Mi(Xiaomi) Smart home bindings?

Have looked through and can’t see an answer to my issue.
OpenHAB : openHAB 2.1.0 - release build -
MiHome : Firmware 1.4.1_150.0143
Gateway : V2
Binding : org.openhab.binding.mihome-2.2.0-SNAPSHOT.jar

I have followed the very well prepared instructions Xiaomi Mi Smart Home Binding

It found my Gateway and Bridge with in seconds and I entered (is correct!:slight_smile: ) developer key and created the items, sitemap map etc.

Issue I’m having is my items don’t read the current status of the gateway and aren’t changing when I perform an action from openHAB or the Mi Home APP. Below is the events log and openHAB log which is generating an error.

Events log

2017-11-22 19:26:03.737 [ItemCommandEvent          ] - Item 'Gateway_LightSwitch' received command ON
2017-11-22 19:26:03.742 [ItemStateChangedEvent     ] - Gateway_LightSwitch changed from OFF to ON
2017-11-22 19:26:05.179 [ItemCommandEvent          ] - Item 'Gateway_LightSwitch' received command OFF
2017-11-22 19:26:05.181 [ItemStateChangedEvent     ] - Gateway_LightSwitch changed from ON to OFF

Openhab Log

Caused by: java.lang.NullPointerException
	at org.openhab.binding.mihome.internal.EncryptionHelper.encrypt(EncryptionHelper.java:69)[198:org.openhab.binding.mihome:2.2.0.201707020013]
	at org.openhab.binding.mihome.internal.EncryptionHelper.encrypt(EncryptionHelper.java:42)[198:org.openhab.binding.mihome:2.2.0.201707020013]
	at org.openhab.binding.mihome.handler.XiaomiBridgeHandler.getEncryptedKey(XiaomiBridgeHandler.java:290)[198:org.openhab.binding.mihome:2.2.0.201707020013]
	at org.openhab.binding.mihome.handler.XiaomiBridgeHandler.createDataJsonString(XiaomiBridgeHandler.java:276)[198:org.openhab.binding.mihome:2.2.0.201707020013]
	at org.openhab.binding.mihome.handler.XiaomiBridgeHandler.writeToBridge(XiaomiBridgeHandler.java:272)[198:org.openhab.binding.mihome:2.2.0.201707020013]
	at org.openhab.binding.mihome.handler.XiaomiActorGatewayHandler.writeBridgeLightColor(XiaomiActorGatewayHandler.java:183)[198:org.openhab.binding.mihome:2.2.0.201707020013]
	at org.openhab.binding.mihome.handler.XiaomiActorGatewayHandler.writeBridgeLightColor(XiaomiActorGatewayHandler.java:179)[198:org.openhab.binding.mihome:2.2.0.201707020013]
	at org.openhab.binding.mihome.handler.XiaomiActorGatewayHandler.execute(XiaomiActorGatewayHandler.java:68)[198:org.openhab.binding.mihome:2.2.0.201707020013]
	at org.openhab.binding.mihome.handler.XiaomiDeviceBaseHandler.handleCommand(XiaomiDeviceBaseHandler.java:101)[198:org.openhab.binding.mihome:2.2.0.201707020013]
	at org.eclipse.smarthome.core.thing.internal.ThingManager$4.call(ThingManager.java:377)[105:org.eclipse.smarthome.core.thing:0.9.0.b5]
	at org.eclipse.smarthome.core.thing.internal.ThingManager$4.call(ThingManager.java:1)[105:org.eclipse.smarthome.core.thing:0.9.0.b5]
	at org.eclipse.smarthome.core.common.SafeMethodCaller.executeDirectly(SafeMethodCaller.java:218)[98:org.eclipse.smarthome.core:0.9.0.b5]
	... 12 more

Looking if anyone has an idea to whats wrong with my configuration.

hey @Murpher ,
a quick search on EncryptionHelper gave me this guy who was using a VPN - and this guy, who had to configure his firewall.
The error seems to appear often with network related solutions. Please make sure you try out different ways to ensure the communication is working :slight_smile:

Hi @dimalo,

Thanks for your reply was hoping my fix was in them. Thanks for the links unfortunately I’m running on a raspberry pi and I have no vpn or firewall.

Must me some communication issue between if anyone has any other ideas I welcome them all it has to be something simple.

Why are some things highlighted in bold and others not?

Hey Guys,

Did anyone get this working?

