OpenHAB 2 and Xiaomi MiHome Temperature & Humidity Sensor

Hi there

I am a bit of a noob, but have OpenHAB 2 setup and configured and running with a few bindings (OpenSprinkler, Yamaha Receiver and Yahoo weather).

I am trying to get my Xiaomi MiHome kit going and have successfully installed the binding and can see (and have added) my “Xiaomi Mi Smart Home Bridge” which is online and showing all stats and controls as expected.

I have also added a “Xiaomi Mi Temperature & Humidity Sensor”, but the only information I am successfully getting is the battery percentage, with the temperature and humidity are showing as 0c and 0% respectively. I get the same with other sensors of the same type and also for my “Xiaomi Door/Window Sensor” (blank open status and last opened time, but battery percentage is fine).

Not sure if something needs adjusting in the bindings or things, but any assistance would be greatly received.

Thank you in advance for any responses and if there is any additional information you require, please do not hesitate to contact me.

Kind regards

Did you see it?

Sometimes you just have to wait. The sensors don’t update their values each 5 minuits.

You can force a update by changing their values, via opening the door/window contact an by holding the temperature sensor in your hand (heating it)

This is my sample item file

Number Temperature_Zona1_Teresa "Temperatura [%.1f ºC]" <temperature> (Temperature , Zona1_Teresa) { channel = "mihome:sensor_ht:158d000182eb02:temperature" }
Number Humitat_Zona1_Teresa "Humitat [%.1f %%]" <humidity> (Humitat , Zona1_Teresa) { channel = "mihome:sensor_ht:158d000182eb02:humidity" }
Number bateria_Zona1_Teresa_TH "Bateria TH[%.1f %%]" <bateria> (baterias , Status) { channel = "mihome:sensor_ht:158d000182eb02:batteryLevel" }

This is my things file

everything works with Xiaomi, (currently 48 sensors with 2 gatway) I take the opportunity to thank the authors of the binding and the help of this forum, especially Rich Koshak

Yep, the link Olymp provided is the one I used to set it up.

I have also waited and left overnight (and longer) with no change. The sensors are working as expected in the Xiaomi app on my phone and the stats for the different sensor’s battery line up between said app and OpenHAB.

I do not create a file of things. I add things from the inbox and create a file of items and a rule file.

I have the same problem.

I created bridge and motion sensors, temperature sensors and plug got discovered.

Though every time I restart openhab temperature/humidity/ battery level readings get updated, no further updates come. Motion sensor after restart receives batter level readings but doesupdate motion status and mi-switch does not receive commands.

I tried both 2.1 stable build as well as development snapshot.

Let’s start at the beginning, at the gateway you have entered the developer key ?
in Paper UI — Control devices appear and are updated ?
Which errors appear in Tail?

Ah ha! Your first post helped me Josep.

I deleted all the Xiaomi things I initially created using the Inbox and created them manually using .things files based on your examples. I found this link helpful with regards to creating the .things file manually.

My temperature sensors are now showing up with values as expected.

Hello again

I am not sure I can put my finger on the problem here. I have had the sensor showing up with temperature, but seem to have issues more often than not.

If I save and apply the .things file, I get the following in the openhab.log file and that suggests I have something wrong with my .things file… Does it not?

2017-09-20 20:46:29.024 [INFO ] [el.core.internal.ModelRepositoryImpl] - Validation issues found in configuration model 'home.things', using it anyway:
Provide a thing type ID and a thing ID in this format:
 <thingTypeId> <thingId>
Provide a thing type ID and a thing ID in this format:
 <thingTypeId> <thingId>
2017-09-20 20:46:29.058 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'home.things'

My .things file is pretty simple and all 3 show up and online in Configuration\Things in PaperUI.

The sensor is showing up on the Control screen, but only the battery percentage (still no temperature or humidity). The gateway also shows up and I can switch the light on/off and change the colours which suggests that the syntax is OK (I think) for that thing, but I am unable to see the difference between that and the sensor.

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

    Thing mihome:sensor_ht:158dXXXXXXXX "Xiaomi Temperature Sensor" [itemId="158dXXXXXXXX"]


Any advice greatly appreciated.

Kind regards

I don’t see any mistakes in your things file. Did you already tried to restart openHAB? I noticed that after changing lots of things after each other, it gets messed up. A restart always helps.

Oddly, I left the things file as detailed above overnight and when I checked it in the morning, the temperature is showing up.
I did leave it for some time last night before I sent my last post and also tried rebooting.

I expect my syntax is correct, but as you suggested, when making a lot of changes it might need some time to sort itself out. Still not sure about the errors in the log files though.

So, my advice for anyone having the same issue is that the syntax above works, but it would pay to reboot and wait before trying something else.

FYI, I have Pi install and:
/etc/openhab2/things is where the .things file goes
./var/log/openhab2/openhab.log is the log file I mentioned above

It finally works for me as well.

Previously following instructions I had udp 9898 port opened on myhab2 servers, but in this configuration sensers were updated only once after restart of openhab2. experimenting I opened tcp 9898 port and updates started rushing in - it works now perfectly. I guess for most of people this is obvious, thought some have to find it hard way :slight_smile:

For fixing the thing config, see my post @ Xiaomi Binding 2.1 Thing configuratin failures in LOG