Mi(Xiaomi) Smart home bindings?

The motion sensors actually send CLOSED but the binding does have an internal timer, which is started when it receives the OPEN. So no need to implement a timer by yourself… :smile:

1 Like

@dimalo

But will the MotionTimer be able to get a fixed value, instead of the default one? Right now you the Motion Sensor will switch back to “OFF” after 1 minute or so (default I guess) What if I would like a certain Motion Sensor to be “ON” for 10 minutes?

I guess when the Aqara Motion Detecter says its “ON” then it just sends the command, its not keeping track of any movements or LUX changes until it changes its state back to “OFF”? So it shouldn’t use extra Battery when kept alive.

sure, have a look in the readme
the Number MotionSensor_MotionTimer <clock> { channel="mihome:sensor_motion:<ID>:motionOffTimer" } is what you are looking for.
change the item value to whatever you want the timer to be. default is 120sec.

only caveat is, that after a restart the item has to be set again (even if it’s persisted), for example by a rule on System started - otherwise it’s back to default again.

having the timer as an item, you can dynamically set it with rules! for example you want the timer to be only a few minutes at night, but for example 10min during the day…

after it has triggered it goes to sleep for one minute and is then able to trigger again on movement. about LUX changes I am not sure, but I guess these are sent not depending on movement but periodically, every 30min for example.

so having the timer set to 10sec will “disable” it for 50sec.

Hi there,

complete NOOB for OpenHAB here - but with looong Java background, so not afraid :o).

I have a few HA functions running on a Maxim TINI Java board, controlling shutters & lights. TINI is something like a “RaspberryPi for Java”. Even the internet has almost forgotten about it, I think its about 15 years old. Anyway its really asking for retirement.

I will install OH on my QNAP NAS to replace it.
For window sesonrs, smoke detecors and a couple of other things the Xiaomi Aqara components seem to fit the bill for price, quality, reliability, and WAF (Wife’s Acceptance Factor).

I have a few questions that I can’t find definite answers for. Some are openHAB, some are more Xiaomi / Zigbee related.

  1. I understand that currently OH binding uses the gateway’s dev API for talking to the Xiaomi zigbee devices. Is a more direct integration (based on a Zigbee dongle) underway?
  2. My home has brick walls and concrete floors. What is the range of the sensors to the gateway in similar environments?
  3. I read on another HA forum that the Xiaomi socket can act as a repeater for the sensors. Does that require some support from OH or is this a Xiaomi internal thing?
  4. Unfortunately there is no EU socket available. Is there any other Xiaomi devices or dedicated zigbee repeaters that extend Xiaomi’s zigbee range?
  5. what is the maximum number of devices that can be paired with a v2 Gateway?
  6. Are multiple Xiaomi Gateways supported by OH?
  7. Can the smoke sensor’s alarm be activated / deactivated from OH?

Any input is greatly appreciated!
Cheers

Hi shabbab,

welcome to OH!

  1. unfortunately not. I’m pretty sure the Xiaomi lineup does not use common Zigbee standarts, so there is little chance you will ever get the devices workinig with a 3rd party dongle. but the gateway is just 30 bucks…
  2. zigbee is 2.4GHz - its hard to say, perhaps you can get a basic idea by deriving from 2.4GHz wifi, but then the protocol is still different. personally, I have drywall and one gateway is able to support all the devices I have (one floor, 100sqm). but again - the gateway is just 30 bucks, buy a couple of them :wink:
  3. never heard about that, not sure if this is really the case… but the binding does not support sockets as bridges. so it must be an Xiaomi internat thing, if at all possible.
  4. if you got wifi all over the place, buy more gateways - the sensors will be much more reliable too, means even with my drywalls from time to time I notice that a signal gets lost (e.g. I enter a room and the motion sensor does not trigger)
  5. v3 gateways are avaiable everywhere, why buy an older version? there are users with 30+ devices paired to one gateway…
  6. oh yeah :slight_smile:
  7. do you mean deactivating the sound they make? Do they even make sound? I don’t have any, so I’m not sure. If you mean “ignoring the zigbee alarm signal” - sure with rules you can just do whatever you want with it
