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 #24313

Closed
Bergasha opened this issue Jun 5, 2019 · 176 comments
Closed

Xiaomi BLE Temperature and Humidity sensor #24313

Bergasha opened this issue Jun 5, 2019 · 176 comments

Comments

@Bergasha
Copy link

Bergasha commented Jun 5, 2019

Home Assistant release with the issue:
0.94.0b8

Last working Home Assistant release (if known):
0.93.2

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

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

Description of problem:
Not updating and showing Unknown temp and humidity only error is
(Updating mitemp_bt sensor took longer than the scheduled update interval 0:00:30)

Rolled back to 0.93.2 and all working fine.

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

- platform: mitemp_bt
  mac: '4C:65:A8:D6:61:08'
  monitored_conditions:
    - temperature
    - humidity
    - battery


**Traceback (if applicable):**

**Additional information:**
@thanhkeyi

This comment has been minimized.

@pkozul

This comment has been minimized.

@christopherl06

This comment has been minimized.

@VuokkoVuorinnen

This comment has been minimized.

@julienperignon

This comment has been minimized.

@Jakobsons
Copy link

HASSIO 0.95.4 on Rasppbery PI 3B+ can t get state and tempreature from XIAOMI Temp. sensors. Someone could?

@julienperignon
Copy link

@Jakobsons i've got 2 sensors one of them works the other one doesn't. Not sure why.

@sendorm
Copy link

sendorm commented Jul 5, 2019

Same issue. HASS 0.95.4 with direct install on raspberry pi buster.

@xguitoux
Copy link

xguitoux commented Jul 8, 2019

Switching to 0.95.4 from 0.95.0 had the same effect for me, working before, not working now :'(

@bramschats

This comment has been minimized.

@julienperignon

This comment has been minimized.

@martin3000
Copy link
Contributor

This message is from helpers/entity_platform.py and I wonder where the scan_interval of 30s comes from.

@julienperignon
Copy link

  • Restarted my router (probably not relevant)
  • Updated Hass.io
  • Restarted my Pi
    Randomly started working again ...

@sendorm
Copy link

sendorm commented Jul 31, 2019

I am on hass 0.96.3 and the problem has been solved for me. I am on python 3.7.

@Harshajv
Copy link

Harshajv commented Aug 1, 2019

