Xiaomi miio chuangmi.plug.v3 power on/off not works

Hello,
i’ve been using Xiaomi Mi IO Binding (binding-miio - 2.5.2) plugin without problems for chuangmi.plug.v3 devices, but since i’ve updated the plug device to 2.0.6_0012 version, the power on/off addon functionality stops working. I’m able to switch usb to on/off correctly, even send the command set_power [on/off] and both are working correctly switching on and off usb’s or power. But Using the power channel (miio:generic:XXXXX:power) the device does not receive any order. I’ve other two plug’s v3 with the previous version and are also working correctly for all functionalities.
Does anyone have this behaviour and know a solution to restore the power channel? I’ve try to reset the device but same problem.

Device info:

hardwareVersion: esp8266
modelId: chuangmi.plug.v3
vendor: Xiaomi
wifiFirmware: v3.1-52-g39e5526-dirty
Current firmware version: 2.0.6_0012

Thanks, best regards.

  • The right place for the json in solution for ubuntu apt installation is:
    /etc/openhab2/misc/miio

I have same problem, do you have solution?

Hi,

i’ve write two rules, one to power on and other to power off, it works but seems that after 5 seconds, openhab logs are printing the current status of the plug, so the switch turns to the oposite selected until the command send by the rule takes effect over the plug.
Also, seems that with this version, changes from xiaomi application to the plug, are not being notified from the device to openhab, something thats with older plugv3 versions was happening.