1 Like

Hi dimalo

and thanks for the info.

Regarding

  1. Direct Communication
    Right now Xiaomi could close the developer API with a simple OTA update to the gateway. Or maybe we just can’t get a replacement gateway in two years if our current gateway dies.
    It seems to be possible to decipher the protocol, see
    articles about sniffing
    and Decrypting
    .
    This guy is just finishing the work on a generic Zigbee gateway. Unfortunately openHAB was not on his list for early developer units.
    .
    Zigbee shepherd can handle Xiaomi as well it seems, see here, here and even here on openHAB.
    .
    So direct communication with Xiaomi zigbee components seems to be possible, but not too easy.

  2. Repeater: There is some talk about the repeater functionality and the problems it has with some other Zigbee components at SmartThings.com

  3. buying a couple of gateway is the easiest solution.

  4. I mean using the smoke detector’s alarm signals (sound / flashing) for other purposes. Intrusion alarm for example.

I just ordered a couple of components to start with. We will see how this evolves. At least I need to retire my old TINI Java SoC. Its been running continuously for almost 15 years now and I doubt it will last much longer. I just realize that it has Sram buffered with a lithium battery.

Hi team,

Need your help!
I’ve recently added Xiaomi Zigbee Plug to my collection of Xiaomi devices.
It works great, can read the power load and consumption, updates the status of the switch but I cannot control the device from OpenHAB.
Is there anything that I’ve done wrong in the config?

Items:

Switch 		Mi_Plug_1_Switch 		"Media Centre Switch [%s]"				<switch> 			{ channel="mihome:sensor_plug:158d0001ded347:power" }
Switch 		Mi_Plug_1_Active 		"Media Centre Active [%s]"			   	<switch> 			{ channel="mihome:sensor_plug:158d0001ded347:inUse" }
Number 		Mi_Plug_1_Power 		"Power Load [%.1f W]"					<energy> 			{ channel="mihome:sensor_plug:158d0001ded347:loadPower" }
Number 		Mi_Plug_1_Consumption	"Power Cunsumed [%.1f kWh]"				<line-incline> 		{ channel="mihome:sensor_plug:158d0001ded347:powerConsumed" }

Sitemap:

		Switch item=Mi_Plug_1_Switch
		Switch item=Mi_Plug_1_Active
		Text item=Mi_Plug_1_Power
		Text item=Mi_Plug_1_Consumption

Logs:

2017-10-27 15:58:00.559 [ItemStateChangedEvent     ] - Mi_Plug_1_Power changed from 46.65 to 46.21
2017-10-27 16:11:24.570 [ItemStateChangedEvent     ] - Mi_Plug_1_Consumption changed from 18.536 to 18.563
2017-10-27 16:11:24.571 [ItemStateChangedEvent     ] - Mi_Plug_1_Power changed from 46.21 to 46.65
2017-10-27 16:45:23.496 [ItemStateChangedEvent     ] - Mi_Plug_1_Power changed from 46.65 to 46.21
2017-10-27 16:45:23.497 [ItemStateChangedEvent     ] - Mi_Plug_1_Consumption changed from 18.563 to 18.591
2017-10-27 16:50:44.487 [ItemStateChangedEvent     ] - Mi_Plug_1_Power changed from 46.21 to 46.65
2017-10-27 16:58:27.481 [ItemStateChangedEvent     ] - Mi_Plug_1_Power changed from 46.65 to 46.21
2017-10-27 17:05:46.469 [ItemStateChangedEvent     ] - Mi_Plug_1_Power changed from 46.21 to 46.65
2017-10-27 17:16:21.455 [ItemStateChangedEvent     ] - Mi_Plug_1_Consumption changed from 18.591 to 18.617
2017-10-27 17:17:44.448 [ItemCommandEvent          ] - Item 'Mi_Plug_1_Switch' received command OFF
2017-10-27 17:17:44.458 [ItemStateChangedEvent     ] - Mi_Plug_1_Switch changed from ON to OFF
2017-10-27 17:17:46.100 [ItemCommandEvent          ] - Item 'Mi_Plug_1_Active' received command OFF
2017-10-27 17:17:46.102 [ItemStateChangedEvent     ] - Mi_Plug_1_Active changed from ON to OFF
2017-10-27 17:17:47.575 [ItemCommandEvent          ] - Item 'Mi_Plug_1_Switch' received command ON