Same here, Using 0.96.5

  • Update of sensor.xx_temperature is taking over 10 seconds
  • I have 10 Sensors, I tried restarting and it works when restarted
  • It was working aweosme till recently...... :( and now it's not
  • Then I changed the parm. in config
    ' - platform: mitemp_bt
    mac: 'xxxxxx'
    name: Bed
    force_update: true
    median: 1
    timeout: 60
    retries: 5
    monitored_conditions:
    - temperature
    - humidity
    - battery
    '
  • It works for some time and then stops, I did wait for days and weeks, but once it has stopped, It will not start again, until you restart HA!
  • Some times it worked for like 8 Hours and then it stops forever!
  • I tried to check with the Mi app on my phone, it was different, When I clicked on each of my 10 sensors, it asked me to accept terms and conditions (Like it's the first time), and after that it updated and I can see the temprature and humidity on my phone app! but on HA it shows last updated so many hours ago or days ago... (In the picture (Last one with plots) the flat line is when there is no update from the sensors)
  • Please help.

image

image

image

image

image

@dxdx65
Copy link

dxdx65 commented Aug 5, 2019

same problem here with Xiaomi BLE Temperature and Humidity sensor upgrading from 0.95.4 (working) to 0.96.5 (not working, devices "unknown")

@hungpr0
Copy link

hungpr0 commented Aug 10, 2019

Same problem here with 0.97.

Thanks

@yoni3210

This comment has been minimized.

@irimiab
Copy link

irimiab commented Aug 11, 2019

I have the same problem with 0.97.1
I just made the update last night (to 0.97.1) and there is still the same issue.

@e3raf
Copy link

e3raf commented Aug 12, 2019

Having same issue here :::
2019-08-12 22:34:13 WARNING (MainThread) [homeassistant.components.sensor] Updating mitemp_bt sensor took longer than the scheduled update interval 0:00:30

Thank you to fix this on next release

@sive66
Copy link

sive66 commented Aug 26, 2019

Same isssue here. Sensors work for approximately 2 hours. then stop.
If I reeboot hassio, they start working again for some time.

Version 0.97.1

@xguitoux
Copy link

Any update here ? I upgraded to 0.97.2 and sensors are not working at all (even after a reboot)

I tried to update my python version in my VM but no change, inside HASS.IO version is :

python_version | 3.7.4

@marcoCasamento
Copy link

same issue here, it works for a while after the restart then it stops working and need another restart for it to start working again. HA 0.98.3 on HASSOS 2.12, RbPI 3b

@vldp2000
Copy link

vldp2000 commented Sep 6, 2019

HassOS 3.4
HA 0.98.4
Raspberry Pi 4

same issue
2019-09-06 14:15:53 WARNING (MainThread) [homeassistant.components.sensor] Updating mitemp_bt sensor took longer than the scheduled update interval 0:00:30

shows Unknown value

@MartinTerp
Copy link

I have same issue:

In docker container:

bash-5.0# hcitool dev
Devices:
        hci0    28:CF:E9:01:A1:66

bash-5.0# hcitool lescan
LE Scan ...
58:2D:34:34:E5:83 MJ_HT_V1
2019-09-07 23:19:04 WARNING (SyncWorker_17) [homeassistant.components.mitemp_bt.sensor] Polling error
2019-09-07 23:19:04 WARNING (SyncWorker_11) [homeassistant.components.mitemp_bt.sensor] Polling error Could not read data from Mi Temp sensor 58:2D:34:34:E5:83
2019-09-07 23:19:38 WARNING (MainThread) [homeassistant.components.sensor] Updating mitemp_bt sensor took longer than the scheduled update interval 0:00:30

conf:

sensor:
  - name: Sensor
    platform: mitemp_bt
    adapter: hci0
    median: 3
    mac: '58:2D:34:34:E5:83'

@eliobou
Copy link

eliobou commented Sep 8, 2019

Same for me, works for a few hours then stop. No solution ?

@tominogino
Copy link

Same issue here, it works for some time after reboot and then stops. Hassio 0.98.4

@odisseo79
Copy link

Same issue, version 0.98.4 installed on docker in raspbian on RBPi3+.
I just reinstalled using 2019-07-10-raspbian-buster-lite and the updating everything.
On previous installation using the same raspbian image but done at the beginning of august everything was working fine.

@rquattros
Copy link

Back again with updates from the USB BT solution: it works for longer, but eventually stops updating just like with the internal BT. Some times works for a couple of days, some others just a few hours. It's not a permanent solution.

@ojalaj
Copy link

ojalaj commented Feb 3, 2020

Hmm... @rquattros the work-around has worked for me. Have some other attached USB (or other) devices to your RPi? Check "dmesg", "dmesg | grep error" etc. on command-line.

@aleqx
Copy link

aleqx commented Feb 4, 2020

This issue is confusing (and I did read through it). What's the actual verdict? Does the current HA version for Pi work with the sensor without hacks? The current docs at https://www.home-assistant.io/integrations/mitemp_bt/ doesn't warn of any issues and claims sit should work with platform: mitemp_bt

The folks who posted the last messages (Jan 5 onwards) seem to be discussing about config no longer supported ... adds to confusion

@esemve
Copy link

esemve commented Feb 23, 2020

Same problem here. A tried with an external bluetooth dongle. It works ~2 hours after same error. :\

@vikdb
Copy link

vikdb commented Feb 27, 2020

Been having this issue for over 6 months

@mansig88
Copy link

mansig88 commented Mar 9, 2020

Any news on this? (my experience https://f.ruuvi.com/t/ruuvitags-in-ha-more-and-more-unstable-with-time/3953/5)

Yes! I finally solved this problem (with your workaround).

Just bought an TP-Link UB400 from Amazon (it was the first that showed), plugged it into my RP3, disabled the on-board bluetooth by adding ‘dtoverlay=pi3-disable-bt’ to the end of ‘/boot/config.txt’ (used my PC to edit the config.txt directly from the microSD) and boom! Solved!

My kids room temperature rely on the thermostat I have built with this BLE Xiaomi cookies.

No additional configuration, the dongle just worked out of the box. It's literally just a two step hack - outside spending ~10€.

EDIT: I'm on Hass.io 0.103.6, it that matters.

Hello, I bouth the same, but the problems continue, I disable internal bluetooth of RPi3b
image

@simfun
Copy link

simfun commented Mar 18, 2020

After many trial and error troubleshooting, i concluded that this must be related to power issues. After replacing my RPi power supply to a 5V-2.5A one, it works perfectly. No more BT stopping receiving results, no more need for restarts.

@mansig88
Copy link

HI @simfun where did you buy??

@simfun
Copy link

simfun commented Mar 19, 2020

The cable is a Blitzwolf braided USB-A to micro-USB:
https://www.banggood.com/BlitzWolf-2_1A-Reversible-Braided-Micro-USB-Cable-Double-Sided-USB-A-Male-to-Double-Sided-Micro-1m-p-1059938.html

The power supply (which is actually a quick charger 5V 3A) is this one in photo:
IMG_20200319_195718

I can not remember where i bought it.

@iromeo
Copy link

iromeo commented Mar 21, 2020

Yes, it does work now. I did two things, so I have to find out what did the trick:

  • Removed the integration with Flic (which uses bluetooth connections too)
  • Installed a new version of mitemp_bt using the steps from here

I now can see the temperature and humidity readings. The battery state is an attribute of both meters.

Raspberry Bluetooth (RBp Model 3B) still stop working in a couple of hours (Home Assistant 107.2)


Symptoms:

  • charts not updated for several hours
  • In HA logs device_tracker integration shows error:
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/bluetooth/bluez.py", line 31, in discover_devices
    lookup_class=lookup_class, device_id=device_id)
_bluetooth.error: (22, 'Invalid argument')
bash-5.0# hciconfig hci0 -a
hci0:   Type: Primary  Bus: UART
    BD Address: B8:27:**:**:**:**  ACL MTU: 1021:8  SCO MTU: 64:1
    DOWN
    RX bytes:2685506 acl:6 sco:28 events:89264 errors:0
    TX bytes:31053 acl:0 sco:0 commands:2545 errors:0
    Features: 0xbf 0xfe 0xcf 0xfe 0xdb 0xff 0x7b 0x87
    Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3
    Link policy: RSWITCH SNIFF
    Link mode: SLAVE ACCEPT

or shows timeout errors

hci0:	Type: Primary  Bus: UART
	BD Address: B8:27:**:**:**:**  ACL MTU: 1021:8  SCO MTU: 64:1
	UP RUNNING
	RX bytes:21588252 acl:25 sco:188 events:639500 errors:0
	TX bytes:421887 acl:0 sco:0 commands:35902 errors:0
	Features: 0xbf 0xfe 0xcf 0xfe 0xdb 0xff 0x7b 0x87
	Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3
	Link policy: RSWITCH SNIFF
	Link mode: SLAVE ACCEPT
Can't read local name on hci0: Connection timed out (110)
  • hciconfig UP doesn't work:
$ hciconfig hci0 up
Can't init device hci0: Operation timed out (110)
  • dmesg | grep Bluetooth shows errors like:
[31640.441744] Bluetooth: hci0: Frame reassembly failed (-84)
[31640.442574] Bluetooth: hci0: Frame reassembly failed (-84)
[31640.443460] Bluetooth: hci0: Frame reassembly failed (-84)
[31640.444363] Bluetooth: hci0: Frame reassembly failed (-84)

and

[29431.849498] Bluetooth: hci0: command 0x1003 tx timeout
[29433.929502] Bluetooth: hci0: command 0x1001 tx timeout
[29436.009528] Bluetooth: hci0: command 0x1009 tx timeout
[29592.890423] Bluetooth: hci0: command 0x1003 tx timeout
[29594.970530] Bluetooth: hci0: command 0x1001 tx timeout
[29597.050443] Bluetooth: hci0: command 0x1009 tx timeout

I've found 4 possible workarounds for this

  1. Don't use RBP for BLE tracking, make simple BLE hub using ESP32 board (buy a ESP32 borad and set it up in 5-10 min, https://esphome.io/components/esp32_ble_tracker.html). There is a HA integration for it.

    Update: Works good (3 days already) in my case, still receive signal after Raspberry BLE failure.

    image

  2. Use 3rd party Bluetooth usb dongle + disable built-in bluetooth in HassOS

    Haven't tried this, but there are reports that it helps

  3. Use better power adapter

    The above posts say that it helps: Xiaomi BLE Temperature and Humidity sensor #24313 (comment). Today I replaced my adapter and will see how it works next 2-3 days.

  4. Wait until Raspberry Pi 3B "Error looking up Bluetooth device" operating-system#524 has been fixed in HassOS or try temporary fix, see updated instructions at Bluetooth: hci0: Frame reassembly failed (-84) raspberrypi/firmware#1150 (comment). This workaround should be repeated again after HassOS reboot. Also seems it's better to use HASS OS mitemp_bt component instead of built-in support (see https://github.com/custom-components/sensor.mitemp_bt), but it has the same bluetooth related issues.
    Update: Partly works for me, I got bluetooth errors again in ~ 1 day. I don't recommend this solution.

    image

lucagiove added a commit to lucagiove/operating-system that referenced this issue Mar 25, 2020
This problem is referenced in many different issues, some of them:
Bluetooth: hci0: Frame reassembly failed (-84)
raspberrypi/firmware#1150

Error communicating with local bluetooth adapter (RPi3)
home-assistant/core#30147

Xiaomi BLE Temperature and Humidity sensor no longer working after update from 0.95.4 to .096.5
home-assistant/core#25704

Xiaomi BLE Temperature and Humidity sensor
home-assistant/core#24313 (comment)

Solution seemed to reeduce the boud rate of the serial connection to BT
on rpi3b where flow control is missing.

The patch to the original btuart file is to reduce the baudrate only for
rpi3b models where flow control is missing:

-		$HCIATTACH /dev/serial1 bcm43xx 921600 noflow - $BDADDR
+		$HCIATTACH /dev/serial1 bcm43xx 460800 noflow - $BDADDR

I'm not a buildroot expert but the best way seemed to move the
upstream btuart download in a PRE_PATCH_HOOK so that standard
buildroot way of patching can be applied.
lucagiove added a commit to lucagiove/operating-system that referenced this issue Mar 25, 2020
This problem is referenced in many different issues, some of them:
Bluetooth: hci0: Frame reassembly failed (-84)
raspberrypi/firmware#1150

Error communicating with local bluetooth adapter (RPi3)
home-assistant/core#30147

Xiaomi BLE Temperature and Humidity sensor no longer working after update from 0.95.4 to .096.5
home-assistant/core#25704

Xiaomi BLE Temperature and Humidity sensor
home-assistant/core#24313 (comment)

Solution seemed to reeduce the boud rate of the serial connection to BT
on rpi3b where flow control is missing.

The patch to the original btuart file is to reduce the baudrate only for
rpi3b models where flow control is missing:

-		$HCIATTACH /dev/serial1 bcm43xx 921600 noflow - $BDADDR
+		$HCIATTACH /dev/serial1 bcm43xx 460800 noflow - $BDADDR

I'm not a buildroot expert but the best way seemed to move the
upstream btuart download in a PRE_PATCH_HOOK so that standard
buildroot way of patching can be applied.
pvizeli pushed a commit to home-assistant/operating-system that referenced this issue Mar 31, 2020
This problem is referenced in many different issues, some of them:
Bluetooth: hci0: Frame reassembly failed (-84)
raspberrypi/firmware#1150

Error communicating with local bluetooth adapter (RPi3)
home-assistant/core#30147

Xiaomi BLE Temperature and Humidity sensor no longer working after update from 0.95.4 to .096.5
home-assistant/core#25704

Xiaomi BLE Temperature and Humidity sensor
home-assistant/core#24313 (comment)

Solution seemed to reeduce the boud rate of the serial connection to BT
on rpi3b where flow control is missing.

The patch to the original btuart file is to reduce the baudrate only for
rpi3b models where flow control is missing:

-		$HCIATTACH /dev/serial1 bcm43xx 921600 noflow - $BDADDR
+		$HCIATTACH /dev/serial1 bcm43xx 460800 noflow - $BDADDR

I'm not a buildroot expert but the best way seemed to move the
upstream btuart download in a PRE_PATCH_HOOK so that standard
buildroot way of patching can be applied.
@perseus177
Copy link

For me,
the following option not fixed the problem

3.Use better power adapter
The above posts say that it helps: #24313 (comment). Today I replaced my adapter and will see how it works next 2-3 days.

@gojojo77
Copy link

gojojo77 commented Apr 1, 2020

The only thing that is working for me at the moment is installing the 'Xiaomi passive BLE monitor sensor platform' through the HACS system. It has worked for well over a week with no problem.

I followed the instructions here:
https://github.com/custom-components/sensor.mitemp_bt

@iromeo
Copy link

iromeo commented Apr 1, 2020

@gojojo77

‘ Xiaomi passive BLE monitor sensor platform'

In my case it seemed to work first 24 hours, then the same bluetooth connection errors

pvizeli pushed a commit to home-assistant/operating-system that referenced this issue Apr 15, 2020
This problem is referenced in many different issues, some of them:
Bluetooth: hci0: Frame reassembly failed (-84)
raspberrypi/firmware#1150

Error communicating with local bluetooth adapter (RPi3)
home-assistant/core#30147

Xiaomi BLE Temperature and Humidity sensor no longer working after update from 0.95.4 to .096.5
home-assistant/core#25704

Xiaomi BLE Temperature and Humidity sensor
home-assistant/core#24313 (comment)

Solution seemed to reeduce the boud rate of the serial connection to BT
on rpi3b where flow control is missing.

The patch to the original btuart file is to reduce the baudrate only for
rpi3b models where flow control is missing:

-		$HCIATTACH /dev/serial1 bcm43xx 921600 noflow - $BDADDR
+		$HCIATTACH /dev/serial1 bcm43xx 460800 noflow - $BDADDR

I'm not a buildroot expert but the best way seemed to move the
upstream btuart download in a PRE_PATCH_HOOK so that standard
buildroot way of patching can be applied.
@lucagiove
Copy link

It's fixed in hassos 3.13

@juaigl
Copy link

juaigl commented Apr 24, 2020

After update battery draining on Xiaomi was very fast. Did someone more experience that?

@lucagiove
Copy link

I think this is due to how the sensor has been implemented not really related to the communication problem or fix itself.
There is another custom sensor that seems less chatty.

@juaigl
Copy link

juaigl commented Apr 24, 2020

But i didn't remenber that this component drains the battery so fast.

Anyway, I will migrate to the custom one, that collects data passively.

Thanks.

@lucagiove
Copy link

Probably because wasn't working :)

@thiagogalvao
Copy link

Hey @juaigl, I noticed about that battery issue.
After I chenged the battery the problem was reducy a lot.

@juaigl
Copy link

juaigl commented Apr 24, 2020

Probably because wasn't working :)

I was speaking about when it was working. For my was until 102-103, if im not wrong

After I chenged the battery the problem was reducy a lot.

Thank you for you suggestion

@stale
Copy link

stale bot commented Jul 25, 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 Jul 25, 2020
@stale stale bot closed this as completed Aug 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.