Mi(Xiaomi) Smart home bindings?

(Kuba Wolanin) #465

It’s almost there :wink:

(Andras Miklos) #466

Wow, what a fast development :slight_smile: Great work!

(Variamus) #467

Hello, anyone can kindly help me please ? :frowning:

(Ward) #468

I’m using the beta jar already, and the water sensor is working. The only missing part is/was battery level.

(Ward) #469

Do you mean with cron in the when statement?

(Variamus) #470

No, just want to know how to phrase the “ACTION” to power on and off and also during a certain date/time

(Josep Xavier Sellart I Gine) #471

Sorry it was not for this post

Good afternoon, colleagues, I have the same problem. I think I have it as in the example, but it shows me the following error
2017-09-12 19:38:36.867 [INFO ] [el.core.internal.ModelRepositoryImpl] - Validation issues found in configuration model ‘xiaomi.things’, using it anyway:
Provide a thing type ID and a thing ID in this format:

Can someone show me where I have the error?
Randomly load the Gateway and the second to load this almost 4 minutes until it starts loading the items.

Thank you very much

Bridge mihome:bridge:34ce00XXXXXX "Gateway 1" [ serialNumber="34ce00XXXXXX", ipAddress="", port=9898, key="vre2l2riaeXXXXXX", pollingInterval=6000 ] {	

Thing mihome:gateway:34ce00XXXXXX "Xiaomi Mi Smart Home Gateway 1" [itemId="34ce00XXXXXX"]

//Sensor_ht "Xiaomi Temperature Sensor" "Xiaomi Gateway 1"
Thing mihome:sensor_ht:158d000182642b "TH 1" [itemId="158d000182642b"]
Thing mihome:sensor_ht:158d000182e53f "TH 2" [itemId="158d000182e53f"]
Thing mihome:sensor_ht:158d000182eb02 "TH 3" [itemId="158d000182eb02"]
Thing mihome:sensor_ht:158d000182647f "TH 4" [itemId="158d000182647f"]
Thing mihome:sensor_ht:158d0001216ec3 "TH 5" [itemId="158d0001216ec3"]
Thing mihome:sensor_ht:158d0001a2bfda "TH 6" [itemId="158d0001a2bfda"]

//Sensor_magnet "Xiaomi Door Sensor" "Xiaomi Gateway 1"
Thing mihome:sensor_magnet:158d0001837f39 "Contacto 1" [itemId="158d0001837f39"]
Thing mihome:sensor_magnet:158d00014deed6 "Contacto 2" [itemId="158d00014deed6"]
Thing mihome:sensor_magnet:158d000183802f "Contacto 3" [itemId="158d000183802f"]
Thing mihome:sensor_magnet:158d0001a5e199 "Contacto 4" [itemId="158d0001a5e199"]

//Sensor_motion "Xiaomi Motion Sensor" "Xiaomi Gateway 1"
Thing mihome:sensor_motion:158d00014dca76 "Presencia 1" [itemId="158d00014dca76"]
Thing mihome:sensor_motion:158d000154a94d "Presencia 2" [itemId="158d000154a94d"]
Thing mihome:sensor_motion:158d0001592a7a "Presencia 3" [itemId="158d0001592a7a"]
Thing mihome:sensor_motion:158d00015c8782 "Presencia 4" [itemId="158d00015c8782"]
Thing mihome:sensor_motion:158d000113c693 "Presencia 5" [itemId="158d000113c693"]
Thing mihome:sensor_motion:158d000113c9e4 "Presencia 6" [itemId="158d000113c9e4"]


Bridge mihome:bridge:286c07XXXXXX "Gateway 2" [ serialNumber="286c07XXXXXX", ipAddress="", port=9898, key="wgv6l8ijnuXXXXXX", pollingInterval=6000 ] {		
Thing mihome:gateway:286c07XXXXXX "Xiaomi Mi Smart Home Gateway 2" [itemId="286c07f09916"]

//Sensor_ht "Xiaomi Temperature Sensor" "Xiaomi Gateway 2"
Thing mihome:sensor_ht:158d0001216dff "TH 7" [itemId="158d0001216dff"]
Thing mihome:sensor_ht:158d0001a2a9ce "TH 8" [itemId="158d0001a2a9ce"]
Thing mihome:sensor_ht:158d0001216d17 "TH 9" [itemId="158d0001216d17"]
Thing mihome:sensor_ht:158d0001216ec9 "TH 10" [itemId="158d0001216ec9"]
Thing mihome:sensor_ht:158d0001217171 "TH 11" [itemId="158d0001217171"]
Thing mihome:sensor_ht:158d00012171c7 "TH 12" [itemId="158d00012171c7"]
Thing mihome:sensor_ht:158d0001216e32 "TH 13_1" [itemId="158d0001216e32"]
Thing mihome:sensor_ht:158d0001235534 "TH 13_2" [itemId="158d0001235534"]

//Sensor_magnet "Xiaomi Door Sensor" "Xiaomi Gateway 2"
Thing mihome:sensor_magnet:158d00016fd932 "Contacto 7_1" [itemId="158d00016fd932"]
Thing mihome:sensor_magnet:158d00018378a9 "Contacto 7_2" [itemId="158d00018378a9"]
Thing mihome:sensor_magnet:158d0001837958 "Contacto 7_3" [itemId="158d0001837958"]
Thing mihome:sensor_magnet:158d00015cd423 "Contacto 8_1" [itemId="158d00015cd423"]
Thing mihome:sensor_magnet:158d0001875fb0 "Contacto 8_2" [itemId="158d0001875fb0"]
Thing mihome:sensor_magnet:158d0001837981 "Contacto 10" [itemId="158d0001837981"]
Thing mihome:sensor_magnet:158d00016c75b4 "Contacto 10_2" [itemId="158d00016c75b4"]
Thing mihome:sensor_magnet:158d00018379e0 "Contacto 11" [itemId="158d00018379e0"]

//Sensor_motion "Xiaomi Motion Sensor" "Xiaomi Gateway 2"
Thing mihome:sensor_motion:158d000113c688 "Presencia 7" [itemId="158d000113c688"]
Thing mihome:sensor_motion:158d000113c7d1 "Presencia 8" [itemId="158d000113c7d1"]
Thing mihome:sensor_motion:158d000154865b "Presencia 9" [itemId="158d000154865b"]
//Thing mihome:sensor_motion:158d0001XXXXXX "Presencia 10" [itemId="158d0001XXXXXX"]
//Thing mihome:sensor_motion:158d0001XXXXXX "Presencia 11" [itemId="158d0001XXXXXX"]
//Thing mihome:sensor_motion:158d0001XXXXXX "Presencia 12" [itemId="158d0001XXXXXX"]


OpenHAB 2 and Xiaomi MiHome Temperature & Humidity Sensor
(Ugur) #472

has anyone newest mihome jar file for me?

(Kuba Wolanin) #473

Just download latest openHAB 2 SNAPSHOT and you’ll have the latest one.

(Ugur) #474

thank you, for your quick reply.

I have a very new Gateway V3. It will discovered from OH2 but i can’t send commands to the gateway. Will Gateway V3 supported?
Yes, i add the developer Key.

(Nicke) #475

Do anyone use the .things file?
Mine is very simple and looks like this:

Bridge mihome:bridge:34ce0088ce2f "Xiaomi Gateway" [ serialNumber="34ce0088ce2f", ipAddress="", port=9898, key="lyvoc1hhbpbxxxxx", pollingInterval=6000 ]
	Thing mihome:gateway:34ce0088ce2f "Xiaomi Mi Smart Home Gateway" [itemId="34ce0088ce2f"]
	Thing mihome:sensor_cube:158d00010aed80 "Xiaomi cube" [itemId="158d00010aed80"]

When I try it, it says in the logs:

2017-09-15 19:07:18.045 [ThingAddedEvent           ] - Thing 'mihome:bridge:34ce0088ce2f' has been added.
2017-09-15 19:07:18.063 [hingStatusInfoChangedEvent] - 'mihome:bridge:34ce0088ce2f' changed from UNINITIALIZED to INITIALIZING
2017-09-15 19:07:18.072 [ThingAddedEvent           ] - Thing 'mihome:gateway:34ce0088ce2f' has been added.
2017-09-15 19:07:18.073 [hingStatusInfoChangedEvent] - 'mihome:gateway:34ce0088ce2f' changed from UNINITIALIZED to UNINITIALIZED (BRIDGE_UNINITIALIZED)
2017-09-15 19:07:18.083 [ThingAddedEvent           ] - Thing 'mihome:sensor_cube:158d00010aed80' has been added.
2017-09-15 19:07:18.090 [hingStatusInfoChangedEvent] - 'mihome:sensor_cube:158d00010aed80' changed from UNINITIALIZED to UNINITIALIZED (BRIDGE_UNINITIALIZED)
2017-09-15 19:07:18.124 [ThingUpdatedEvent         ] - Thing 'mihome:bridge:34ce0088ce2f' has been updated.
2017-09-15 19:07:18.130 [ThingUpdatedEvent         ] - Thing 'mihome:gateway:34ce0088ce2f' has been updated.
2017-09-15 19:07:18.132 [ThingUpdatedEvent         ] - Thing 'mihome:sensor_cube:158d00010aed80' has been updated.
2017-09-15 19:07:19.074 [hingStatusInfoChangedEvent] - 'mihome:bridge:34ce0088ce2f' changed from INITIALIZING to ONLINE
2017-09-15 19:07:19.082 [hingStatusInfoChangedEvent] - 'mihome:gateway:34ce0088ce2f' changed from UNINITIALIZED (BRIDGE_UNINITIALIZED) to INITIALIZING
2017-09-15 19:07:19.083 [hingStatusInfoChangedEvent] - 'mihome:sensor_cube:158d00010aed80' changed from UNINITIALIZED (BRIDGE_UNINITIALIZED) to INITIALIZING
2017-09-15 19:07:19.089 [hingStatusInfoChangedEvent] - 'mihome:sensor_cube:158d00010aed80' changed from INITIALIZING to ONLINE
2017-09-15 19:07:19.089 [hingStatusInfoChangedEvent] - 'mihome:gateway:34ce0088ce2f' changed from INITIALIZING to ONLINE
2017-09-15 19:07:19.091 [ItemStateChangedEvent     ] - Cube_Battery changed from 76 to 81
2017-09-15 19:07:19.099 [ItemStateChangedEvent     ] - Xiaomi1GatewayColor changed from 0,0,100 to 0,0,0

Everything looks great, but nothing really happens when I press anything light on in the MI APP.

However if I try a switch in openhab it throws error:

2017-09-15 19:12:49.095 [ERROR] [ome.core.thing.internal.ThingManager] - Exception occurred while calling handler: java.lang.NullPointerException
java.util.concurrent.ExecutionException: java.lang.NullPointerException
	at org.eclipse.smarthome.core.common.SafeMethodCaller.executeDirectly(SafeMethodCaller.java:220)[98:org.eclipse.smarthome.core:]
	at org.eclipse.smarthome.core.common.SafeMethodCaller.callAsynchronous(SafeMethodCaller.java:189)[98:org.eclipse.smarthome.core:]
	at org.eclipse.smarthome.core.common.SafeMethodCaller.call(SafeMethodCaller.java:83)[98:org.eclipse.smarthome.core:]
	at org.eclipse.smarthome.core.common.SafeMethodCaller.call(SafeMethodCaller.java:67)[98:org.eclipse.smarthome.core:]
	at org.eclipse.smarthome.core.thing.internal.ThingManager.receiveCommand(ThingManager.java:374)[105:org.eclipse.smarthome.core.thing:]
	at org.eclipse.smarthome.core.items.events.AbstractItemEventSubscriber.receive(AbstractItemEventSubscriber.java:47)[98:org.eclipse.smarthome.core:]
	at org.eclipse.smarthome.core.internal.events.OSGiEventManager$1.call(OSGiEventManager.java:193)[98:org.eclipse.smarthome.core:]
	at org.eclipse.smarthome.core.internal.events.OSGiEventManager$1.call(OSGiEventManager.java:1)[98:org.eclipse.smarthome.core:]
	at org.eclipse.smarthome.core.common.SafeMethodCaller$CallableWrapper.call(SafeMethodCaller.java:181)[98:org.eclipse.smarthome.core:]
	at java.util.concurrent.FutureTask.run(Unknown Source)[:1.8.0_144]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)[:1.8.0_144]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)[:1.8.0_144]
	at java.lang.Thread.run(Unknown Source)[:1.8.0_144]