Screenshot from Paper UI (I’ve added things via it):

1 Like

Wow didn’t even think of it as being possible!
good chance to get rid of the sniffing servers :slight_smile:

I hope things will evolve, but at the moment it seems like very hacky.

the gateway has sound playing capabilities. I guess writing to the smoke sensor is not possible.

@sasha_jpr: please enter your dev key. seems like youre not able to write but can read. check if the key is working by switiching the light on the gateway or something similar.

1 Like

Hi, thanks for the Xiaomi binding, great stuff.

I have some questions on it:

  1. Several channels seem to be mapped to a Switch type of item while I think they are more a read only info (e.g. LowBattery). Is this intentional or a mistake?

  2. Can things and items definitions directly in the config files coexist with the PaperUI defined ones?

  3. What would be the right way for me to monitor the “reachability” or “aliveness” of a device? I just noticed that one of the Water leak sensors I have is out of reach and so basically is not connected to OH, and nothing mentioned it (it appears nicely “online” in the things list)…

  4. Motion sensors from Xiaomi have also the ability to report illumination or brightness, and I don’t see this info being reported in the available channels for motion sensors? Was it forgotten? Or do I have a problem on my setup?

  5. Same for smoke detectors, I don’t see the channel for battery level and low battery appearing? Do I have a problem with my setup? And I don’t see either the “smoke density” and “ability to see in the smoke” info that are popping up in other plateforms for the same device…

Thanks,

@dimalo Hi, thanks for the advice. I’ve reenabled a dev code in the gateway settings and changed it in Xiaomi binding but it still the same. I cannot control it but can get data… Any other ideas?
Thanks!!!

Hello!
I have 3 leakage sensors. They are added to the android application and configured in OpenHAB. In the rules, when alarming and resetting the alarm, sending to telegrams is configured. Everything works well!!! Yesterday morning in the android application received three notifications, alarm reset, OpenHAB did not send a telegram. Then I put all three sensors in the water and immediately got three telegrams, pulling the sensors out of the water, again received three telegrams. It turns out that those three notifications about the alarm reset in the android application are different from the real ones. What was it? Has anyone encountered a similar one?

Ist there a possibility to “reset” the motion sensors, so they don’t sleep one minute after triggering?

Does anyone have any preference to the original Mijia or newer Aqara items? Im wondering exactly what the difference between the two is besides looks.

@Mar Besides look, some of the newer Aqara items have additional sensors, for example the Aqara temperature & humidity also measure atmospheric pressure and the Aqara movement sensor also measure luminence. Most of the Aqara items also do away with the paper clip switch and instead work with a long press to connect and disconnect from your gateway. That is usually not a problem for most items.

The range of Aqara items is also growing while the Mijia have stopped and I am pretty sure is discontinued.

However, with the single switch version of the Aqara switch (to me looks better than the original round puck) misses out on the long press function. The original round switch has three functions - single quick press, double quick press and long press while the newer Aqara switch only has the single and double quick press. Also, sometimes if you accidentally press and hold on the switch, it disconnects form the gateway and you have to go through the steps to reconnect it. Something to think about.

1 Like

@CoolWombat thanks so much for the details around the original vs the Aqara items. I suppose it does make sense to go with the newer Aqara items, and I’d also agree that the Aqara items look a little better. Good to know around the bonus things like measuring pressure/luminescence - I suppose you could run a lot of automation just getting how bright it is back into openhab.

Also really good to know about the switch, having that extra function on the switch could prove useful. I’ve gone ahead and ordered a bunch of Aqara items and one of the original switches to try it out.

With all the sales I managed to get a whole ton of stuff for less than £80!! take that smartthings!

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?