Mi(Xiaomi) Smart home bindings?

Can you place the gateway to the first floor and the temp-sensor in the last corner of your cellar?

There maybe is no zigbee connection anymore? And then place the plug in the ground floor and look if it is connecting?

Do you have the “Original Xiaomi Mi Home Smart WiFi Socket” or the “Original Xiaomi Mi Smart WiFi Socket - ZigBee Version” ?

Are there really 2 different Versions or is this all the same?

I guess, there are two versions. I have no ZigBee (at least not aware of) in my outlet. It’s WiFi only.
Perhaps the ZigBee version also functions as a gateway, as the Aqara smart IP cam (https://m.gearbest.com/ip-cameras/pp_978606.html?wid=21) is.

I have the Xiaomi Mi Smart Socket Plug 2 ZigBee Edition and i can confirm that it works as a repeater. Garage temp sensor was offline last night until i plugged that Smart socket with an Schuko-China adapter to nearby room and it automatically fixed the connection in about 5mins.

Unfortunately IKEA trÄdfri dimmable bulb didnŽt bring this sensor up, i had that bulb switched on for whole night at the same location as that xiaomi smart plug.

1 Like

Having trouble with the motion sensor

i OH2.2, i added it as thing, and assigned items to Motion and Timer.
i can see the motion updates fine the Item, however i have no visible events in logs, and rules doesn’t apply

any ideas?

rule "YeeLightMotion Trigger"
when
    Channel "mihome:sensor_motion:158d0000f41d32:motion" triggered ON
then
        sendNotiication("l******@gmail.com", "motion trigered")
end

tried also using the item

rule "YeeLightMotion Trigger"
when
    Item corridormotion changed
then
        logInfo("YeeLight.Rules","motion activated")
        sendNotiication("l*******@gmail.com", "motion trigered")
end

UPDATE: had to change the Item associated to the Motion Sensor from CONTACT to SWITCH - did the trick
 getting now updates from the sensor.

Also consider changing sendNotiication to sendNotification

If your motion sensor is placed inside a frequently used room, you’ll get notifications every few minutes.
The sensor itself sends motion ON, waits for a interval (3mins in default, if I remember correctly) - then it’ll trigger OFF. if there’s still movement, it’ll trigger ON again.
I defined a proxy item with an expire-binding value of 10mins. It’ll go OFF if there’s no further ON coming from the sensor. Play around with the expire to suit your needs.

Hello Thomas @binderth,

I’d be interested in having examples of how exactly you do the below to detect when an item becomes offline and I’d like to understand if there is a way to make a one generic rule that works for all sensors or if I need systematically a rule per sensor?

Thanks for your help,

at first, try to understand how it works with single configuration:
items:

Number MiWeather_Temperature "Temperatur innen [%.1f C]" <temperature> (xiaomi) { channel="mihome:sensor_weather_v1:34cexxxxxx:158dxxxxxxxxxx:temperature",expire="2h" }

That means, if the item “MiWeather_Temperature” doesn’t get updated within 2h it will “expire” - meaning it’ll change to UNDEF.
That way, you can trigger some action on that:

rule "MiWeather failure"
when
	Item MiWeather_Temperature changed to UNDEF
then
	// do something like:
	var String message = "MiWeather Temperature sensor is offline!"
	logInfo("Xiaomi Mi offline", "message: "+message)
	sendNotification("john@deere.com", message)
end

Now: if you know, how this works - you can put all your Sensors or whatever expiring in one Group and do some action, if the Group goes UNDEF:

items:

Group:Switch:OR(ON, OFF) gXiaomi "Xiaomi Sensors" 

note: the “OR” is key here, that means if one sensor inside the group changes, the whole group changes With AND you’ll only get a UNDEF on the Group if all items within fail.

rule "Xiaomi sensors failure"
when
	Item gXiaomi changed to UNDEF
then
	// do something like:
	gXiaomi?.allMembers.filter(s | s.state == UNDEF).forEach[i|
		var String message = "Xiaomi sensor offline: " + i.name
		logInfo("Xiaomi Mi offline", "message: "+message)
		sendNotification("john@deere.com", message)		
	]
end

this means, you’ll get on every change of the Group gXiaomi a log-entry and a notification of all UNDEF items (presumably only one). If there’s more than one failure, you’ll only get the first one. If you’d like to have multiple notifications and log-entries, you’ll have to rewrite the trigger of the rule to Item gXiaomi received update - and you’ll have to have an IF to ask, if the update was UNDEF. To my Knowledge you can’t have “Item gXiaomi received update to UNDEF”
 I hope, you understand, what I mean


3 Likes

Thanks for the explanation! I already used these kind of rules to receive notification about my low batteries, but never used the ‘expire’ binding.
Will test this asap

Thank you Thomas, this is great. I’ll put in in place immediately.

Gents, I can’t find anywhere the loudness of the gateway.
Can it be used as a siren? Is it loud enough?

Thanks!

As an alarm to scare someone off I would say no. More like loudly announce presence.

Hello everyone

I am new to openhab and try to set up my smart home. Most of my equipment is from Xiaomi and the subcontractors. Unfortunately, I have a problem and I can’t make any items out of it at the switches. Of course, nothing can be combined in a meaningful way. Anybody got any advice?

yes - read the docs! :wink:
honestly - please read them thoroughly - otherwise we repeat ourselves daily here in the forum.
But please - if you find something difficult to understand in the docs or think something’s missing there - please tell us, so the docs can be improved.
For the time being:
https://docs.openhab.org/addons/bindings/mihome/readme.html

tl;dr> You can’t have items for events like button presses. you have to take the channel in a rule and there you can do something with your pressed button.
but you can have items for “battery level” and “low Battery”

Mi Gateway is compulsory for using Mi Sensors. It works on Zigbee Protocol which connects to Mi Gateway and Mi Gateway through wifi connects to your router.

Hi again,

I have a strange situation where a Aqara Temp sensor is showing the following:

  • flat on Grafana (stuck at given values since 24 hours)
  • offline in Mihome
  • nice and clean “on-line” in openhab

Did any of you already see this? There must be something wrong in my setup but I’m not sure what?

@binderth, this makes the rules to detect offline etc
 not triggering of course :slight_smile:

Thanks,

And I have another question, on a different front : Is there a way for me to find in MiHome the id of the sensor that are then used by openhab? I miss this to have a manageable mapping between openhab and mihome for the (rare) cases when I need to go to mihome. I have clicked everywhere in mihome I think and did not find the info.

Thanks,

Hi,

So you are using another Gateway as Zigbee Repeater or directly connected to wifi ?

Unfortunately not. You have to either add them one by one (and write the ID in a list or something) or you have to guess which device by either pressing buttons, checking information or something like that. I don’t see nor a ID or MACadress or something in MiHome for a Aqara-Device.