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

Problem with Mi Flora in 0.94.1 #24453

Closed
amaciasf opened this issue Jun 10, 2019 · 42 comments · Fixed by #26297
Closed

Problem with Mi Flora in 0.94.1 #24453

amaciasf opened this issue Jun 10, 2019 · 42 comments · Fixed by #26297
Assignees

Comments

@amaciasf
Copy link

amaciasf commented Jun 10, 2019

Home Assistant release with the issue:
from 0.94.0b0 to 0.94.1

Last working Home Assistant release (if known):
0.93.2

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

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

Description of problem:
Not updating and showing Unknown sensors value.

Rolled back to 0.93.2 and all working fine.

(similar problem that this with Xiaomi BLE Temperature and Humidity sensor: #24313)

I could see that in version 0.93.2 Bluepy was used and in version 0.94 Gatttool. Why?

Traceback (if applicable):

0.93.2:

2019-06-10 12:00:15 INFO (SyncWorker_9) [homeassistant.loader] Loaded miflora from homeassistant.components.miflora
2019-06-10 12:00:22 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.miflora
2019-06-10 12:00:22 DEBUG (MainThread) [homeassistant.components.miflora.sensor] Miflora is using BluepyBackend backend.

0.94.1:

2019-06-10 12:45:41 INFO (SyncWorker_7) [homeassistant.loader] Loaded miflora from homeassistant.components.miflora
2019-06-10 12:46:09 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.miflora
2019-06-10 12:46:09 DEBUG (MainThread) [homeassistant.components.miflora.sensor] Miflora is using GatttoolBackend backend.
@ghost
Copy link

ghost commented Jun 10, 2019

Hey there @Danielhiversen, @ChristianKuehnel, mind taking a look at this issue as its been labeled with a integration (miflora) you are listed as a codeowner for? Thanks!

This is a automatic comment generated by codeowners-mention to help ensure issues and pull requests are seen by the right people.

@ChristianKuehnel
Copy link
Contributor

First guess, without analyzing: You do not have the bluepy library installed any more. miflora prefers bluepy and falls back to gatttool if bluepy is not found.

@amaciasf
Copy link
Author

Yes, I've seen that in the component code. It is assumed that the Bluepy library comes installed in docker, right?

Because it does not appear installed in the 0.94.1

0.93.2:

# docker stop ha
ha
# docker container rm ha
ha
# docker run --init -d --name="ha" -v /docker/ha/config:/config -v /etc/localtime:/etc/localtime:ro --net=host --restart unless-stopped homeassistant/raspberrypi3-homeassistant:0.93.2
3c8fd41cae55c63ce83886389b54473ee0d596486477049c2d42dedc602e07ae
# cat .HA_VERSION
0.93.2
# docker exec -it ha /bin/bash
bash-4.4# pip3 show bluepy
Version: 1.1.4
Summary: Python module for interfacing with BLE devices through Bluez
Home-page: https://github.com/IanHarvey/bluepy
Author: Ian Harvey
Author-email: website-contact@fenditton.org
License: UNKNOWN
Location: /usr/local/lib/python3.7/site-packages
Requires:
Required-by: python-eq3bt, PySwitchmate, PySwitchbot, decora
bash-4.4#

But in 0.94.1 (since 0.94.0b0) it is not installed:

# docker stop ha
ha
# docker container rm ha
ha
# docker run --init -d --name="ha" -v /docker/ha/config:/config -v /etc/localtime:/etc/localtime:ro --net=host --restart unless-stopped homeassistant/raspberrypi3-homeassistant:0.94.1
f40798b7720ec3c6abd47ca38a082582498e9f955df538e67ffed57f4a3e1c8a
# cat .HA_VERSION
0.94.1
# docker exec -it ha /bin/bash
bash-4.4# pip3 show bluepy
bash-4.4#
bash-4.4# pip3 install bluepy
Collecting bluepy
  Downloading https://files.pythonhosted.org/packages/27/91/6cfca10bee9862f93015413cf9e6a52c3081a71f1518963396a055128f8e/bluepy-1.3.0.tar.gz (217kB)
     |████████████████████████████████| 225kB 1.5MB/s
Building wheels for collected packages: bluepy
  Building wheel for bluepy (setup.py) ... error
  ERROR: Complete output from command /usr/local/bin/python -u -c 'import setuptools, tokenize;__file__='"'"'/tmp/pip-install-668n8xq9/bluepy/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-71bbs37q --python-tag cp37:                                           ERROR: running bdist_wheel
  running build                                                                      running build_py                                                                   Working dir is /tmp/pip-install-668n8xq9/bluepy                                    execute make -C ./bluepy clean                                                     error: [Errno 2] No such file or directory: 'make': 'make'                         ----------------------------------------                                           ERROR: Failed building wheel for bluepy
  Running setup.py clean for bluepy
Failed to build bluepy
Installing collected packages: bluepy
  Running setup.py install for bluepy ... error
    ERROR: Complete output from command /usr/local/bin/python -u -c 'import setuptools, tokenize;__file__='"'"'/tmp/pip-install-668n8xq9/bluepy/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-aht62vd6/install-record.txt --single-version-externally-managed --compile:
    ERROR: running install
    running build
    running build_py
    Working dir is /tmp/pip-install-668n8xq9/bluepy
    execute make -C ./bluepy clean
    error: [Errno 2] No such file or directory: 'make': 'make'
    ----------------------------------------
ERROR: Command "/usr/local/bin/python -u -c 'import setuptools, tokenize;__file__='"'"'/tmp/pip-install-668n8xq9/bluepy/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-aht62vd6/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-668n8xq9/bluepy/
bash-4.4#

Can anyone check why this happens?

Thanks!

@eucciferri
Copy link

Hello, good day! Did anyone manage to find a solution to this problem? In my case the failure continues to occur, even in the latest version 0.94.3.
Thanks!!

@amaciasf
Copy link
Author

@eucciferri The issue is the same that #24441

@repvik
Copy link

repvik commented Jul 6, 2019

Bluepy is not installed in 0.95.4 docker image either.
gattool manages to read battery on my flora, but fails reading humidity and temperature.

@eucciferri
Copy link

That's right, I had started working on version 0.95, but now that I'm realizing it, after version 0.95.4 it stopped working again!

@eucciferri
Copy link

Hi @repvik, this weekend I managed to solve this problem in the following way. I bought a NodeMcu ESP32, I configured it with the ESPHome firmware and connected Mi Flora to this device. Then the ESP32 sends the data to Home Assistant. You can connect more than one Mi Flora to a single ESP32. You must have the Mi Flora with its latest firmware version, that update with the official App. It works perfect, I recommend it.
If you give yourself time, you can do it.

Board:
https://www.amazon.com/IZOKEE-Development-ESP32-DEVKITC-Consumption-ESP-WROOM-32/dp/B073GT4Y39/ref=sr_1_3?__mk_es_US=%C3%85M%C3%85%C5%BD%C3%95%C3%91&keywords=esp32+nodemcu&qid=1563200330&s=gateway&sr=8-3

Instructions:
https://domoticaencasa.es/integracion-xiaomi-mi-flora-home-assistant-esphome-esp32

How to use ESPHome in HA:
https://esphome.io/guides/getting_started_hassio.html

This is how my configuration for the ESP32 firmware was:
image

image

@JBS5
Copy link

JBS5 commented Jul 16, 2019

I do have the same problem with miflora with Hass.io 0.95.4

@repvik
Copy link

repvik commented Jul 19, 2019

Still same issue on 0.96.1

@eucciferri A separate ESP gateway is not an option. I don't want another device to power.

@timdonovanuk
Copy link

Same for me in 0.96.1. I have a feeling it was working fine in .93, but now most of my Mi Floras either are "unknown" or update about once a week..

@furiaceka87
Copy link

Same for me in 0.96.5.
It's probably because in HASS.IO bluepy is no more included as deps.
Do you have a plan to fix this?

@ChristianKuehnel
Copy link
Contributor

I can't test this at the moment. Can someone please try this:
Add "bluepy==1.3.0" to the requirements list in the manifest.json in https://github.com/home-assistant/home-assistant/blob/2b490e44862ca7daae113fff092202ce9a646823/homeassistant/components/miflora/manifest.json

This should tell HA to pull in bluepy as an additional dependency.

@furiaceka87
Copy link

furiaceka87 commented Aug 2, 2019

HA pull correctly bluepy but after one hour of correctly working, sensors stop to update.
Last info received in the log is:

2019-08-02 17:16:35 DEBUG (SyncWorker_12) [homeassistant.components.miflora.sensor] Potus Light intensity = 61
2019-08-02 17:16:35 DEBUG (SyncWorker_12) [homeassistant.components.miflora.sensor] Data collected: [61, 61]
2019-08-02 17:16:35 DEBUG (SyncWorker_12) [homeassistant.components.miflora.sensor] Not yet enough data for median calculation
2019-08-02 17:16:35 DEBUG (SyncWorker_7) [homeassistant.components.miflora.sensor] Polling data for Zamia Moisture
2019-08-02 17:16:35 DEBUG (SyncWorker_7) [miflora.miflora_poller] Using cache (0:19:52.081584 < 0:20:00)
2019-08-02 17:16:35 DEBUG (SyncWorker_7) [homeassistant.components.miflora.sensor] Zamia Moisture = 58
2019-08-02 17:16:35 DEBUG (SyncWorker_7) [homeassistant.components.miflora.sensor] Data collected: [58, 58]
2019-08-02 17:16:35 DEBUG (SyncWorker_7) [homeassistant.components.miflora.sensor] Not yet enough data for median calculation
2019-08-02 17:16:35 DEBUG (SyncWorker_16) [homeassistant.components.miflora.sensor] Polling data for Zamia Light intensity
2019-08-02 17:16:35 DEBUG (SyncWorker_16) [miflora.miflora_poller] Using cache (0:19:52.104346 < 0:20:00)
2019-08-02 17:16:35 DEBUG (SyncWorker_16) [homeassistant.components.miflora.sensor] Zamia Light intensity = 55
2019-08-02 17:16:35 DEBUG (SyncWorker_16) [homeassistant.components.miflora.sensor] Data collected: [55, 55]
2019-08-02 17:16:35 DEBUG (SyncWorker_16) [homeassistant.components.miflora.sensor] Not yet enough data for median calculation
2019-08-02 17:36:36 DEBUG (SyncWorker_14) [homeassistant.components.miflora.sensor] Polling data for Zamia Conductivity
2019-08-02 17:36:36 DEBUG (SyncWorker_14) [miflora.miflora_poller] Filling cache with new sensor data.

I just have just this message in the HASSIO info page:

Schermata 2019-08-02 alle 19 29 52

But in the log, either with debug level I can't see any request for sensors update.

@ChristianKuehnel
Copy link
Contributor

@furiaceka87 great, so the problem with the missing library seems to be solved. Can you please create a pull request for this?

Concerning the missing updates: They keep being reported, but I haven't been able to locate the source of the problem so far and it does not heppen in my setups. So I have no idea on how to solve this...

@furiaceka87
Copy link

furiaceka87 commented Aug 4, 2019

@furiaceka87 great, so the problem with the missing library seems to be solved. Can you please create a pull request for this?>

I'm not expert enough in GitHub to create a PR, sorry for this.

Concerning the missing updates: They keep being reported, but I haven't been able to locate the source of the problem so far and it does not heppen in my setups. So I have no idea on how to solve this...>

Could you please share with us your sensors configuration?
After the first refresh @ha reboot no other update come from the sensors...
Firmware of MiFlora is 3.2.1, if could be a useful information

@carlmes
Copy link

carlmes commented Aug 5, 2019

I'd be happy to help creating debug logs. I have a similar problem, where my miflora sensors (I have 4 of them) work fine for a couple of hours, then just stop reporting until i restart homeassistant (docker restart container), after which they spring back to life and work again for a few hours.

I tried migrating over to brand new install (from a Pi3-B to a Pi4), the only configuration that I copied was the sensor configuration in my configuration.yaml, otherwise it was a brand new install (to try eliminate configuration as the cause of the problem).

My HA version: 0.97.0b1

I've enabled debug logging, and will report back with any findings tomorrow once the issue occurs again:

logger:
  default: info
  logs:
   miflora: debug
   btlewrap: debug

Here's my sensor config:

# Sensors
sensor:
  # Weather prediction
  - platform: yr

  # Pink Orchid
  - platform: miflora
    mac: 'C4:7C:8D:63:EC:05'
    name: Pink Orchid
    force_update: true
    scan_interval: 1200
    #median: 3
    monitored_conditions:
      - moisture
      - light
      - temperature
      - conductivity
      - battery

  # Purple Orchid
  - platform: miflora
    mac: 'C4:7C:8D:63:FA:B4'
    name: Purple Orchid
    force_update: true
    scan_interval: 1200
    #median: 3
    monitored_conditions:
      - moisture
      - light
      - temperature
      - conductivity
      - battery

  # White Orchid
  - platform: miflora
    mac: 'C4:7C:8D:63:FA:C8'
    name: White Orchid
    force_update: true
    scan_interval: 1200
    #median: 3
    monitored_conditions:
      - moisture
      - light
      - temperature
      - conductivity
      - battery

  # Mini Orchid
  - platform: miflora
    mac: 'C4:7C:8D:64:01:37'
    name: Mini Orchid
    force_update: true
    scan_interval: 1200
    #median: 3
    monitored_conditions:
      - moisture
      - light
      - temperature
      - conductivity
      - battery

Oh, I also seem to have the correct bluetooth library? Here's what my homeassistant is reporting:

bash-5.0# pip3 show bluepy
Name: bluepy
Version: 1.3.0
Summary: Python module for interfacing with BLE devices through Bluez
Home-page: https://github.com/IanHarvey/bluepy
Author: Ian Harvey
Author-email: website-contact@fenditton.org
License: UNKNOWN
Location: /usr/local/lib/python3.7/site-packages
Requires:
Required-by: avea

(Accessed it through Portainer > Container console)

@furiaceka87
Copy link

I have exactly your same issue @carlmes

@obelix05
Copy link
Contributor

obelix05 commented Aug 6, 2019

Ist seems bluepy has a Problem with Python 3.7.3
IanHarvey/bluepy#364

@furiaceka87
Copy link

I also tried by using an external USB Bluetooth dongle without success.
After less then 1 hour stop to update the values

@eucciferri
Copy link

Dear,
Stop suffering and do what I mentioned above.
This is the same thing that you should do if you had a large house and the Bluetooth range did not reach. An ESP32 is used as Gateway.

In my case, I did that and I have never had problems again.

Bye!

#24453 (comment)

@furiaceka87
Copy link

@eucciferri probably you're right. But Raspberry Pi can handle these sensors, beacuse in the past it was working, so we have to found the solution.

@ChristianKuehnel
I tried the following tentative, without success:

  • Use Bluetooth USB dongle instead of native Raspberry Bluetooth
  • Use Gatttol instead of Bluepy

The issue is always the same, after some succesful update of the sensors after 1 hour more or less I receive the first WARNING "took longer than 10 seconds" and later it stops to work.

@carlmes
Copy link

carlmes commented Aug 9, 2019

As promised, here’s detailed logs from when the sensors stop working:

2019-08-05 15:37:36 DEBUG (SyncWorker_13) [miflora.miflora_poller] Filling cache with new sensor data.
2019-08-05 15:37:42 DEBUG (SyncWorker_13) [miflora.miflora_poller] Received result for handle 53: FE 00 00 EE 00 00 00 24 38 03 02 3C 00 FB 34 9B
2019-08-05 15:37:42 DEBUG (SyncWorker_2) [miflora.miflora_poller] Filling cache with new sensor data.
2019-08-05 15:37:44 DEBUG (SyncWorker_2) [miflora.miflora_poller] Received result for handle 53: FB 00 00 C6 00 00 00 26 AF 05 02 3C 00 FB 34 9B
2019-08-05 15:37:44 DEBUG (SyncWorker_6) [miflora.miflora_poller] Filling cache with new sensor data.
2019-08-05 15:37:47 DEBUG (SyncWorker_6) [miflora.miflora_poller] Received result for handle 53: F3 00 00 5A 00 00 00 12 64 01 02 3C 00 FB 34 9B
2019-08-05 15:37:47 DEBUG (SyncWorker_16) [miflora.miflora_poller] Using cache (0:00:00.010995 < 0:20:00)
2019-08-05 15:37:47 DEBUG (SyncWorker_17) [miflora.miflora_poller] Using cache (0:00:00.022043 < 0:20:00)
2019-08-05 15:37:47 DEBUG (SyncWorker_11) [miflora.miflora_poller] Filling cache with new sensor data.
2019-08-05 15:37:51 DEBUG (SyncWorker_11) [miflora.miflora_poller] Received result for handle 53: 00 01 00 CE 00 00 00 15 02 05 02 3C 00 FB 34 9B
2019-08-05 15:37:51 DEBUG (SyncWorker_12) [miflora.miflora_poller] Using cache (0:00:07.149638 < 0:20:00)
2019-08-05 15:37:51 DEBUG (SyncWorker_2) [miflora.miflora_poller] Using cache (0:00:08.864595 < 0:20:00)
2019-08-05 15:37:51 DEBUG (SyncWorker_1) [miflora.miflora_poller] Using cache (0:00:07.165023 < 0:20:00)
2019-08-05 15:37:51 DEBUG (SyncWorker_17) [miflora.miflora_poller] Using cache (0:00:03.721934 < 0:20:00)
2019-08-05 15:37:51 DEBUG (SyncWorker_15) [miflora.miflora_poller] Using cache (0:00:07.192641 < 0:20:00)
2019-08-05 15:37:51 DEBUG (SyncWorker_3) [miflora.miflora_poller] Using cache (0:00:08.901800 < 0:20:00)
2019-08-05 15:37:51 DEBUG (SyncWorker_16) [miflora.miflora_poller] Using cache (0:00:08.917443 < 0:20:00)
2019-08-05 15:37:51 DEBUG (SyncWorker_10) [miflora.miflora_poller] Using cache (0:00:00.077761 < 0:20:00)
2019-08-05 15:37:51 DEBUG (SyncWorker_12) [miflora.miflora_poller] Using cache (0:00:00.086036 < 0:20:00)
2019-08-05 15:37:51 DEBUG (SyncWorker_4) [miflora.miflora_poller] Using cache (0:00:00.090698 < 0:20:00)
2019-08-05 15:57:37 DEBUG (SyncWorker_3) [miflora.miflora_poller] Using cache (0:19:54.703271 < 0:20:00)
2019-08-05 15:57:37 DEBUG (SyncWorker_19) [miflora.miflora_poller] Using cache (0:19:49.546958 < 0:20:00)
2019-08-05 15:57:37 DEBUG (SyncWorker_14) [miflora.miflora_poller] Using cache (0:19:45.887923 < 0:20:00)
2019-08-05 15:57:37 DEBUG (SyncWorker_17) [miflora.miflora_poller] Using cache (0:19:53.042237 < 0:20:00)
2019-08-05 15:57:37 DEBUG (SyncWorker_13) [miflora.miflora_poller] Using cache (0:19:54.758556 < 0:20:00)
2019-08-05 15:57:37 DEBUG (SyncWorker_3) [miflora.miflora_poller] Using cache (0:19:45.922754 < 0:20:00)
2019-08-05 15:57:37 DEBUG (SyncWorker_0) [miflora.miflora_poller] Using cache (0:19:45.930966 < 0:20:00)
2019-08-05 15:57:37 DEBUG (SyncWorker_14) [miflora.miflora_poller] Using cache (0:19:54.787378 < 0:20:00)
2019-08-05 15:57:37 DEBUG (SyncWorker_10) [miflora.miflora_poller] Using cache (0:19:49.626010 < 0:20:00)
2019-08-05 15:57:37 DEBUG (SyncWorker_8) [miflora.miflora_poller] Using cache (0:19:45.961244 < 0:20:00)
2019-08-05 15:57:37 DEBUG (SyncWorker_1) [miflora.miflora_poller] Using cache (0:19:53.105975 < 0:20:00)
2019-08-05 15:57:37 DEBUG (SyncWorker_14) [miflora.miflora_poller] Using cache (0:19:49.646391 < 0:20:00)
2019-08-05 15:57:37 DEBUG (SyncWorker_9) [miflora.miflora_poller] Using cache (0:19:49.661411 < 0:20:00)
2019-08-05 15:57:37 DEBUG (SyncWorker_8) [miflora.miflora_poller] Using cache (0:19:53.130622 < 0:20:00)
2019-08-05 15:57:37 DEBUG (SyncWorker_6) [miflora.miflora_poller] Using cache (0:19:53.135761 < 0:20:00)
2019-08-05 15:57:37 DEBUG (SyncWorker_15) [miflora.miflora_poller] Using cache (0:19:54.854235 < 0:20:00)
2019-08-05 16:17:38 DEBUG (SyncWorker_15) [miflora.miflora_poller] Filling cache with new sensor data.
2019-08-05 16:17:42 DEBUG (SyncWorker_15) [miflora.miflora_poller] Received result for handle 53: F6 00 00 94 00 00 00 12 62 01 02 3C 00 FB 34 9B
2019-08-05 16:17:42 DEBUG (SyncWorker_8) [miflora.miflora_poller] Filling cache with new sensor data.
2019-08-05 16:17:42 INFO (SyncWorker_8) [homeassistant.components.miflora.sensor] Polling error [Errno 32] Broken pipe
2019-08-05 16:17:42 DEBUG (SyncWorker_16) [miflora.miflora_poller] Filling cache with new sensor data.
2019-08-05 16:17:52 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.white_orchid_temperature is taking over 10 seconds
2019-08-05 16:37:39 WARNING (MainThread) [homeassistant.components.sensor] Updating miflora sensor took longer than the scheduled update interval 0:20:00
2019-08-05 16:57:40 WARNING (MainThread) [homeassistant.components.sensor] Updating miflora sensor took longer than the scheduled update interval 0:20:00
2019-08-05 17:17:41 WARNING (MainThread) [homeassistant.components.sensor] Updating miflora sensor took longer than the scheduled update interval 0:20:00
2019-08-05 17:37:42 WARNING (MainThread) [homeassistant.components.sensor] Updating miflora sensor took longer than the scheduled update interval 0:20:00
2019-08-05 17:57:43 WARNING (MainThread) [homeassistant.components.sensor] Updating miflora sensor took longer than the scheduled update interval 0:20:00
2019-08-05 18:17:44 WARNING (MainThread) [homeassistant.components.sensor] Updating miflora sensor took longer than the scheduled update interval 0:20:00
2019-08-05 18:37:45 WARNING (MainThread) [homeassistant.components.sensor] Updating miflora sensor took longer than the scheduled update interval 0:20:00

@carlmes
Copy link

carlmes commented Aug 9, 2019

More info: https://community.home-assistant.io/t/suddenly-no-connection-to-miflora-sensor/123074

@furiaceka87
Copy link

@carlmes I tried clean installation many times without succeeding.
Are you able to solve in this way?

@DKCryptoKing
Copy link

+1 for this.

Still not working in 0.97.2

@timdonovanuk
Copy link

Same..I guess the docker image still isn't updated with the required Bluetooth dependencies.

@furiaceka87
Copy link

Same..I guess the docker image still isn't updated with the required Bluetooth dependencies.

I manually installed all the dependencies, it’s not an issue related to dependencies. Seems that MiFlora sensors take longer time to answer and after 10s there is timeout and no more update come from the sensors.
I also noticed that most of the problems are with raspberry.
I personally try to use also external Bluetooth dongle connected to the usb of raspberry without any change.

@timdonovanuk
Copy link

@furiaceka87 My HA cannot even connect on startup - back in around 0.90ish, they would at least connect but then lose connection over a few days. Since 0.94+ they don't even connect.

@furiaceka87
Copy link

@timdonovanuk are you in Raspberry?
@ChristianKuehnel any news?

@furiaceka87
Copy link

At the developer ( @Danielhiversen, @ChristianKuehnel )
Do you know if this fix can be applied to the MiFlora too:
https://gist.github.com/Magalex2x14/7389b840d873824dcabf93a193fe2ca8

@harrywesterman
Copy link

Would love this to be fixed, I used a spare Raspberry PI with https://github.com/ThomDietrich/miflora-mqtt-daemon to get one of my Mi Flora's working again :-) But the other two are in reach of my Hassio Raspberry, so I would like a direct connection again.

@ChristianKuehnel
Copy link
Contributor

@furiaceka87 @harrywesterman
The fix is described in my comment above: #24453 (comment)
Someone just needs to file a PR for this...

@furiaceka87
Copy link

@ChristianKuehnel I try the modification suggested in your comment #24453, however the problem is still there.
Bluepy is correctly used but the error is always there.

@ChristianKuehnel
Copy link
Contributor

ChristianKuehnel commented Aug 28, 2019

@furiaceka87
But then it's a different problem. This ticket is about Miflora not working at all because of the missing dependency. Either way, no one has bothered to file a PR for this yet. So it must not be that bad...

For failures after it was working for some time: I have no idea what is causing this or how to debug it. I read rumors that the problem is related to Bluetooth issues on Raspberry Pi 3 and can solved with a firmware update(sudo apt update; sudo apt upgrade; sudo rpi-update and rebooting). But I do not have any conformation for this.

@carlmes
Copy link

carlmes commented Aug 28, 2019

@ChristianKuehnel - this error occurs whenever there is a temporary problem communicating with a sensor (perhaps some Bluetooth radio interference?). Ideally, the error should be ignored and the sensor polled again at the next specified interval (most of us have 1200 or 1800 refresh interval configured), however once one sensor fails to respond correctly, the whole home assistant stack stops polling ALL sensors until it has been rebooted.

Here's a suggestion about how the error could be reliably reproduced:

  1. Create a debugging version of the miflora components that always throw the connection error. For example, if name = "debugging sensor" then throw this error: 2019-08-05 16:17:42 INFO (SyncWorker_8) [homeassistant.components.miflora.sensor] Polling error [Errno 32] Broken pipe

  2. Install and run the miflora debugging sensor. Notice how everything crashes and no further polling occurs.

Note - the error seems to exist in the polling logic somewhere, as other sensors (such as the temperature and humidity one) are also experiencing exactly the same problems as us: #19326 (comment)

@timdonovanuk
Copy link

I have also updated the bluepy dependency in my docker image but still get "unknown". Previously it would at least connect for a bit.

@timdonovanuk
Copy link

timdonovanuk commented Aug 29, 2019

Done a bit of poking. I'm running in docker, so I jumped into the shell of the container and tried to manually run a bluetooth scan:

hcitool lescan
Set scan parameters failed: I/O error

Well of course if my docker image cannot poll bluetooth then miflora is not going to work. So then I tried this command on my host machine, i.e. directly on the Pi. I got a similar result.

hcitool lescan
Set scan parameters failed: Input/output error

So if the Pi cant scan bluetooth, there is no way a docker image running on it will be able to...So I tried restarting bluetooth (directly, not in the docker container):

sudo hciconfig hci0 down
sudo hciconfig hci0 up

I then ran hcitool lescan again and got what we're looking for, a list of found bluetooth devices:

sudo hcitool lescan
LE Scan ...
65:5C:17:35:2D:0A (unknown)
62:5C:17:35:2D:0A (unknown)
62:6F:D7:13:54:E4 (unknown)
2A:A6:72:FC:24:18 (unknown)

I then went back into my HA docker container and hcitool lescan worked again..for a bit. It now seems to sometimes stop and then sometimes start working again...

Edit: now that I know bluetooth is actually scanning again, I couldn't find my sensors in the list of BLE mac addresses. I've replaced the battery in them and it's working again. So as I see it I have two problems:

  1. the bluetooth stack on the Pi sometimes falls over which causes this integration to stop working
  2. this integration drains the batteries very quickly if you don't set a scan_interval

Hurrah! My HA is back to telling me I'm incapable of taking care of my houseplants :) I should mention I'm running on 0.98 released today.

Now if only the plant card was not quite so damned ugly...

image

@ChristianKuehnel
Copy link
Contributor

I just filed that PR for the dependency problem. But to be honest, I'm really disappointed that nobody bothered to spend 10 minutes in the last month to fix this 1 line change! This is an open source project, so YOU (yes you in front of this screen!) are expected to contribute!

@esbenr
Copy link

esbenr commented Oct 19, 2019

Done a bit of poking. I'm running in docker, so I jumped into the shell of the container and tried to manually run a bluetooth scan:

hcitool lescan
Set scan parameters failed: I/O error

Well of course if my docker image cannot poll bluetooth then miflora is not going to work. So then I tried this command on my host machine, i.e. directly on the Pi. I got a similar result.

hcitool lescan
Set scan parameters failed: Input/output error

So if the Pi cant scan bluetooth, there is no way a docker image running on it will be able to...So I tried restarting bluetooth (directly, not in the docker container):

sudo hciconfig hci0 down
sudo hciconfig hci0 up

I then ran hcitool lescan again and got what we're looking for, a list of found bluetooth devices:

sudo hcitool lescan
LE Scan ...
65:5C:17:35:2D:0A (unknown)
62:5C:17:35:2D:0A (unknown)
62:6F:D7:13:54:E4 (unknown)
2A:A6:72:FC:24:18 (unknown)

I then went back into my HA docker container and hcitool lescan worked again..for a bit. It now seems to sometimes stop and then sometimes start working again...

Edit: now that I know bluetooth is actually scanning again, I couldn't find my sensors in the list of BLE mac addresses. I've replaced the battery in them and it's working again. So as I see it I have two problems:

  1. the bluetooth stack on the Pi sometimes falls over which causes this integration to stop working
  2. this integration drains the batteries very quickly if you don't set a scan_interval

Hurrah! My HA is back to telling me I'm incapable of taking care of my houseplants :) I should mention I'm running on 0.98 released today.

Now if only the plant card was not quite so damned ugly...

image

Hi,

Even with HA 0.100.2 containing @ChristianKuehnel s fix, I'm still facing the 10s limit issue.
I want to try your resolution to restart the BT stack.
I'm on a Raspberry Pi with the standard Hass.io image, but I don't know how to run the hcitool commands. The SSL console I can open via Putty seems limited. How do I get SSL access to the underlying OS, so I can perform your solution?

@h4
Copy link

h4 commented Nov 13, 2019

I'm on a Raspberry Pi with the standard Hass.io image, but I don't know how to run the hcitool commands.

If you use ssh-addon, you login into homeassistant docker container, when you just type ssh root@hassio.local.

Try this to log in into host machine:

ssh -p 22222 root@hassio.local
// inside shell type this
login
// now you can run host commands
# hcitoo lescan

But looks like down and up hci0 does not help...

@Strormcrow
Copy link

Just wondering, is there a fix for this?
Same issue. I had 3, that was perfect. I added 4 and now only 1 or 2 work no matter what I do...

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.