Mi(Xiaomi) Smart home bindings?

Does anyone can help me identify this problem?
My xiaomi aqara wall switch is not reliably working. Every channel is linked to 2 items, paperUI generated items, and from xiaomi.items

I have rule to trigger items created from xiaomi.items and while those items are changed, actual switch is not always switched, most noticable by seeing paperUI generated items not changing. Does anybody have any ideas why this happens?

Also, it happens that OH will still think that xiaomi devices is online while it cannot communicate at all. If I analyze from debug log, no heartbeat entry on it, thus xiaomi devices does not communicate to OH.

could you please post your items-files and the rule you’re talking about?
My Aqara Switch button can’t be bound to an item, it has to be rule-only, so I guess, the Aqara Wall Switch stays either ON or OFF, doesn’t it?

basically, the Xiaomi Mihome binding can’t tell, if a specific device is online or not, as the devices shut down and only communicate if pressed or in intervals. The Gateway is as far as I know the only device which sends the heartbeat - and if there’s no heartbeat anymore I suspect a Network issue?
So, the question here is: Do you mean the gateway’s heartbeat or the devices (Switches, sensors, …) ?

Sure, here it is.

I don’t understand about this question. The thing is, I just enabled debug logging for Xiaomi binding on OH few days after the problem occurs, so I have no debug logging when things run smooth when I install them.
I can control gateway using mihome app, but not from OH. Both are in same wifi network.

I reset the xiaomi gateway yesterday, to change network to different wifi AP, but same network, with about 4db better signal, then the log start showing heartbeat logs.

ok. now I see - your wall switch has two distinct states: ON and OFF (you flip the switch). That’s why you can have an item from it. (my Switch doesn’t have a state - it only has Events)

Then - the heartbeat you see is the connection for the gateway to OH2. The heartbeat is “only” from the gateway - not from the sensors. So if you still see the heartbeat, that means the connection between OH2 and the gateway should be up and running. It doesn’t - however - say something on the connection between the sensors and the gateway. That is solely out of reach of the binding and can’t be seen afaik. OH will always think, all configured sensors will be online.

if there’s no heartbeat anymore my bet is, you’ll have to dig into network level - it shouldn’t be a OH2 issue as you have a heartbeat already…

@binderth I think I did overcome this problem by resetting my gateway network setting. But now I have another question. One of my switch is always having this error log, but apparently it is working without problem. I tried resetting gateway and removing thing in OH and re-adding it. This error log persist.

2018-04-12 17:07:25.824 [DEBUG] [home.handler.XiaomiDeviceBaseHandler] - Device 158d0001f503dc on channel mihome:ctrl_neutral1:158d0001f503dc:ch1 received command ON

==> /var/log/openhab2/events.log <==

2018-04-12 17:07:25.830 [ome.event.ItemCommandEvent] - Item 'Light_outdoor_1' received command ON

==> /var/log/openhab2/openhab.log <==

2018-04-12 17:07:25.839 [DEBUG] [g.mihome.handler.XiaomiBridgeHandler] - Send to bridge mihome:bridge:7811dcb226c5: {"cmd": "write", "sid": "158d0001f503dc", "data": "{\"channel_0\": \"on\", \"key\": \"69599675D8478666BD2EC976E11DCB53"}"}

==> /var/log/openhab2/events.log <==

2018-04-12 17:07:25.842 [vent.ItemStateChangedEvent] - Light_outdoor_1 changed from OFF to ON

==> /var/log/openhab2/openhab.log <==

2018-04-12 17:07:25.843 [ERROR] [ndler.XiaomiAqaraActorSwitch1Handler] - Can't handle command ON on channel mihome:ctrl_neutral1:158d0001f503dc:ch1

2018-04-12 17:07:25.851 [DEBUG] [.mihome.internal.socket.XiaomiSocket] - Received Datagram from 192.168.123.55:9898 on Port 9898

2018-04-12 17:07:25.863 [DEBUG] [g.mihome.handler.XiaomiBridgeHandler] - Device 158d0001f503dc honored write request

2018-04-12 17:07:25.868 [DEBUG] [home.handler.XiaomiDeviceBaseHandler] - Item got update: {"cmd":"write_ack","model":"ctrl_neutral1","sid":"158d0001f503dc","short_id":22716,"data":"{\"voltage\":3300,\"channel_0\":\"off\"}"}

==> /var/log/openhab2/events.log <==

2018-04-12 17:07:25.881 [vent.ItemStateChangedEvent] - Light_outdoor_1 changed from ON to OFF

