Core: xiaomi ble temperature and humidity sensor polling error

Created on 15 Dec 2018  路  44Comments  路  Source: home-assistant/core

Home Assistant release with the issue:
0.84.2

Last working Home Assistant release (if known):

Operating environment (Hass.io/Docker/Windows/etc.):
Hass.io

Component/platform:
https://www.home-assistant.io/components/sensor.mitemp_bt/

Description of problem:
Polling error Could not read data from Mi Temp sensor 4C:65:A8:DA:89:E3

Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):

   - platform: mitemp_bt
     mac: '4C:65:A8:DA:**:**'
     monitored_conditions:
      - temperature
      - humidity
      - battery

Traceback (if applicable):

Polling error Could not read data from Mi Temp sensor 4C:65:A8:DA:**:**

Additional information:
even if the sensor is at 2cm from pi3 don't work. i've tried everything my config was ok (triple check) and the mac was the right one.

mitemp_bt stale waiting-for-reply

Most helpful comment

With the following command you can edit systemd unit files.
sudo systemctl edit bluetooth.service
There just insert those lines...
Further Info on systemd:
https://manpages.debian.org/jessie/systemd/systemd.service.5.en.html
https://www.digitalocean.com/community/tutorials/how-to-use-systemctl-to-manage-systemd-services-and-units

All 44 comments

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.

Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment :+1:

Home Assistant release with the issue:
0.92.0

Last working Home Assistant release (if known):
Not known, as I was using xiaomi_hygrothermo in the past.

Operating environment (Hass.io/Docker/Windows/etc.):
Linux (Armbian)

Component/platform:
https://www.home-assistant.io/components/sensor.mitemp_bt/

Description of problem:
After new start of Home Assistant, everything is working nice.
After 2-4 hours the _Polling error [Errno 32] Broken pipe_ is visible in the log and there there is no readout any more.
The line on the graph stays flat. Home assistant restart is required (but, all other bluetooth devices work, so even if there are some BT issues, the other subsystems keep working).
I have two such devices, which behave in the same way,

Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):

 - platform: mitemp_bt
    name: p0 floor
    mac: '4C:65:A8:xx'
    scan_interval: 60
    median: 2
    timeout: 60
    retries: 3

Traceback (if applicable):

_Polling error
12:32 AM components/mitemp_bt/sensor.py (WARNING)_
and later
_Polling error [Errno 32] Broken pipe
1:14 AM components/mitemp_bt/sensor.py (WARNING)_

Additional information:
In the past I was using the xiaomi_hygrothermo custom component, which was working fine, but stopped working (at all - does not start with "not found" error) with the latest update (unknown reason).
Therefore I switched to mitemp_bt, which is built in and provides nice features (like median).

Extra info: My system consists of ~10 bluetooth devices (BT and BLE), and one USB BT transmitter with self made antenna. There are always issues with the BT (on linux and windows), but there is no other way for me. I have low signal, connection losses, etc, but other subsystems catch the errors properly and do not die like this :)

At the moment I will try to switch back to hygrothermo.

I have the same issue. Time until failure is completely variable, sometimes it seems to work for a few days other times a few hours. I've tried both the Pi3 internal Bluetooth and a USB Bluetooth adapter, with the device ~20cm away. The device is still visible and connectable from bluetoothctl in the HassOS 2.12 host / developer SSH.

Same issue here. Have this problem since a few versions ago. Tried lots of things... getting sensor closer, different settings, even a different pi3 :)

