Hi,
I have some problems with Xiaomi devices not behaving as expected.
I have searched a lot on the forum but I can’t find any similar topics, if I missed it I apologize and would be grateful for a link
The problem:
When I switch something ON, it switches state to ON, then OFF, then ON again in openhab. Switching OFF shows the same behavior. The device itself however will behave as expected.
This applies both to my Zigbee smart socket and air purifier pro (v6), these devices use different bindings.
Looking at the trace it seems to me that the following happens.
-
Openhab sends a command to the device, the switch item changes state after the command is sent to the device (which is wrong, right?).
-
The device acknowledges the command and this acknowledgement contains the current unswitched status.
-
Openhab reads the acknowledgement and updates the status back to the unswitched state.
-
Once the device has actually switched it sends an update with it’s new state and openhab again updates the state.
Another thing is that the update after switching only contains the new switch state, so other parameters (current consumption, mode, rpm, etc.) are not updated until the next heartbeat (which for the smart socket can be many minutes away).
The questions:
Is this the expected behavior of the bindings?
Have anyone experienced the same behaviours?
INFO level log
2019-01-06 13:23:51.500 [ome.event.ItemCommandEvent] - Item 'Plug_Switch' received command ON
2019-01-06 13:23:51.510 [nt.ItemStatePredictedEvent] - Plug_Switch predicted to become ON
2019-01-06 13:23:51.527 [vent.ItemStateChangedEvent] - Plug_Switch changed from OFF to ON
2019-01-06 13:23:51.535 [vent.ItemStateChangedEvent] - Plug_Switch changed from ON to OFF
2019-01-06 13:23:51.614 [vent.ItemStateChangedEvent] - Plug_Switch changed from OFF to ON
DEBUG level log
2019-01-05 17:45:04.379 [ome.event.ItemCommandEvent] - Item 'Plug_Switch' received command ON
2019-01-05 17:45:04.395 [DEBUG] [rnal.handler.XiaomiDeviceBaseHandler] - Device 158d0002861fb1 on channel mihome:sensor_plug:7c49ebb3ac4c:158d0002861fb1:power received command ON
2019-01-05 17:45:04.398 [nt.ItemStatePredictedEvent] - Plug_Switch predicted to become ON
2019-01-05 17:45:04.423 [vent.ItemStateChangedEvent] - Plug_Switch changed from OFF to ON
2019-01-05 17:45:04.439 [DEBUG] [rnal.handler.XiaomiDeviceBaseHandler] - Item got update: {"cmd":"write_ack","model":"plug","sid":"158d0002861fb1","short_id":28810,"data":"{\"voltage\":3600,\"status\":\"off\",\"inuse\":\"0\",\"power_consumed\":\"1636\",\"load_power\":\"0.00\"}"}
2019-01-05 17:45:04.456 [vent.ItemStateChangedEvent] - Plug_Switch changed from ON to OFF
2019-01-05 17:45:04.515 [DEBUG] [rnal.handler.XiaomiDeviceBaseHandler] - Item got update: {"cmd":"report","model":"plug","sid":"158d0002861fb1","short_id":28810,"data":"{\"status\":\"on\"}"}
2019-01-05 17:45:04.524 [vent.ItemStateChangedEvent] - Plug_Switch changed from OFF to ON
TRACE level log
2019-01-06 12:20:22.167 [nt.ItemStatePredictedEvent] - Plug_Switch predicted to become ON
==> /var/log/openhab2/openhab.log <==
2019-01-06 12:20:22.169 [DEBUG] [internal.handler.XiaomiBridgeHandler] - Send to bridge mihome:bridge:7c49ebb3ac4c: {"cmd": "write", "sid": "158d0002861fb1", "data": "{\"status\": \"on\", \"key\": \"ABB5061B2B3E9FBF7BF284DF73620DB7\"}"}
2019-01-06 12:20:22.173 [TRACE] [.mihome.internal.socket.XiaomiSocket] - Sending message: {"cmd": "write", "sid": "158d0002861fb1", "data": "{\"status\": \"on\", \"key\": \"ABB5061B2B3E9FBF7BF284DF73620DB7\"}"} to /192.168.3.103:9898
==> /var/log/openhab2/events.log <==
2019-01-06 12:20:22.184 [vent.ItemStateChangedEvent] - Plug_Switch changed from OFF to ON
==> /var/log/openhab2/openhab.log <==
2019-01-06 12:20:22.189 [DEBUG] [.mihome.internal.socket.XiaomiSocket] - Received Datagram from 192.168.3.103:9898 on Port 9898
2019-01-06 12:20:22.193 [TRACE] [internal.handler.XiaomiBridgeHandler] - Received message {"cmd":"write_ack","model":"plug","sid":"158d0002861fb1","short_id":28810,"data":"{\"voltage\":3600,\"status\":\"off\",\"inuse\":\"0\",\"power_consumed\":\"1671\",\"load_power\":\"0.00\"}"}
2019-01-06 12:20:22.197 [TRACE] [internal.handler.XiaomiBridgeHandler] - Updated "last time seen" for device 158d0002861fb1
2019-01-06 12:20:22.200 [DEBUG] [internal.handler.XiaomiBridgeHandler] - Cancelled running timer
2019-01-06 12:20:22.205 [DEBUG] [internal.handler.XiaomiBridgeHandler] - Device 158d0002861fb1 honored write request
2019-01-06 12:20:22.208 [DEBUG] [rnal.handler.XiaomiDeviceBaseHandler] - Item got update: {"cmd":"write_ack","model":"plug","sid":"158d0002861fb1","short_id":28810,"data":"{\"voltage\":3600,\"status\":\"off\",\"inuse\":\"0\",\"power_consumed\":\"1671\",\"load_power\":\"0.00\"}"}
==> /var/log/openhab2/events.log <==
2019-01-06 12:20:22.222 [vent.ItemStateChangedEvent] - Plug_Switch changed from ON to OFF
==> /var/log/openhab2/openhab.log <==
2019-01-06 12:20:22.233 [TRACE] [.mihome.internal.socket.XiaomiSocket] - Data received and notified 1 listeners
2019-01-06 12:20:22.236 [TRACE] [.mihome.internal.socket.XiaomiSocket] - Thread Thread[Thread-69,5,main] waiting for data on port 9898
2019-01-06 12:20:22.270 [DEBUG] [.mihome.internal.socket.XiaomiSocket] - Received Datagram from 192.168.3.103:4321 on Port 9898
2019-01-06 12:20:22.272 [TRACE] [internal.handler.XiaomiBridgeHandler] - Received message {"cmd":"report","model":"plug","sid":"158d0002861fb1","short_id":28810,"data":"{\"status\":\"on\"}"}
2019-01-06 12:20:22.274 [TRACE] [internal.handler.XiaomiBridgeHandler] - Updated "last time seen" for device 158d0002861fb1
2019-01-06 12:20:22.277 [DEBUG] [internal.handler.XiaomiBridgeHandler] - Cancelled running timer
2019-01-06 12:20:22.280 [DEBUG] [rnal.handler.XiaomiDeviceBaseHandler] - Item got update: {"cmd":"report","model":"plug","sid":"158d0002861fb1","short_id":28810,"data":"{\"status\":\"on\"}"}
2019-01-06 12:20:22.284 [TRACE] [.mihome.internal.socket.XiaomiSocket] - Data received and notified 1 listeners
2019-01-06 12:20:22.288 [TRACE] [.mihome.internal.socket.XiaomiSocket] - Thread Thread[Thread-69,5,main] waiting for data on port 9898
==> /var/log/openhab2/events.log <==
2019-01-06 12:20:22.289 [vent.ItemStateChangedEvent] - Plug_Switch changed from OFF to ON
EDIT:
This is running on a raspberry pi 3B with openhabian 1.4 and openHAB 2.4.
The gateway/bridge is Xiaomi v3 (not aqara).