Xiaomi Mi Smart Plug (New Model) Device Handler

Hmm, ok. It looks like the plug turned on/off based on what I see, is that right?

I was hoping I could easily repurpose another similar DTH I have for this device, but it doesn’t look like I’ll be able to do that. This is turning out to be a lot more complicated than I expected since I don’t have a device to test with.

This is the power reporting cluster, and there are several showing up. Unfortunately the value is always 0000, as you can see in your live logs. Looks like we won’t be able to use that for anything.

There are also 2 other clusters being used - FCC0 and 000C. 000C seems to have to do with power reporting, and FCC0 is a Xiaomi manufacturer specific cluster (source), which looks like that’s where several attributes live:

I looked back at one DTH you tried:

https://raw.githubusercontent.com/bspranger/Xiaomi/master/devicetypes/bspranger/xiaomi-zigbee-outlet.src/xiaomi-zigbee-outlet.groovy

Did that one turn it on/off?

If so, lines 165 and 172 may just need to be tweaked to change the endpoint from 02 and 03, to what this plug sends. Can you try going back to that DTH and change line 165 so that the endpoint is 15 instead of 02 and change line 172 so that endpoint is 16 instead of 03.

It should look like this after those changes:

else if (descMap.cluster == "000C" && descMap.attrId == "0055" && descMap.endpoint == "15") {
	def wattage_int = Long.parseLong(descMap.value, 16)
	def wattage = Float.intBitsToFloat(wattage_int.intValue())
	wattage = Math.round(wattage * 10) * 0.1
	resultMap = createEvent(name: "power", value: wattage, unit: 'W')
	log.debug "${device.displayName}: Reported power use is ${wattage}W"
}
else if (descMap.cluster == "000C" && descMap.attrId == "0055" && descMap.endpoint == "16") {
	def energy_int = Long.parseLong(descMap.value, 16)
	def energy = Float.intBitsToFloat(energy_int.intValue())
	energy = Math.round(energy * 100) * 0.0001
	resultMap = createEvent(name: "energy", value: energy, unit: 'kWh')
	log.debug "${device.displayName}: Reported energy usage is ${energy}kWh"
}

I’m thinking these simple changes may work for you. Can you try? My DTH is pretty much useless at this point.

If you’re curious, here’s my source for that info and why I think that should work for you:

image

2 Likes