==> /var/log/openhab2/openhab.log <==

2018-04-12 17:07:26.076 [DEBUG] [.mihome.internal.socket.XiaomiSocket] - Received Datagram from 192.168.123.55:4321 on Port 9898

2018-04-12 17:07:26.081 [DEBUG] [home.handler.XiaomiDeviceBaseHandler] - Item got update: {"cmd":"report","model":"ctrl_neutral1","sid":"158d0001f503dc","short_id":22716,"data":"{\"channel_0\":\"on\"}"}

==> /var/log/openhab2/events.log <==

2018-04-12 17:07:26.104 [vent.ItemStateChangedEvent] - Light_outdoor_1 changed from OFF to ON

==> /var/log/openhab2/openhab.log <==

2018-04-12 17:07:26.157 [DEBUG] [.mihome.internal.socket.XiaomiSocket] - Received Datagram from 192.168.123.55:4321 on Port 9898

2018-04-12 17:07:26.162 [DEBUG] [home.handler.XiaomiDeviceBaseHandler] - Item got update: {"cmd":"heartbeat","model":"gateway","sid":"7811dcb226c5","short_id":"0","token":"apbD2Nr0YU7KEygd","data":"{\"ip\":\"192.168.123.55\"}"}

2018-04-12 17:07:36.138 [DEBUG] [.mihome.internal.socket.XiaomiSocket] - Received Datagram from 192.168.123.55:4321 on Port 9898

2018-04-12 17:07:36.143 [DEBUG] [home.handler.XiaomiDeviceBaseHandler] - Item got update: {"cmd":"heartbeat","model":"gateway","sid":"7811dcb226c5","short_id":"0","token":"Iny6wOBDSmHS4O5l","data":"{\"ip\":\"192.168.123.55\"}"}

Did you change the configuration of the thing and/or item? Perhaps it’s just a cache/tmp problem, try this:

I’m very similar

2018-03-18 09:03:10.017 [ERROR] [ndler.XiaomiAqaraActorSwitch1Handler] - Can't handle command ON on channel mihome:ctrl_ln1:id:ch1
2018-03-18 09:03:12.751 [ERROR] [ndler.XiaomiAqaraActorSwitch1Handler] - Can't handle command OFF on channel mihome:ctrl_ln1:id:ch1

My switch works, the error only occurs if the switch is controlled through OH2.
@dimalo Help understand the cause of this error. Maybe you need to finish something in a binding?

hi guys,
I finally found the issue and just had to look a bit closer… with the newest PR the error message should be gone.
The problem was the message came, even if the command was processed correctly…

@WeirdlyChosen:
if your switch is not controlled, maybe the distance to the gateway is too far?

with the current version the binding also shows if the device is offline, when OH didn’t receive any heartbeat for more than 2 hours.

do we have a feedback for Xiaomi Aqara Neutral Wall Switch (1 and 2 buttons)?At the xiaomi binding page says that they are supported but (not yet confirmed)…Anyone using one?I use the non Neutral version and they work just fine…Any feedback?

Thank you, I will try.

I have one button. It works, but there was an error in the log, see the discussion above.

I can not enable developer mode. Has something changed after updating the My Home application?
Update: figured out

my non neutral sinlge switch gives an error too but it works just fine.I just needed to know if the neutral version switches works fine too .They r cheaper right know at Gearbest.

noobie here ,what PR means?

I don’t know if the previous posters that had a similar issue fixed theirs, but I had an issue recently with a new Xiaomi Gateway.

The first issue was that it refused to be autodetected by openHab. The only way I could get it onto OH was to manually add it using its IP. This is new. My previous two Gateways automatically were detected, and was easy to add. After updating to the newest OH, this seems to have become an issue. Not sure what the cause is.

After manuall adding, and entering the developer key, I did manage to successfully add the gateway, as well as the sensors attached to it.

BUT. I was unable to control the Gateway. I also received no updates from the sensors linked to it.
I could change the light on the Gateway with the Mi App, and basic things like Brightness would update on OH, but not vice versa.
I have two other of the same Gateways connected to OH, and they worked fine, so it was strange.

Now, I configure almost everything with files except for loading the actual Things which I do through Paper UI.
So, I took the three Gateways (2 working, 1 with the issue)'s JSONDB Things entries, and placed them together and checked for differences. And I found one. The non-working Gateway’s record didn’t have a ‘serialNumber’ field under properties.

The other two had an serialNumber, which is exactly the same as the identifier ID of the Thing. After some checking, I found that the serialNumber appears to be the MAC address of the Gateway, which is easily findable in the Mi App.

