Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xiaomi ble temperature and humidity sensor polling error #19326

Closed
joten75 opened this issue Dec 15, 2018 · 45 comments
Closed

xiaomi ble temperature and humidity sensor polling error #19326

joten75 opened this issue Dec 15, 2018 · 45 comments

Comments

@joten75
Copy link

joten75 commented Dec 15, 2018

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.

@balloobbot
Copy link

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 👍

@yunnanpl
Copy link

yunnanpl commented Apr 30, 2019

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.

@dangrin0
Copy link

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.

@pixeldublu
Copy link

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

@mat4444
Copy link

mat4444 commented Jul 30, 2019

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.

@psp888
Copy link

psp888 commented Jul 31, 2019

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

@mat4444
Copy link

mat4444 commented Aug 1, 2019

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.

@rds-online
Copy link

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.

@nickdos
Copy link

nickdos commented Aug 5, 2019

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.

@dangrin0
Copy link

dangrin0 commented Aug 5, 2019

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.

@psp888
Copy link

psp888 commented Aug 5, 2019

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

@psp888
Copy link

psp888 commented Aug 8, 2019

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

@gasparirob
Copy link

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

@furiaceka87
Copy link

Any update?

@psp888
Copy link

psp888 commented Aug 11, 2019

Nope, still not working with 0.97.1

@danibiza
Copy link

something new?

@mat4444
Copy link

mat4444 commented Aug 25, 2019

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.

@furiaceka87
Copy link

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

@mat4444
Copy link

mat4444 commented Aug 25, 2019

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

@carlmes
Copy link

carlmes commented Aug 28, 2019

Just noting that other sensors have the same issues: #24453

@furiaceka87
Copy link

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

@psp888
Copy link

psp888 commented Sep 20, 2019

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

@mat4444
Copy link

mat4444 commented Sep 20, 2019

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.

@gohm44
Copy link

gohm44 commented Sep 21, 2019

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

@psp888
Copy link

psp888 commented Sep 21, 2019

Yes been working for 2 days straight and counting

@psp888
Copy link

psp888 commented Sep 21, 2019

I got mitemp and miflora, they both work perfectly now

@gohm44
Copy link

gohm44 commented Sep 23, 2019

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?

@psp888
Copy link

psp888 commented Sep 24, 2019

I'm using hassio

@Harshajv
Copy link

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

@pixeldublu
Copy link

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 )

@psp888
Copy link

psp888 commented Oct 12, 2019

i'm using Pi4

@pixeldublu
Copy link

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

@fbrinker
Copy link

fbrinker commented Oct 29, 2019

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

@pixeldublu
Copy link

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

@victorlapshev
Copy link

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

@Harshajv
Copy link

Harshajv commented Nov 2, 2019

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?

@gohm44
Copy link

gohm44 commented Nov 2, 2019

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

@0x646f6d
Copy link

0x646f6d commented Nov 3, 2019

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...

@fbrinker
Copy link

fbrinker commented Nov 3, 2019

@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

@magin1
Copy link

magin1 commented Nov 7, 2019

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? :)

@0x646f6d
Copy link

0x646f6d commented Nov 7, 2019

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

@magin1
Copy link

magin1 commented Nov 9, 2019

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?

@pdonat01
Copy link

pdonat01 commented Dec 12, 2019

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

@stale
Copy link

stale bot commented Mar 11, 2020

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.

@stale stale bot added the stale label Mar 11, 2020
@stale stale bot closed this as completed Mar 18, 2020
@zephirus
Copy link

I have the latest HA version. This issue is still happening.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests