Mi(Xiaomi) Smart home bindings?

Hi

Does anyone know the xiaomi IR Blaster device (all-in-one media control center http://files.xiaomi-mi.com/files/All_in_one/All_in_one-EN.pdf)?
It would be great to be able to integrate openHAB and be able to handle air conditioning, tv, portraits, audio equipment, etc.
Do you know if there is an API to be able to integrate it?

The only “open” devices I know of are Yeelights and MiHome ZigBee devices…
There is some possibility to include every wifi enabled device but complex. have a look at this previous post

strange. tried removing all things and readding them again?

It worked again after some time :confused:

I just update home bindings with the last version, but since then the temperature and humidity values stanys constant (not updated anymore). I tried to remove things in Paper UI and restart openHab but I still have this issue.

The only error I have in the logs is:

“[ERROR] [nternal.DiscoveryServiceRegistryImpl] - Cannot trigger scan for thing types ‘[mihome:bridge]’ on ‘XiaomiBridgeDiscoveryService’!”

Any idea about this problem?

Thanks.

1 Like

We had this issue over at github in the PR discussion
The user there managed to get rid of it by reinstalling the binding.
But still it was a bug in the code.
I have made a bugfix for that and opened a pull request on @pboos repository.

NEWS

The OH2 binding will be available on the new IOT Marketplace!
Follow the instruction provided in the link above to get the IOT Marketplace binding.

At the moment the jar in the marketplace is old, it will get updated as soon as @pboos merges something in or closes and reopens his PR on the openHAB repo.

For now please be patient, you can check if its up to date on comparing the date of the build to this post :smile:

1 Like

Hi,
Just installed last JAR available, 2.1.0 SNAPSHOT.
I can see the gateway and all sensors in InBox and I can add things.
I added a Temperature/Humidity Sensor and a Windows Contact, but opening detail I got NaN for Umidity and Temp and no status for window:

Perhaps I miss something in Item config:

Contact MANSARDA_FINESTRA_BAGNO "Finestra Bagno [%s]" <flash> { channel="mihome:sensor_magnet:158d000183724f:isOpen" }

Number CUCINA_TEMP "Temperatura Cucina [%.1f °C]" <temperature> 	{ channel = "mihome:sensor_ht:158d000187234a:temperature" } 
Number CUCINA_HUMI "Umidità Cucina [%d %%]" <water>		 			{ channel = "mihome:sensor_ht:158d000187234a:humidity" }

And I do not have Battery Voltage. I have latest firmware version on the gateway.

Someone can help me?

Thanks

Hi,
I installed latest OH2 snapshot and installed latest Bindings from IOT Market.
I have this isseues:

  1. Temperature and Humidity are NaN, and contact have no value as for screenshoot
  2. Opening Things I cannot get voltage channel

but in the log I see value was read:
Item got update: {“cmd”:“read_ack”,“model”:“sensor_ht”,“sid”:“158d000187234a”,“short_id”:50889,“data”:"{“voltage”:3085,“temperature”:“2097”,“humidity”:“3800”}"}

  1. For Magnet sensor same thing. I got only 1 channel and value isOpen was not retrieved:

    but in the log I can see values arriving:
    Item got update: {“cmd”:“read_ack”,“model”:“magnet”,“sid”:“158d000183724f”,“short_id”:60271,“data”:"{“voltage”:3095,“status”:“close”}"}

I just removed and added binding and things 10 times, but result is always the same.

Marco

Hi @marcolino7, please read carefully and don’t repeat yourself. As I already wrote, please be patient and wait for the latest build in IOT marketplace. it will be updated the next few days…

Hello!
Try it this way:

Contact MANSARDA_FINESTRA_BAGNO "Finestra Bagno" <flash>  { channel="mihome:sensor_magnet:158d000183724f:isOpen" }

If you finish [%s] it works in BasicUI
But does not work in the PaperUI to work there and there,
Then in the item without [%s]
But in the sitemap file:

Text item=MANSARDA_FINESTRA_BAGNO label="Finestra Bagno [%s]"

Correct me if I’m wrong, but I only work in this version.

Number WindowSwitch_AlarmTimer <clock> { channel="mihome:sensor_magnet:158d00013e5f82:isOpenAlarmTimer" }
Number MotionSensor_MotionTimer <clock> { channel="mihome:sensor_motion:158d000128b345:motionOffTimer" }

What here should be?
I could not get the values to change here …

Switch Gateway_LightSwitch <light> { channel="mihome:gateway:286c078921f5:brightness" }

If you press this button, the light goes out, no more how to turn it off, only through the application, I’m doing something wrong?

@Olymp
with the Timer values you can change the time, after which the motion sensor switches off again. default (if no value is set) is 120sec for motion. with window sensors, an alarm event is triggered, when the sensor report “open” but not “closed” in a certain time, default is 300sec.
There is a desciption text in paperUI for these channels.
But we should make it more clear in the readme, thanks for your feedback!

The thing with the switch is, it comes together with a dimmer on the same channel, see next line in the readme example. function is: set some dimmer value, the switch can then switch off and on and will retain the brightness value you set before. If you don’t have anything set, it should switch to full brightness. it seems that doesn’t happen. will have to fix that…

Hi Everybody,

First of all, thank you for this binding.

Anybody try this, when have 2 vlan?
I have the server in 192.18.0.0/24 [A vlan] but the Chines stuff(like this) in 192.168.10.0/24 [B vlan]
When the server and the gateway in the same vlan,work as expected. But when I move it to secure vlan, its stop working.
The Openhab say its “Online”, but when I change for example the lamp, I get this error:

20:47:17.584 [INFO ] [smarthome.event.ItemCommandEvent ] - Item ‘Gateway_Brightness’ received command 53
20:47:17.587 [INFO ] [marthome.event.ItemStateChangedEvent] - Gateway_Brightness changed from 16 to 53
java.lang.NullPointerException
at org.openhab.binding.mihome.internal.EncryptionHelper.encrypt(EncryptionHelper.java:35)
at org.openhab.binding.mihome.internal.EncryptionHelper.encrypt(EncryptionHelper.java:25)
at org.openhab.binding.mihome.handler.XiaomiBridgeHandler.getEncryptedKey(XiaomiBridgeHandler.java:282)
at org.openhab.binding.mihome.handler.XiaomiBridgeHandler.createDataJsonString(XiaomiBridgeHandler.java:267)
at org.openhab.binding.mihome.handler.XiaomiBridgeHandler.writeToBridge(XiaomiBridgeHandler.java:263)
at org.openhab.binding.mihome.handler.XiaomiActorGatewayHandler.writeBridgeLightColor(XiaomiActorGatewayHandler.java:191)
at org.openhab.binding.mihome.handler.XiaomiActorGatewayHandler.writeBridgeLightColor(XiaomiActorGatewayHandler.java:187)
at org.openhab.binding.mihome.handler.XiaomiActorGatewayHandler.execute(XiaomiActorGatewayHandler.java:53)
at org.openhab.binding.mihome.handler.XiaomiDeviceBaseHandler.handleCommand(XiaomiDeviceBaseHandler.java:100)
at org.eclipse.smarthome.core.thing.internal.ThingManager$4.call(ThingManager.java:374)
at org.eclipse.smarthome.core.thing.internal.ThingManager$4.call(ThingManager.java:1)
at org.eclipse.smarthome.core.common.SafeMethodCaller.executeDirectly(SafeMethodCaller.java:218)
at org.eclipse.smarthome.core.common.SafeMethodCaller.callAsynchronous(SafeMethodCaller.java:189)
at org.eclipse.smarthome.core.common.SafeMethodCaller.call(SafeMethodCaller.java:83)
at org.eclipse.smarthome.core.common.SafeMethodCaller.call(SafeMethodCaller.java:67)
at org.eclipse.smarthome.core.thing.internal.ThingManager.receiveCommand(ThingManager.java:371)
at org.eclipse.smarthome.core.items.events.AbstractItemEventSubscriber.receive(AbstractItemEventSubscriber.java:46)
at org.eclipse.smarthome.core.internal.events.OSGiEventManager$1.call(OSGiEventManager.java:192)
at org.eclipse.smarthome.core.internal.events.OSGiEventManager$1.call(OSGiEventManager.java:1)
at org.eclipse.smarthome.core.common.SafeMethodCaller$CallableWrapper.call(SafeMethodCaller.java:181)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

Any idea?
THX

BR,
O.

Your welcome :slight_smile:

Seems like the binding is either missing the developer key or the gateway token.

please check, if your server in A VLAN receives heartbeat messages from the gateway.
enable DEBUG logging for the binding in the console of karaf and check if you get messages which look like this:

2017-04-22 21:53:45.078 [DEBUG] [me.handler.XiaomiActorGatewayHandler] - Item got update: {"cmd":"heartbeat","model":"gateway","sid":"xxxx","short_id":"0","token":"70TmuQW5QTln1BX4","data":"{\"ip\":\"192.168.0.xxx\"}"}

to be able to write values to the gateway you need to have the token (which is in this heartbeat message and gets updated every 10sec), and the developer key you get from the xiaomi app as described in the readme for the binding.

Are you receiving value updates from sensors etc. when in different VLANs? Then at least multicast traffic should be routed.
Multicast address is 224.0.0.50, port is 9898

Thank your quick answer!
From Service vlan, cant create any connection to server vlan or to internet. Everything disabled. :confused:
Enough the multicast ip?

at least multicast traffic and the port, I’d say…

1 Like

Still I have no luck. On mikrotik not so easy to setup this :slight_smile:
now I have a little bit different error log, but I think, this is the same issue…

09:35:06.805 [INFO ] [smarthome.event.ItemCommandEvent ] - Item ‘Gateway_LightSwitch’ received command ON
09:35:06.806 [DEBUG] [me.handler.XiaomiActorGatewayHandler] - Device 286c07888601 on channel mihome:gateway:286c07888601:brightness received command ON
java.lang.NullPointerException
at org.openhab.binding.mihome.internal.EncryptionHelper.encrypt(EncryptionHelper.java:35)
at org.openhab.binding.mihome.internal.EncryptionHelper.encrypt(EncryptionHelper.java:25)
at org.openhab.binding.mihome.handler.XiaomiBridgeHandler.getEncryptedKey(XiaomiBridgeHandler.java:282)
at org.openhab.binding.mihome.handler.XiaomiBridgeHandler.createDataJsonString(XiaomiBridgeHandler.java:267)09:35:06.808 [INFO ] [marthome.event.ItemStateChangedEvent] - Gateway_LightSw
itch changed from OFF to ON

    at org.openhab.binding.mihome.handler.XiaomiBridgeHandler.writeToBridge(XiaomiBridgeHandler.java:263)
    at org.openhab.binding.mihome.handler.XiaomiActorGatewayHandler.writeBridgeLightColor(XiaomiActorGatewayHandler.java:191)
    at org.openhab.binding.mihome.handler.XiaomiActorGatewayHandler.writeBridgeLightColor(XiaomiActorGatewayHandler.java:187)
    at org.openhab.binding.mihome.handler.XiaomiActorGatewayHandler.execute(XiaomiActorGatewayHandler.java:75)
    at org.openhab.binding.mihome.handler.XiaomiDeviceBaseHandler.handleCommand(XiaomiDeviceBaseHandler.java:100)
    at org.eclipse.smarthome.core.thing.internal.ThingManager$4.call(ThingManager.java:374)
    at org.eclipse.smarthome.core.thing.internal.ThingManager$4.call(ThingManager.java:1)
    at org.eclipse.smarthome.core.common.SafeMethodCaller.executeDirectly(SafeMethodCaller.java:218)
    at org.eclipse.smarthome.core.common.SafeMethodCaller.callAsynchronous(SafeMethodCaller.java:189)
    at org.eclipse.smarthome.core.common.SafeMethodCaller.call(SafeMethodCaller.java:83)
    at org.eclipse.smarthome.core.common.SafeMethodCaller.call(SafeMethodCaller.java:67)
    at org.eclipse.smarthome.core.thing.internal.ThingManager.receiveCommand(ThingManager.java:371)
    at org.eclipse.smarthome.core.items.events.AbstractItemEventSubscriber.receive(AbstractItemEventSubscriber.java:46)
    at org.eclipse.smarthome.core.internal.events.OSGiEventManager$1.call(OSGiEventManager.java:192)
    at org.eclipse.smarthome.core.internal.events.OSGiEventManager$1.call(OSGiEventManager.java:1)
    at org.eclipse.smarthome.core.common.SafeMethodCaller$CallableWrapper.call(SafeMethodCaller.java:181)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

09:35:06.812 [DEBUG] [g.mihome.handler.XiaomiBridgeHandler] - Send to bridge: {“cmd”: “write”,“model”: “gateway”,“sid”: “286c07888601”,“short_id”: “0”,“data”: “{“rgb”: 603979776, “key”: “”
}”}
09:35:06.813 [DEBUG] [.mihome.internal.socket.XiaomiSocket] - Sending message: {“cmd”: “write”,“model”: “gateway”,“sid”: “286c07888601”,“short_id”: “0”,“data”: “{“rgb”: 603979776, “key”: “
”}”} to /10.6.2.47
09:35:06.853 [DEBUG] [g.mihome.handler.XiaomiBridgeHandler] - Received message {“cmd”:“write_ack”,“sid”:“286c07888601”,“data”:"{“error”:“Invalid key len”}"}
09:35:06.853 [DEBUG] [g.mihome.handler.XiaomiBridgeHandler] - Updated “last time seen” for device 286c07888601
09:35:06.853 [DEBUG] [g.mihome.handler.XiaomiBridgeHandler] - Device 286c07888601 honored write request
09:35:06.854 [DEBUG] [me.handler.XiaomiActorGatewayHandler] - Item got update: {“cmd”:“write_ack”,“sid”:“286c07888601”,“data”:"{“error”:“Invalid key len”}"}
09:35:06.854 [DEBUG] [.mihome.internal.socket.XiaomiSocket] - Data received and notified 1 listeners
09:35:06.854 [DEBUG] [.mihome.internal.socket.XiaomiSocket] - Thread waiting for data on port 9898

BR,
O.

seems that you got unicast traffic working as you receive answers to your requests.
just to be sure: you entered the developer key into the thing config of the bridge right?

are you receiving any reports or heartbeats?

Yes of curse, until it in the same vlan, its working

Regarding the heartbeats, you mean this?:

BR,
O.

Is it a problem, If at the first time it was in the same wlan, so the autodiscovery find it. Than I move it to other vlan, and simple edit the ip here:


BR,
O.