I have exactly the same issue described by Yunnanpl. (_Polling error [Errno 32] Broken pipe
1:14 AM components/mitemp_bt/sensor.py (WARNING)_
It started appearing on Hass.io 0.96 for me.
Only a restart of Hass.io will make me able to poll the sensor again. Getting it closer will not change anything.

having same issue here with the latest version, not working with mitemp_bt and the mi_flora component. Bluetooth tracking is fine, just sensors stops working after a few errors with
Polling error [Errno 32] Broken pipe

The same error is also reported by other users on the Home Assistant forum. Hope it will get fixed in the next release of hass.io.

I have the same issue, it works fine for a few hours and then it stops updating like the others described. The errors are the same as listed above.

Subscribed - same issue & seems to be related to a recent update of HA/HASSIO as was working fine for months before this. My battery level is still >90% and position of sensor and host system has not changed.

I've moved over to Hassbian to see if the issue continues. I can confirm it is still present with the exact same HA config on Hassbian. Only error present in the HA log is:
WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.mitemp_bt_temperature is taking over 10 seconds
Running HA 0.96.5 on a fully up to date Hassbian.

seems to be getting worse too, some don't even update on reboot now.

looks like it's not fixed on the latest 0.97 release :-(

I confirm:
looks like it's not fixed on the latest 0.97 release :-(

Any update?

Nope, still not working with 0.97.1

something new?

There is a custom component that solves the issue. Please take a look at the hassio forum https://community.home-assistant.io/t/xiaomi-mijia-bluetooth-temperature-humidity-sensor-compatibility/43568/155?u=mat44150
It is not based on polling, but actually acquires data that the sensor sends every second.

Do you know if is it possible to apply same modification for miflora?

Sorry, I don't know how the mi flora works

Just noting that other sensors have the same issues: https://github.com/home-assistant/home-assistant/issues/24453

I see that someone solved by installing libglib2.0-dev, I cannot try because I'm on HASSIO.

I think this is finally fixed in 0.99, been 24 hours and still updating! Thank you developers!

I am glad the official component works for you psp888. I am going to stick with the custom component for now and hope it eventually becomes the standard component in a future release of home assistant. In my opinion, it is much better. It acquires much more data points in the same time interval, and since the data is automatically sent by the sensor, it has no impact on the battery's life. It is also more reliable to get data from more remote sensors: It virtually increased my communication range to 10m compared to 3-4m with the previous polling component.

@psp888 It is still working fine? Could you update?
I am asking because for me still does not work :(

Yes been working for 2 days straight and counting

I got mitemp and miflora, they both work perfectly now

For me, it works a few hours at longest but usually a few minutes after restart home assistant. I am really confused because I have some other components behave like this I mean stops updating after a few minutes. Most of them are related to the command line I guess like binary sensors... ping, cat... For me, issues appeared when docker build migrated to alpine instead of Debian. Has anyone had the same issues with other components or it's only xiaomi ble related?

I'm using hassio

The problem still persists even with 0.99.3
Works for couple of hours and then there are no updates.

Additional info: on the Pi Zero W this does not happen. Got a friend with a Pi Zero W and similar setup with xiaomi stuff and the ble temp sensor works perfectly for him. ( since last year )

i'm using Pi4

So this is only for the Pi3 ? I am wondering if there is a difference between the 32 and 64 versions...

@pixeldublu no i have the same issues on a zero w. I am using a pi3 and zero w as HA slaves

@fbrinker interesting... have a buddy with the same ble temp sensor and pi zero with same hassio versions and works flawlessly for him :|

I've checked, hassio uses bluepy as backend for mi sensor. And it have related issue

With new
Release 0.101.1 - October 31 -> Stopped working completly
Release 0.101.2 - November 1 -> Works but stops after few hours

We have to find a solution ASAP! Commits are not accepted
We have to find other ways

May be a special or new addon for Mi sensors?

I gave up a few releases ago. To work around this you can use esphome ;)
https://esphome.io/components/sensor/xiaomi_cgg1.html

I was follwing this issue for some time and also tried other solutions to narrow down the cause of the instabilities. for me it seems that this issue and #24313 and #24792 are about the same cause... My installation (raspbian, docker, hass 0.100.3) finally seems to be running stable IF I restart the bluetooth.service on the host (raspbian) regulary (like every day). Therefore I adjusted the systemd file with:

[Service]
Restart=always
RuntimeMaxSec=86400

I know, not a final solution, but a workaround I can live with...

@0x646f6d thanks, interesting idea, i will give it a try. Restarting the service from time to time is also my workaround, but didn't "automate" it yet

I was follwing this issue for some time and also tried other solutions to narrow down the cause of the instabilities. for me it seems that this issue and #24313 and #24792 are about the same cause... My installation (raspbian, docker, hass 0.100.3) finally seems to be running stable IF I restart the bluetooth.service on the host (raspbian) regulary (like every day). Therefore I adjusted the systemd file with:

[Service]
Restart=always
RuntimeMaxSec=86400

I know, not a final solution, but a workaround I can live with...

How and where can you set these settings? :)

With the following command you can edit systemd unit files.
sudo systemctl edit bluetooth.service
There just insert those lines...
Further Info on systemd:
https://manpages.debian.org/jessie/systemd/systemd.service.5.en.html
https://www.digitalocean.com/community/tutorials/how-to-use-systemctl-to-manage-systemd-services-and-units

With the following command you can edit systemd unit files.
sudo systemctl edit bluetooth.service
There just insert those lines...
Further Info on systemd:
https://manpages.debian.org/jessie/systemd/systemd.service.5.en.html
https://www.digitalocean.com/community/tutorials/how-to-use-systemctl-to-manage-systemd-services-and-units

Ah is see this is not possible in hass.io running on my Pi... while in ssh you are limited in what you can do, no sudo potability's. Is this restart of Bluetooth services possible with my setup?

Hi,

After 0.103: Happy Holidays, Service calls, StarLine, GeoNet NZ and Proxmox
I get same error
Polling error [Errno 32] Broken pipe
asd

Now every hygro/thermo sensor goes unknown

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 馃憤
This issue now has been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

moskovskiy82 picture moskovskiy82  路  3Comments

sogeniusio picture sogeniusio  路  3Comments

TheZoker picture TheZoker  路  3Comments

kirichkov picture kirichkov  路  3Comments

Konstigt picture Konstigt  路  3Comments