So, I entered the serialNumber (the MAC address without the colons) and refreshed the developer key, and reentered that. This resolved my issue instantly. I can now control my Gateway, as well as receive updates from the sensors connected to it.

So.

  • It appears when adding the Gateway Bridge manually via Paper UI, it doesn’t automatically assign a serialNumber Property to the Thing. This is a read-only field on Paper UI. I had to stop my OH service, and add the property manually to the JsonDB file, and restart OH, to add the value.
  • Note that this applies to the Bridge thing, not the Gateway Light and Sound thing.

Hopefully this helps someone.

I have a similar issue but not quite the same - my devices are all online in OH2 and receive sensor updates, but I cannot control it from OH - it feels like its the developer key but from IOS I have gone into the device on the Mi Home app, tapped repeatedly in the about screen (now everything is is chinese) selected the second option and then used the value next to the “cycle” arrows (which Ive also tapped to get a new code and tried updating. I have also turned on the slider above it (I think this is to enable LAN functions based on other guides)

Anyone have any idea? am I using the correct developer code?

Hello!
I can not get the events of pressing the buttons of the switches with the neutral line. I left for 2 weeks, or forgot or something has changed, help please.
There are 2 switches, one-key and two-key.


rules:

//---------------------------------------------------------------------------------------------
rule "x1"
when
    Channel "mihome:ctrl_ln1:158d0001f2766d:ch1" triggered SHORT_PRESSED
then
    logInfo("RULE","<-- x1")
end
//---------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------
rule "x2 ch1"
when
    Channel "mihome:ctrl_ln2:158d000239f928:ch1" triggered SHORT_PRESSED
then
    logInfo("RULE","<-- x2 ch1")
end
//---------------------------------------------------------------------------------------------
rule "x2 ch2"
when
    Channel "mihome:ctrl_ln2:158d000239f928:ch2" triggered SHORT_PRESSED
then
    logInfo("RULE","<-- x2 ch2")
end
//---------------------------------------------------------------------------------------------

log x1:

2018-05-06 20:41:24.805 [TRACE] [.mihome.internal.socket.XiaomiSocket] - Thread Thread[Thread-34,5,main] waiting for data on port 9898
2018-05-06 20:41:28.325 [DEBUG] [.mihome.internal.socket.XiaomiSocket] - Received Datagram from 192.168.215.203:4321 on Port 9898
2018-05-06 20:41:28.325 [TRACE] [g.mihome.handler.XiaomiBridgeHandler] - Received message {"cmd":"heartbeat","model":"gateway","sid":"286c07fa22a3","short_id":"0","token":"gU08P2A0zE9BYucU","data":"{\"ip\":\"192.168.215.203\"}"}
2018-05-06 20:41:28.326 [TRACE] [g.mihome.handler.XiaomiBridgeHandler] - Updated "last time seen" for device 286c07fa22a3
2018-05-06 20:41:28.326 [DEBUG] [discovery.XiaomiItemDiscoveryService] - Detected Xiaomi smart device - sid: 286c07fa22a3 model: gateway
2018-05-06 20:41:28.328 [TRACE] [.mihome.internal.socket.XiaomiSocket] - Data received and notified 1 listeners
2018-05-06 20:41:28.329 [TRACE] [.mihome.internal.socket.XiaomiSocket] - Thread Thread[Thread-34,5,main] waiting for data on port 9898
2018-05-06 20:41:29.229 [DEBUG] [.mihome.internal.socket.XiaomiSocket] - Received Datagram from 192.168.215.203:4321 on Port 9898
2018-05-06 20:41:29.230 [TRACE] [g.mihome.handler.XiaomiBridgeHandler] - Received message {"cmd":"report","model":"ctrl_ln1.aq1","sid":"158d0001f2766d","short_id":36019,"data":"{\"channel_0\":\"on\"}"}
2018-05-06 20:41:29.231 [TRACE] [g.mihome.handler.XiaomiBridgeHandler] - Updated "last time seen" for device 158d0001f2766d
2018-05-06 20:41:29.232 [DEBUG] [home.handler.XiaomiDeviceBaseHandler] - Item got update: {"cmd":"report","model":"ctrl_ln1.aq1","sid":"158d0001f2766d","short_id":36019,"data":"{\"channel_0\":\"on\"}"}
2018-05-06 20:41:29.233 [TRACE] [.mihome.internal.socket.XiaomiSocket] - Data received and notified 1 listeners
2018-05-06 20:41:29.234 [TRACE] [.mihome.internal.socket.XiaomiSocket] - Thread Thread[Thread-34,5,main] waiting for data on port 9898
2018-05-06 20:41:31.918 [DEBUG] [.mihome.internal.socket.XiaomiSocket] - Received Datagram from 192.168.215.203:4321 on Port 9898
2018-05-06 20:41:31.918 [TRACE] [g.mihome.handler.XiaomiBridgeHandler] - Received message {"cmd":"report","model":"ctrl_ln1.aq1","sid":"158d0001f2766d","short_id":36019,"data":"{\"channel_0\":\"off\"}"}
2018-05-06 20:41:31.919 [TRACE] [g.mihome.handler.XiaomiBridgeHandler] - Updated "last time seen" for device 158d0001f2766d
2018-05-06 20:41:31.919 [DEBUG] [home.handler.XiaomiDeviceBaseHandler] - Item got update: {"cmd":"report","model":"ctrl_ln1.aq1","sid":"158d0001f2766d","short_id":36019,"data":"{\"channel_0\":\"off\"}"}
2018-05-06 20:41:31.923 [TRACE] [.mihome.internal.socket.XiaomiSocket] - Data received and notified 1 listeners
2018-05-06 20:41:31.924 [TRACE] [.mihome.internal.socket.XiaomiSocket] - Thread Thread[Thread-34,5,main] waiting for data on port 9898

log x2:

2018-05-06 20:45:57.873 [TRACE] [.mihome.internal.socket.XiaomiSocket] - Thread Thread[Thread-34,5,main] waiting for data on port 9898
2018-05-06 20:46:00.945 [DEBUG] [.mihome.internal.socket.XiaomiSocket] - Received Datagram from 192.168.215.203:4321 on Port 9898
2018-05-06 20:46:00.946 [TRACE] [g.mihome.handler.XiaomiBridgeHandler] - Received message {"cmd":"report","model":"ctrl_ln2.aq1","sid":"158d000239f928","short_id":10095,"data":"{\"channel_0\":\"on\"}"}
2018-05-06 20:46:00.947 [TRACE] [g.mihome.handler.XiaomiBridgeHandler] - Updated "last time seen" for device 158d000239f928
2018-05-06 20:46:00.947 [DEBUG] [home.handler.XiaomiDeviceBaseHandler] - Item got update: {"cmd":"report","model":"ctrl_ln2.aq1","sid":"158d000239f928","short_id":10095,"data":"{\"channel_0\":\"on\"}"}
2018-05-06 20:46:00.948 [TRACE] [.mihome.internal.socket.XiaomiSocket] - Data received and notified 1 listeners
2018-05-06 20:46:00.950 [TRACE] [.mihome.internal.socket.XiaomiSocket] - Thread Thread[Thread-34,5,main] waiting for data on port 9898
2018-05-06 20:46:04.488 [DEBUG] [.mihome.internal.socket.XiaomiSocket] - Received Datagram from 192.168.215.140:4321 on Port 9898
2018-05-06 20:46:04.489 [TRACE] [.mihome.internal.socket.XiaomiSocket] - Data received and notified 1 listeners
2018-05-06 20:46:04.490 [TRACE] [.mihome.internal.socket.XiaomiSocket] - Thread Thread[Thread-34,5,main] waiting for data on port 9898
2018-05-06 20:46:04.860 [DEBUG] [.mihome.internal.socket.XiaomiSocket] - Received Datagram from 192.168.215.203:4321 on Port 9898
2018-05-06 20:46:04.861 [TRACE] [g.mihome.handler.XiaomiBridgeHandler] - Received message {"cmd":"report","model":"ctrl_ln2.aq1","sid":"158d000239f928","short_id":10095,"data":"{\"channel_1\":\"on\"}"}
2018-05-06 20:46:04.862 [TRACE] [g.mihome.handler.XiaomiBridgeHandler] - Updated "last time seen" for device 158d000239f928
2018-05-06 20:46:04.863 [DEBUG] [home.handler.XiaomiDeviceBaseHandler] - Item got update: {"cmd":"report","model":"ctrl_ln2.aq1","sid":"158d000239f928","short_id":10095,"data":"{\"channel_1\":\"on\"}"}
2018-05-06 20:46:04.865 [TRACE] [.mihome.internal.socket.XiaomiSocket] - Data received and notified 1 listeners
2018-05-06 20:46:04.866 [TRACE] [.mihome.internal.socket.XiaomiSocket] - Thread Thread[Thread-34,5,main] waiting for data on port 9898
2018-05-06 20:46:07.853 [DEBUG] [.mihome.internal.socket.XiaomiSocket] - Received Datagram from 192.168.215.203:4321 on Port 9898
2018-05-06 20:46:07.853 [TRACE] [g.mihome.handler.XiaomiBridgeHandler] - Received message {"cmd":"heartbeat","model":"gateway","sid":"286c07fa22a3","short_id":"0","token":"HmY3FTHKieD5ckhh","data":"{\"ip\":\"192.168.215.203\"}"}
2018-05-06 20:46:07.854 [TRACE] [g.mihome.handler.XiaomiBridgeHandler] - Updated "last time seen" for device 286c07fa22a3
2018-05-06 20:46:07.854 [DEBUG] [discovery.XiaomiItemDiscoveryService] - Detected Xiaomi smart device - sid: 286c07fa22a3 model: gateway
2018-05-06 20:46:07.856 [TRACE] [.mihome.internal.socket.XiaomiSocket] - Data received and notified 1 listeners
2018-05-06 20:46:07.856 [TRACE] [.mihome.internal.socket.XiaomiSocket] - Thread Thread[Thread-34,5,main] waiting for data on port 9898
2018-05-06 20:46:08.200 [DEBUG] [.mihome.internal.socket.XiaomiSocket] - Received Datagram from 192.168.215.203:4321 on Port 9898
2018-05-06 20:46:08.201 [TRACE] [g.mihome.handler.XiaomiBridgeHandler] - Received message {"cmd":"report","model":"ctrl_ln2.aq1","sid":"158d000239f928","short_id":10095,"data":"{\"channel_0\":\"off\"}"}
2018-05-06 20:46:08.201 [TRACE] [g.mihome.handler.XiaomiBridgeHandler] - Updated "last time seen" for device 158d000239f928
2018-05-06 20:46:08.207 [DEBUG] [home.handler.XiaomiDeviceBaseHandler] - Item got update: {"cmd":"report","model":"ctrl_ln2.aq1","sid":"158d000239f928","short_id":10095,"data":"{\"channel_0\":\"off\"}"}
2018-05-06 20:46:08.213 [TRACE] [.mihome.internal.socket.XiaomiSocket] - Data received and notified 1 listeners
2018-05-06 20:46:08.215 [TRACE] [.mihome.internal.socket.XiaomiSocket] - Thread Thread[Thread-34,5,main] waiting for data on port 9898
2018-05-06 20:46:10.959 [DEBUG] [.mihome.internal.socket.XiaomiSocket] - Received Datagram from 192.168.215.203:4321 on Port 9898
2018-05-06 20:46:10.960 [TRACE] [g.mihome.handler.XiaomiBridgeHandler] - Received message {"cmd":"report","model":"ctrl_ln2.aq1","sid":"158d000239f928","short_id":10095,"data":"{\"channel_1\":\"off\"}"}
2018-05-06 20:46:10.961 [TRACE] [g.mihome.handler.XiaomiBridgeHandler] - Updated "last time seen" for device 158d000239f928
2018-05-06 20:46:10.961 [DEBUG] [home.handler.XiaomiDeviceBaseHandler] - Item got update: {"cmd":"report","model":"ctrl_ln2.aq1","sid":"158d000239f928","short_id":10095,"data":"{\"channel_1\":\"off\"}"}
2018-05-06 20:46:10.965 [TRACE] [.mihome.internal.socket.XiaomiSocket] - Data received and notified 1 listeners
2018-05-06 20:46:10.966 [TRACE] [.mihome.internal.socket.XiaomiSocket] - Thread Thread[Thread-34,5,main] waiting for data on port 9898
2018-05-06 20:46:14.473 [DEBUG] [.mihome.internal.socket.XiaomiSocket] - Received Datagram from 192.168.215.140:4321 on Port 9898
2018-05-06 20:46:14.474 [TRACE] [.mihome.internal.socket.XiaomiSocket] - Data received and notified 1 listeners

switches work from site map and from paper, but the rules do not work, what do I do wrong?
Thank you!
PS openHAB 2.3.0 Build #1269

i install a double switch (zero line,neutral) the mihome app sees it and working ok but it is not shown at my openhab inbox…all my other switches are showing and working fine (non neutral) .Do i have to manually add it?how can i find the MiHome device ID ?

updated the binding and now the switch found and working allright

Hi there.

Does your ‘wireless communication’ menu screen look like this?

Generally in my experience, if the developer key isn’t correct, you are able to receive updates from sensors, but can’t actually send commands, so it seems to be the culprit. Also check for updates on your mi home binding.