rule "Xiaomi Switch"
when
    Channel "mihome:sensor_switch:<ID>:button" triggered
then
    var actionName = receivedEvent.getEvent()
    switch(actionName) {
        case "SHORT_PRESSED": {
            Garden_Light.sendCommand(ON)
        }
        case "DOUBLE_PRESSED": {
            Garden_Light.sendCommand(OFF)
        }
        case "LONG_PRESSED": {
            <ACTION>
        }
        case "LONG_RELEASED": {
            <ACTION>
        }
    }
end

I’m runnning openHAB 2.2.0 Build #1068 but I still don’t see my light gets turned ON.
I do see the events though, so openHAB sees the buttons pressed…

I tried reading through this long thread, so I might have missed something! Is there any solution to this?

There as been a change, so the code doesn’t work anymore.

Try this instead:

rule " "
when
    Channel "mihome:sensor_switch:<ID>:button" triggered SHORT_PRESSED
then
  <code>    				}
end


rule " "
when
    Channel "mihome:sensor_switch:<ID>:button" triggered DOUBLE_PRESSED
then
  <code>    				}
end


rule " "
when
    Channel "mihome:sensor_switch:<ID>:button" triggered LONG_PRESSED
then
  <code>    				}
end

Hmm, tried it, but nothing happens:

rule "Xiaomi Switch - Doorbell "
when
    Channel "mihome:sensor_switch:158d00014d0cc0:button" triggered SHORT_PRESSED
then
    gGarden_Back_Beds.sendCommand(ON) }
end

Also, now my other Xioami rules doesn’t work - when above is in my rules file.

Sorry - my mistake.

Got it working with;

rule "Xiaomi Switch - Doorbell "
when
    Channel "mihome:sensor_switch:158d00014d0cc0:button" triggered SHORT_PRESSED
then
    if (gGarden_Back_Beds.state == OFF) {
        gGarden_Back_Beds.sendCommand(ON)
    } else {
        gGarden_Back_Beds.sendCommand(OFF)
    }
end

Thanks…

The first 3 Things are missing some sort of label. I thought is was something in the binding’s code (https://github.com/openhab/openhab2-addons/tree/master/addons/binding/org.openhab.binding.mihome/ESH-INF/thing), but I see a correct label for all things. I see the same with my water leak sensors.

What has been changed? this code is still working in my setup…

To be honest, i assume there must have been a change, because after an update the old version did not work anymor for me.

I just bought Xiaomi Mijia Aqara Smart IP Camera
It is camera with getaway functionality. Do you think it will work with the binding? If not who should I ask to update the binding?

This should work with the gateway, but is not yet supported by the binding (https://github.com/openhab/openhab2-addons/tree/master/addons/binding/org.openhab.binding.mihome)

Maybe you can ask it in this topic: Support for more Mi-Home Aqara items - #50 by antricki

Hi,

Does anyone having problem getting to developer mode in the new mi home app version 5? I press the version in the about page and the only thing I get is a bunch of information about my gateway (ip, wifi password, devices, …).

I’m using gateway 3 v2.46

Just tried it again, is still working. Don’t you see the ‘local area network communication protocol’ item in the About menu? This should appear after enabling developer mode.

My gateway has firmware 1.4.1_150.0143 (version 2.46) (I don’t think a gateway v3 exists)
MiHome v5.0.10

Maybe the one I have is not supported for such developer mode.
In the readme page for the mi home binding there is this step that the gateway 3 is mentioned:
•Add Gateway 2 or 3 to your WiFi Network

It is that one:
https://pt.aliexpress.com/item/2017-Xiaomi-Smart-Home-Gateway-3-Aqara-Smart-Light-Control-ZiGBee-Wifi-Wireless-Key-and-Wall/32790262169.html
However In the xiaomi mi page they mention only as a air condition companion.
https://xiaomi-mi.com/sockets-and-sensors/xiaomi-aqara-air-conditioning-companion-temperature-humidity-sensor/

Has anyone succesfully used the “gateway 3”?

this gateway is supported. there are different versions of it and it is the original gateway v3 - there is an older v2 of this which looks the same. these are montioned in the readme…

Did you find correct way?

Yep, installed v2.2. That helped

1 Like

Hello friend, what example do you have of what you did with the xiaomi temperature sensors? What tutorial do you follow to achieve it with Grafana?

Hello friend, a query

This example that you share can be used to capture the information from the xiaomi temperature sensors, how would you connect it to my device?