Caused by: java.lang.NullPointerException
	at org.openhab.binding.mihome.internal.EncryptionHelper.encrypt(EncryptionHelper.java:69)[242:org.openhab.binding.mihome:]
	at org.openhab.binding.mihome.internal.EncryptionHelper.encrypt(EncryptionHelper.java:42)[242:org.openhab.binding.mihome:]
	at org.openhab.binding.mihome.handler.XiaomiBridgeHandler.getEncryptedKey(XiaomiBridgeHandler.java:292)[242:org.openhab.binding.mihome:]
	at org.openhab.binding.mihome.handler.XiaomiBridgeHandler.createDataJsonString(XiaomiBridgeHandler.java:278)[242:org.openhab.binding.mihome:]
	at org.openhab.binding.mihome.handler.XiaomiBridgeHandler.writeToBridge(XiaomiBridgeHandler.java:274)[242:org.openhab.binding.mihome:]
	at org.openhab.binding.mihome.handler.XiaomiActorGatewayHandler.writeBridgeLightColor(XiaomiActorGatewayHandler.java:183)[242:org.openhab.binding.mihome:]
	at org.openhab.binding.mihome.handler.XiaomiActorGatewayHandler.writeBridgeLightColor(XiaomiActorGatewayHandler.java:179)[242:org.openhab.binding.mihome:]
	at org.openhab.binding.mihome.handler.XiaomiActorGatewayHandler.execute(XiaomiActorGatewayHandler.java:68)[242:org.openhab.binding.mihome:]
	at org.openhab.binding.mihome.handler.XiaomiDeviceBaseHandler.handleCommand(XiaomiDeviceBaseHandler.java:103)[242:org.openhab.binding.mihome:]
	at org.eclipse.smarthome.core.thing.internal.ThingManager$3.call(ThingManager.java:377)[105:org.eclipse.smarthome.core.thing:]
	at org.eclipse.smarthome.core.thing.internal.ThingManager$3.call(ThingManager.java:1)[105:org.eclipse.smarthome.core.thing:]
	at org.eclipse.smarthome.core.common.SafeMethodCaller.executeDirectly(SafeMethodCaller.java:218)[98:org.eclipse.smarthome.core:]
	... 12 more

