dolezsa / Xiaomi_Hygrothermo

Home-assistant sensor platform for Xiaomi Mijia BT Hygrothermo temperature and humidity sensor
MIT License
89 stars 16 forks source link

Only works on discovery mode #2

Closed vicfergar closed 5 years ago

vicfergar commented 6 years ago

Hi, I have included your component in my system. Hass.io can only read values while the device is in discovery mode (pressing Bluetooth button). It is intended?

Thanks for your work!

dolezsa commented 6 years ago

Hi, thank you for your feedback. No, this is not intended. I did not experience such behavior, though I did not try it out from hass.io ... It works for me from a plain python or docker installation. Have you paired your device with mi-home app? Maybe it could be the key to solution.

vicfergar commented 6 years ago

Hi again,

I cannot pair the device throught the app, it does not recognize the device and I can not find it in the "manual add" device list. I have tried with different regions and found same behavior.

I have notice that HASS sometimes connects with the device, because in the graph I can see different values across the time. Anyway most of the time it shows the state unavailable, but when the device enter in discovery mode HASS read the values without problems instantanelly... Its extrange...

image

CapReed commented 6 years ago

Hi my friends.

I have the same problem, only go with i press the button syncro. I have instaled hassio.

My graph is equal to Victor.

Thank you!

dolezsa commented 6 years ago

and do you not have paired your device with mi-home app also?

CapReed commented 6 years ago

Than you for you response.

I've tried it in three ways:

I always get the same problem: Unexpected error: Failed to connect to the 4C: 65: A8: D0: 7C: 55, addr type: public

Regards.

CapReed commented 6 years ago

Solved!!!!

You are my hero, only today ... ;-)

I install a new clean hassbian (no hassio) and go at first chance with your module.

Thank you very very much!

vicfergar commented 6 years ago

So maybe it is not 100% compatible with hassio?

jojoro1 commented 6 years ago

I have the same problem. Sensor reading i correct only after restart hassio. Then after 30 seconds readings from sensor "unavaliable". In logs I've got "Unexpected error: Failed to connect to the MAC:ADDRESS, addr type: public" If I press bluetooth button on device then sensor reads status again - for 30s.

dolezsa commented 6 years ago

Hi everybody,

I don't have hassio not either possibility to migrate to hassio, so I am not able to check it but I have two theories:

The pressence of "error" message in logs (Failed to connect to the MAC...) mustn't mean error, there can be many reasons. It just means that the device, wich You are trying to connect to, is ureachable or is overloaded. For example in the time when in mihome you are checking actual status of Your device, the computer cannot connect to (it is standart behavior of bluetooth). In my configuration (HA runs on standart PC with BT dongle in USB port, HA installed to virtualenv by pip) sometimes appeares this in log too, but graph is more less continual...

It would be good, if someone of You has possibility to try to replace hassio with regular installation using pip.

snip_20180427101907

jojoro1 commented 6 years ago

My thermometer is paired with mihome and BLE hub in Bedside Lamp. I have no problems with that. So its only Hassio problem. Can I read sensor via BLE gateway like Mihome do?

risa2000 commented 6 years ago

I have set up the Mi HygroThermoMeter with RPi 3b+ native bluetooth interface using @dolezsa script and it worked right from the start as expected (I had to pair it first though) except one thing. I see regularly in the log that the device is unavailable for one reading, like every 30-45 minutes. I have set up the reading frequency for 120 seconds, so it looks more like some systematic bug or disturbance than some generic radio problem. But on the RPi I do not use wifi (it is disabled by rfkill) and the only other radio I have connected is Z-Wave dongle which operates on different frequency. So I wonder what might be the problem.