Items:
Switch plugv3 “Plug v3” [“Switchable”] {channel=“miio:generic:xxxx:power” }
String plugv3_send_command “Send Command” {channel=“miio:generic:xxxx:actions#commands”}

Here you have the rules:

  • plugv3 is the item associated to plugv3 power channel
  • plugv3_send_command is the item associated to plugv3 commands channel

rule "Miio plug ON "
when
Item plugv3 received command ON
then
plugv3_send_command.sendCommand(“set_power [on]”)
end

rule "Miio plug OFF "
when
Item plugv3 received command OFF
then
plugv3_send_command.sendCommand(“set_power [off]”)
end

This is a dirty solution, would be fine to found the origin of the problem and fix the addon behaviour for this plugV3 version.

Best regards.

1 Like

Thanks

Hi,

I tried this rule, but didn’t resolve.

Mmm, it’s strange, on logs when you change the status of power channel you should see in logs something like this if the rules are ok (also previows post has been updated with the correct items/channels):

openhabsrv:~$tail -F /var/log/openhab2/events.log

From OFF to ON

> [ome.event.ItemCommandEvent] - Item 'plugv3' received command ON (Rule trigger)
> [nt.ItemStatePredictedEvent] - plugv3 predicted to become ON (What addon should do)
> [ome.event.ItemCommandEvent] - Item 'plugv3_send_command' received command set_power [on]
> [vent.ItemStateChangedEvent] - plugv3 changed from OFF to ON (addon turn power on but seems like command does not arrive to plug)
> [nt.ItemStatePredictedEvent] - plugv3_send_command predicted to become set_power [on] (Manual command send by rule)
> [vent.ItemStateChangedEvent] - plugv3_send_command changed from {"code":0,"id":381,"result":["ok"],"exe_time":150} to set_power [on]
> [vent.ItemStateChangedEvent] - plugv3 changed from ON to OFF (This is the malcfunction event of the addon for this plug version)
> [vent.ItemStateChangedEvent] - plugv3_send_command changed from set_power [on] to {"code":0,"id":385,"result":["ok"],"exe_time":160} (Power on command result)
> [vent.ItemStateChangedEvent] - plugv3 changed from OFF to ON (Finally the item change to real status once command is executed)

Can you send a debug log to me to understand the issue at hand better and see the detailed communication with the device.
To enable detailed logging
log:set debug org.openhab.binding.miio
log:tail org.openhab.binding.miio

Are the other functionalities / properties updating fine?
If not, you may want to check if the token has not changed during the upgrade.

Hi Marcel,
all other functionalities are working ok, i can power on the usb correctly and see the temperature value. Also, i’ve verify the token, and is correct. To perform this test, i’ve disabled the rules to send on/off power command manually. Here you have the logs:

When i turn on the plug power(functionality that doesn’t work)

11:58:45.148 [DEBUG] [iio.internal.handler.MiIoBasicHandler] - Locating action for channel power: ON
11:58:45.149 [DEBUG] [iio.internal.handler.MiIoBasicHandler] - Sending command set_on[]
11:58:45.149 [DEBUG] [rnal.transport.MiIoAsyncCommunication] - Command added to Queue {"id":4,"method":"set_on","params":[]} -> myplugip (Device: myplugid token: myplugupdatedtoken Queue: 1)
11:58:45.149 [DEBUG] [iio.internal.handler.MiIoBasicHandler] - Periodic update for 'miio:generic:myplugid' (miio:basic)
11:58:45.150 [DEBUG] [rnal.transport.MiIoAsyncCommunication] - Sending Ping myplugid (myplugip)
11:58:45.158 [DEBUG] [rnal.transport.MiIoAsyncCommunication] - Ping myplugid (myplugip) success
11:58:45.159 [DEBUG] [rnal.transport.MiIoAsyncCommunication] - Command added to Queue {"id":5,"method":"get_prop","params":["power","usb_on","temperature","wifi_led"]} -> myplugip (Device: myplugid token: myplugupdatedtoken Queue: 2)
11:58:45.159 [DEBUG] [rnal.transport.MiIoAsyncCommunication] - Command added to Queue {"id":6,"method":"miIO.info","params":[]} -> myplugip (Device: myplugid token: myplugupdatedtoken Queue: 3)
11:58:49.319 [DEBUG] [.internal.handler.MiIoAbstractHandler] - Received response for myplugid type: UNKNOWN, result: {}, fullresponse: {"id":4,"error":{"code":-9999,"message":"user ack timeout"},"exe_time":4020}
11:58:49.322 [DEBUG] [.internal.handler.MiIoAbstractHandler] - Error received: {"code":-9999,"message":"user ack timeout"}
11:58:49.697 [DEBUG] [.internal.handler.MiIoAbstractHandler] - Received response for myplugid type: GET_PROPERTY, result: ["off",true,25,"on"], fullresponse: {"id":5,"result":["off",true,25,"on"],"exe_time":340}
11:58:49.803 [DEBUG] [.internal.handler.MiIoAbstractHandler] - Received response for myplugid type: MIIO_INFO, result: {"life":528313,"uid":mypluguid,"model":"chuangmi.plug.v3","token":"myplugupdatedtoken","ipflag":1,"fw_ver":"2.0.6_0012","miio_ver":"0.0.8","hw_ver":"esp8266","mmfree":17304,"mac":"myplugmac","wifi_fw_ver":"v3.1-52-g39e5526-dirty","ap":{"ssid":"mywifi","bssid":"mybssid","rssi":-83,"primary":11},"netif":{"localIp":"myplugip","mask":"255.255.255.0","gw":"myaccessip"}}, fullresponse: {"id":6,"result":{"life":528313,"uid":mypluguid,"model":"chuangmi.plug.v3","token":"myplugupdatedtoken","ipflag":1,"fw_ver":"2.0.6_0012","miio_ver":"0.0.8","hw_ver":"esp8266","mmfree":17304,"mac":"myplugmac","wifi_fw_ver":"v3.1-52-g39e5526-dirty","ap":{"ssid":"mywifi","bssid":"mybssid","rssi":-83,"primary":11},"netif":{"localIp":"myplugip","mask":"255.255.255.0","gw":"myaccessip"}},"exe_time":30}

I can see, that the command send by de addon is set_on[] and not set_power[on], and seems here is the problem, manually sending set_on[] is not working, but works with set_power[on] , so may be in this version, set_on[]/set_off[] commands has been removed

And here you have when i turn the usb on that is working:

12:12:14.666 [DEBUG] [iio.internal.handler.MiIoBasicHandler] - Locating action for channel usb: ON
12:12:14.666 [DEBUG] [iio.internal.handler.MiIoBasicHandler] - Sending command set_usb_on[]
12:12:14.667 [DEBUG] [rnal.transport.MiIoAsyncCommunication] - Command added to Queue {"id":15,"method":"set_usb_on","params":[]} -> myplugip (Device: myplugid token: myplugtoken Queue: 1)
12:12:14.667 [DEBUG] [iio.internal.handler.MiIoBasicHandler] - Periodic update for 'miio:generic:myplugid' (miio:basic)
12:12:14.667 [DEBUG] [rnal.transport.MiIoAsyncCommunication] - Sending Ping myplugid (myplugip)
12:12:14.877 [DEBUG] [rnal.transport.MiIoAsyncCommunication] - Ping myplugid (myplugip) success
12:12:14.877 [DEBUG] [rnal.transport.MiIoAsyncCommunication] - Command added to Queue {"id":16,"method":"get_prop","params":["power","usb_on","temperature","wifi_led"]} -> myplugip (Device: myplugid token: myplugtoken Queue: 1)
12:12:15.241 [DEBUG] [.internal.handler.MiIoAbstractHandler] - Received response for myplugid type: UNKNOWN, result: ["ok"], fullresponse: {"id":15,"result":["ok"],"exe_time":330}
12:12:15.613 [DEBUG] [.internal.handler.MiIoAbstractHandler] - Received response for myplugid type: GET_PROPERTY, result: ["off",true,25,"on"], fullresponse: {"id":16,"result":["off",true,25,"on"],"exe_time":330}

Thanks, best regards.

You can give this a try…

If you have a newer version of the binding (the one with local db support) , you can add attached file to your /openhab/conf/misc/miio folder. Than go to the thing config and override the model with chuangmi.plug.v3fw

chuangmi.plug.v3fw.json (1.3 KB)

Hi,
i’m using binding-miio - 2.5.2 version, i think is with local db support, but i don’t know where to put this json file (i’ve try making directory in /etc/openhab2/config/miio, but is not detected):

[WARN ] [iio.internal.handler.MiIoBasicHandler] - Database entry for model ‘chuangmi.plug.v3fw’ cannot be found.

[DEBUG] [iio.internal.handler.MiIoBasicHandler] - Locating action for channel power: ON
[DEBUG] [iio.internal.handler.MiIoBasicHandler] - Actions not loaded yet

Could you explain me the correct path where to put this json file on an ubuntu openhab apt installation?

Thanks.

hi victor,

Path is right. but , db support was merged in 2.5.3. so you would need to pull the new version of the binding.
You could also try the very latest one… it has several (stability) improvements over the current offical build
Xiaomi Robot Vacuum Binding

Hi again Marcel,

after uninstall the official miio addon, an install your las jar, seems that is not able to load the new v3 model, json is in /etc/openhab2/config/miio folder, as i said doing an mkdir for config folder and miio folder. The message when starting openhab is as with version 2.5.2:

[WARN ] [iio.internal.handler.MiIoBasicHandler] - Database entry for model 'chuangmi.plug.v3fw' cannot be found.

and changing model version on thing, the logs are:

[DEBUG] [iio.internal.handler.MiIoBasicHandler] - Periodic update for 'miio:generic:myplugid' (miio:basic)
[DEBUG] [iio.internal.handler.MiIoBasicHandler] - Building Channel Structure for miio:generic:myplugid - Model: chuangmi.plug.v3fw
[WARN ] [iio.internal.handler.MiIoBasicHandler] - Database entry for model 'chuangmi.plug.v3fw' cannot be found.
[DEBUG] [rnal.transport.MiIoAsyncCommunication] - Command added to Queue {"id":12,"method":"miIO.info","params":[]} -> myplugip (Device: myplugid token: E3756E59XXXXXXXXXXXXXXXXE6985834 Queue: 1)
[DEBUG] [rnal.transport.MiIoAsyncCommunication] - Sending Ping myplugid (myplugip)
[DEBUG] [rnal.transport.MiIoAsyncCommunication] - Ping myplugid (myplugip) success
[INFO ] [.internal.handler.MiIoAbstractHandler] - Mi Device model chuangmi.plug.v3 has model config: chuangmi.plug.v3fw. Unexpected unless manual override
[INFO ] [.internal.handler.MiIoAbstractHandler] - Mi Device model chuangmi.plug.v3 identified as: Mi Power-plug v3 (chuangmi.plug.v3). Matches thingtype miio:basic

the version that appears on cli seems the last one:
Active │ 80 │ 2.5.4.202004011447 │ openHAB Add-ons :: Bundles :: Xiaomi Mi IO Binding

Some idea, thanks.

Yes… got an idea… it was my mistake…the location changed last minute… I still had the old location in my mind.

the right folder is /openhab/conf/misc/miio in your caste /etc/openhab/conf/misc/miio

you should see something like this as soon as you add the file:

20:21:36.700 [DEBUG] [ternal.basic.MiIoDatabaseWatchService] - Local Databases file chuangmi.plug.v3fw.json changed. Refreshing device database.
20:21:36.702 [DEBUG] [ternal.basic.MiIoDatabaseWatchService] - Adding local json db file: chuangmi.plug.v3fw.json, file:/openhab/conf/misc/miio/chuangmi.plug.v3fw.json
20:21:49.736 [DEBUG] [iio.internal.handler.MiIoBasicHandler] - Building Channel Structure for miio:generic:0581B26C - Model: chuangmi.plug.v3fw
20:21:49.737 [DEBUG] [iio.internal.handler.MiIoBasicHandler] - Using device database: /openhab/conf/misc/miio/chuangmi.plug.v3fw.json for device chuangmi.plug.v3fw
20:23:52.078 [DEBUG] [rnal.transport.MiIoAsyncCommunication] - Command added to Queue {"id":8,"method":"set_power","params":["on"]} -> 192.168.3.111 (Device: 0581B26C token: CF338CBDA8

Thanks for the help Marcel, but once i move the json file to correct folder, nothing in logs appears. Also i’ve try uninstalling 2.5.4 miio version, cleaning openhab cache and installing again, but same result, the logs are equal as before post. I didn’t see the line where load json file from file : /etc/openhab2/conf/misc/miio/chuangmi.plug.v3fw.json.
As you also explain in your addon readme, this folder should be the correct one /etc/openhab2/config/misc/miio,but again same result. The openhab2 directory is where items, things, and other openhab configuration files are placed.

openhabsrv:/etc/openhab2/config/misc/miio$ ls -arlt
openhab openhab 1294 mar 31 23:02 chuangmi.plug.v3fw.json

Best regards

the only thing I see is the conf vs config folder…
I’m not 100% confident which one is right. In my system it is [opt]/openhab/conf/misc/miio
the other folders in conf are the ones for items, things etc

Ok, this info about other folders you has gave me what i was doing wrong. I’ve check the configuration folder on openhab2 whith an apt ubuntu installation, and is only /etc/openhab2. So i’ve added your v3fw json in /etc/openhab2/misc/miio. Then on openhab restart, the new model was loaded, and of course, your solution made my plug v3 works again.

Thanks.

Thanks for referencing the solution in your original post. I think that indeed helps for others to easy find the solution.

Hello,

Since a couple weeks the switches on my smart plug stopped working, I have followed the instructions in this post and the main power switch started working again however the usb switch is not.

This is the log

09:04:54.569 [INFO ] [.internal.handler.MiIoAbstractHandler] - Mi Device model chuangmi.plug.v3 has model config: chuangmi.plug.v3fw. Unexpected unless manual override
09:04:54.575 [DEBUG] [.internal.handler.MiIoAbstractHandler] - Mi Device model chuangmi.plug.v3 identified as: Mi Power-plug v3 (chuangmi.plug.v3). Matches thingtype miio:basic
09:04:54.714 [DEBUG] [.internal.handler.MiIoAbstractHandler] - Received response for 07264C6D type: GET_PROPERTY, result: ["off",false,28,"off"], fullresponse: {"result":["off",false,28,"off"],"id":2}
09:04:54.845 [DEBUG] [.internal.handler.MiIoAbstractHandler] - Received response for 07264C6D type: MIIO_INFO, result: {"life":1863473,"token":"a65ac1ba29dee52cd1d9e42832ca0e5a","mac":"40:31:3C:D7:C1:EC","fw_ver":"1.3.0_92","hw_ver":"ESP8266","uid":"2147483647","model":"chuangmi.plug.v3","wifi_fw_ver":"1.5.0-dev(7f7a714)","ap":{"rssi":-70,"ssid":"Gattolandia","bssid":"D8:0D:17:6B:10:73"},"netif":{"localIp":"192.168.0.144","mask":"255.255.255.0","gw":"192.168.0.1"},"mmfree":8864}, fullresponse: {"result":{"life":1863473,"token":"a65ac1ba29dee52cd1d9e42832ca0e5a","mac":"40:31:3C:D7:C1:EC","fw_ver":"1.3.0_92","hw_ver":"ESP8266","uid":"2147483647","model":"chuangmi.plug.v3","wifi_fw_ver":"1.5.0-dev(7f7a714)","ap":{"rssi":-70,"ssid":"Gattolandia","bssid":"D8:0D:17:6B:10:73"},"netif":{"localIp":"192.168.0.144","mask":"255.255.255.0","gw":"192.168.0.1"},"mmfree":8864},"id":3}
09:05:03.777 [DEBUG] [iio.internal.handler.MiIoBasicHandler] - Periodic update for 'miio:generic:07264C6D' (miio:basic)
09:05:03.789 [DEBUG] [rnal.transport.MiIoAsyncCommunication] - Command added to Queue {"id":4,"method":"get_prop","params":["power","usb_on","temperature","wifi_led"]} -> 192.168.0.144 (Device: 07264C6D token: A65AC1BAXXXXXXXXXXXXXXXX32CA0E5A Queue: 1)
09:05:04.007 [DEBUG] [.internal.handler.MiIoAbstractHandler] - Received response for 07264C6D type: GET_PROPERTY, result: ["off",false,28,"off"], fullresponse: {"result":["off",false,28,"off"],"id":4}
09:05:21.145 [DEBUG] [iio.internal.handler.MiIoBasicHandler] - Locating action for channel power: ON
09:05:21.151 [DEBUG] [iio.internal.handler.MiIoBasicHandler] - Sending command set_power["on"]
09:05:21.157 [DEBUG] [rnal.transport.MiIoAsyncCommunication] - Command added to Queue {"id":5,"method":"set_power","params":["on"]} -> 192.168.0.144 (Device: 07264C6D token: A65AC1BAXXXXXXXXXXXXXXXX32CA0E5A Queue: 1)
09:05:21.162 [DEBUG] [iio.internal.handler.MiIoBasicHandler] - Periodic update for 'miio:generic:07264C6D' (miio:basic)
09:05:21.168 [DEBUG] [rnal.transport.MiIoAsyncCommunication] - Command added to Queue {"id":6,"method":"get_prop","params":["power","usb_on","temperature","wifi_led"]} -> 192.168.0.144 (Device: 07264C6D token: A65AC1BAXXXXXXXXXXXXXXXX32CA0E5A Queue: 2)
09:05:21.385 [DEBUG] [.internal.handler.MiIoAbstractHandler] - Received response for 07264C6D type: SET_POWER, result: ["ok"], fullresponse: {"result":["ok"],"id":5}
09:05:21.517 [DEBUG] [.internal.handler.MiIoAbstractHandler] - Received response for 07264C6D type: GET_PROPERTY, result: ["on",false,28,"off"], fullresponse: {"result":["on",false,28,"off"],"id":6}
09:05:29.889 [DEBUG] [iio.internal.handler.MiIoBasicHandler] - Locating action for channel usb: ON
09:05:29.896 [DEBUG] [iio.internal.handler.MiIoBasicHandler] - Command not send. Value null
09:05:29.903 [DEBUG] [iio.internal.handler.MiIoBasicHandler] - Periodic update for 'miio:generic:07264C6D' (miio:basic)
09:05:29.909 [DEBUG] [rnal.transport.MiIoAsyncCommunication] - Command added to Queue {"id":7,"method":"get_prop","params":["power","usb_on","temperature","wifi_led"]} -> 192.168.0.144 (Device: 07264C6D token: A65AC1BAXXXXXXXXXXXXXXXX32CA0E5A Queue: 1)
09:05:30.878 [DEBUG] [.internal.handler.MiIoAbstractHandler] - Received response for 07264C6D type: GET_PROPERTY, result: ["on",false,28,"off"], fullresponse: {"result":["on",false,28,"off"],"id":7}
09:05:33.804 [DEBUG] [iio.internal.handler.MiIoBasicHandler] - Periodic update for 'miio:generic:07264C6D' (miio:basic)
09:05:33.815 [DEBUG] [rnal.transport.MiIoAsyncCommunication] - Command added to Queue {"id":8,"method":"get_prop","params":["power","usb_on","temperature","wifi_led"]} -> 192.168.0.144 (Device: 07264C6D token: A65AC1BAXXXXXXXXXXXXXXXX32CA0E5A Queue: 1)
09:05:34.254 [DEBUG] [.internal.handler.MiIoAbstractHandler] - Received response for 07264C6D type: GET_PROPERTY, result: ["on",false,28,"off"], fullresponse: {"result":["on",false,28,"off"],"id":8}

I think the issue is here as the value is null.

09:05:29.889 [DEBUG] [iio.internal.handler.MiIoBasicHandler] - Locating action for channel usb: ON
09:05:29.896 [DEBUG] [iio.internal.handler.MiIoBasicHandler] - Command not send. Value null

Any ideas on how to solve this?

Thanks,
r