If I autodiscover the gateway, it is found and works perfectly!
But I want to have it all in items, things and sitemaps files.
Can anyone help me troubleshoot this?

(Nicke) #476

Funny thing!

I use VPN on my computer.
If I turn off the VPN and then input my things file into openhab it works.
I can turn on my VPN after this and it will continue to work.
If I restart openhab with VPN ON, it will not work.
If I start openhab without VPN and then turn it ON, it will work.


(Josep Xavier Sellart I Gine) #477

The Bridge does not appear to initialize properly.
Does the Bridge have a fixed IP? , it is possible for another device to try to use the same IP or port “9898”.
Sorry for my simple answer, but I’m also starting with OH2.
If you use the SmartHome-Designer editor, you have to look at the things that appear in red.
In my case “mihome: sensor_ht: 158d000182642b” is marked in red, but according to the Binding examples, I think they are well written

(Nicke) #478

If you look closer, they go from uninitialized to online.
In the next post I describe that everything works great if I turn of my VPN connection.
So in fact, my .things file is correct :slight_smile:
Not a big problem, I just have to turn of my VPN everytime I reboot or restart openhab.

(TootToot168) #479

Currently there are no way to get a “low” battery status for all xiaomi devices from this binding right?

(Dimalo) #480

If I understand your problem right, you don’t know how to send the command to the plug to switch the power to ON, right?
If you have defined the power channel as an item “Plug_Switch” you type Plug_Switch.sendCommand(ON) to switch it on in rules.

