Mi(Xiaomi) Smart home bindings?

(Thomas Binder) #750

based on my above config, I do have the possibility to trigger some action - though I don’t do something real (other then the test) as of now, but the button actions do come up immediately.

rule "Xiaomi Switch"
	Channel "mihome:sensor_switch:34cexxxxx:158dxxxxxxx:button" triggered
	var actionName = receivedEvent.getEvent()
	switch(actionName) {
	case "SHORT_PRESSED": {
			logInfo("MiHome Button", "Kurzer Druck")
		case "DOUBLE_PRESSED": {
			logInfo("MiHome Button", "Doppelter Druck")
		case "LONG_PRESSED": {
			logInfo("MiHome Button", "Langer Druck")
		case "LONG_RELEASED": {
			logInfo("MiHome Button", "Langer Druck verlassen")

(Michael Kohl) #751

@sunseaandpalms I tried today - and indeed it works :smile:
It is a bit of a mess to get the token to connect, but hey - IT WORKS.
Reason enough to buy a second one…

(sunseaandpalms) #752

Sounds awesome. I’m going to order one and test.

(sunseaandpalms) #753

Wow, Openhab community is amazing) Thanks for testing. Going to order mine ASAP)

(sunseaandpalms) #754

Got my lamp today. Loaded the jar from the provided link, but I don’t see the lamp in list. I have (Inbox / Xiaomi Mi IO Binding / Choose Thing):

  • Xiaomi Mi IO Basic device
  • Xiaomi Mi IO device
  • Xiaomi Robot Vacuum
  • Xiaomi Unsupported Mi IO device

Which one did you choose during setup?

(Michael Kohl) #755

You have to manually create a basic device, and set ip and the token.

Afterwards if finds the correct type of device. It is all (especially the insane token provision procedures) described here:

(marcel) #756

These all come from the miio binding. The binding uses 2 different mechanisms to discover devices on the network. Depending on the sequence of being found, that results in duplicated entries for a device.
I will add the device ID to the name in the discovery screen to easier identify these duplicates.
In the end it does not really matter which one you choose. Only in very specific cases (e.g.you want to overwrite the devices model you are better off using the basic device instead of the generic device)

(sunseaandpalms) #757

It wasn’t auto-discovered, albeit I just added it manually and can confirm everything is working fine: light on/off, ambient on/off and Eyecare mode. Illumination stays on zero as for now, so I’ll continue to keep an eye on it. Thank you all for your efforts!

(Artem) #758

Please help me figure it out. Control of the gateway is not working from the OH. Also I can not get data about the battery charge of the sensors.
I checked the progress of udp packets, everything is in order. OH 2.2 and binding-mihome - 2.2.0
Here is the log:

2018-04-04 16:47:46.886 [DEBUG] [home.handler.XiaomiDeviceBaseHandler] - Device 7811dcb3**** on channel mihome:gateway:7811dcb3****:brightness received command OFF
2018-04-04 16:47:46.890 [DEBUG] [me.handler.XiaomiActorGatewayHandler] - Update OFF for channel mihome:gateway:7811dcb3****:brightness received
2018-04-04 16:47:46.889 [DEBUG] [g.mihome.handler.XiaomiBridgeHandler] - Send to bridge mihome:bridge:7811dcb3****: {“cmd”: “write”, “model”: “gateway”, “sid”: “7811dcb3****”, “short_id”: “0”, “data”: “{“rgb”: 16777215, “key”: “B0B99C81F52BCFFA3D6C6B**********”}”}
2018-04-04 16:47:46.900 [DEBUG] [.mihome.internal.socket.XiaomiSocket] - Received Datagram from 192.168..:9898 on Port 9898
2018-04-04 16:47:46.901 [DEBUG] [g.mihome.handler.XiaomiBridgeHandler] - Device 7811dcb3**** honored write request
2018-04-04 16:47:46.901 [DEBUG] [home.handler.XiaomiDeviceBaseHandler] - Item got update: {“cmd”:“write_ack”,“sid”:“7811dcb3****”,“data”:"{“error”:“No device”}"}
2018-04-04 16:47:46.902 [DEBUG] [home.handler.XiaomiDeviceBaseHandler] - Item got update: {“cmd”:“write_ack”,“sid”:“7811dcb3****”,“data”:"{“error”:“No device”}"}
2018-04-04 16:47:50.061 [DEBUG] [.mihome.internal.socket.XiaomiSocket] - Received Datagram from 192.168..:4321 on Port 9898

Any ideas?

(Tejo) #759

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.

(Thomas Binder) #760

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, …) ?

(Tejo) #761

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.

(Thomas Binder) #762

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…

(Tejo) #763

@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 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 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 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\":\"\"}"}

2018-04-12 17:07:36.138 [DEBUG] [.mihome.internal.socket.XiaomiSocket] - Received Datagram from 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\":\"\"}"}

(Thomas Binder) #764

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

(Sergey M) #765

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?

(Dimalo) #766

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…

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.

(Constantinos Contis) #767

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?

(Sergey M) #768

Thank you, I will try.

(Sergey M) #769

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