have you tried to just use PaperUI and the discovery function? much more convenient than text config…
Otherwise please try deleting the pollingInterval value - I think it’s not included anymore…

the communication between gateway and binding works over multicast. It’s just a guess, but I think as soon as the VPN is active, the multicast route changes?! It might be easier to automate the initialization to ensure that OH comes first and then VPN

as soon as the battery level drops below 20% the channel is triggered…

(Josep Xavier Sellart I Gine) #481

Thanks Dimalo, yes, with Paper UI, they are discovered correctly, but I thought that if it can be done in text mode, it was much better.
What is your opinion ?

(Gonzalo Echevarria) #482

Use the v2.2.0 snapshot from https://github.com/openhab/openhab2-addons/files/1117531/org.openhab.binding.mihome-2.2.0-SNAPSHOT.jar.zip

(Hallo Ween) #484

Can someone help me with the illumination / ambient light sensor of the xiaomi gateway? I only get the value 1292 on daytime - is this the highest value? This night it went down to about 300. No change the whole night. And no change the whole day. Only 1292 and 300 and a very short time where the value is rising or falling.

Is this sensor working at your setup? Is this number in the unit “lux” ?

Very strange. Is this not very accurate? Where is the sensor?

(Ray) #485

I’m getting the value 881 right now, have no idea what to do whit this channel, response seems erratic…