core: miflora sensors reported as 'Unavailable'.

Home Assistant release with the issue:

0.103.4

Last working Home Assistant release (if known): 0.102

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

raspbian/virtualenv on pi4 python_version 3.7.3

Integration:

https://www.home-assistant.io/integrations/miflora/

Description of problem: Since https://github.com/home-assistant/home-assistant/pull/29276, miflora sensors are now displayed as ‘Unavailable’ when they can’t be reached. Since BtLE is quite unreliable, even with a good connection they are frequently displayed as ‘Unavailable’.

As values tend to change slowly, a day-old stale value is preferable to ‘Unavailable’.

image

All six of my devices are within 4m of the pi4 which runs home-assistant. Even the closest devices have gaps in the graphs where they are ‘Unavailable’. image image image

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


Traceback (if applicable):


Additional information:

Suggestion: Allow users to set a threshold after which the sensor is considered ‘Unavailable’. Only mark the sensor ‘Unavailable’ if the user has configured a threshold.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 86 (26 by maintainers)

Most upvoted comments

Can we await confirmation of the fix before closing the issue please?

Ups, yes platform should be miflora ` sensor:

  • platform: miflora mac: ‘C4:XX:XX:XX:XX:AC’ #nr: 1 … ` I also use the plant component - I also know that it can take a while till the sensor shows up

# https://home-assistant.io/components/plant/ plant: Palme: sensors: moisture: sensor.palme_moisture battery: sensor.palme_battery temperature: sensor.palme_temperature conductivity: sensor.palme_conductivity brightness: sensor.palme_brightness min_moisture: 20 max_moisture: 55 min_battery: 10 min_conductivity: 100 min_temperature: 11

i don t know why but i can receive the values. they are still unavailable. in the flower care app i see all values. in the bluetooth scan i see the sensors but not in Home Assistant

@DanielXYZ2000 is this working in your setup `sensor:

  • platform: ` nothing after platform?

on the console you should get: ` ~bluetoothctrl

Agent registered [CHG] Controller … XX:XX:… Discovering: yes [bluetooth]# scan on Discovery started [CHG] … [NEW] Device C4:X:XX:…XX:AC Flower care`

in my config it looks like

sensor: 
  - platform:   
    mac: 'C4:XX:XX:XX:XX:AC' #nr: 1
    name: Palme
    force_update: true 
    median: 1
    adapter: hci0
    monitored_conditions:
    - moisture
    - light
    - temperature
    - conductivity
    - battery

You don’t need BLE_ as prefix

@DanielXYZ2000 - platform: miflora mac: C4:7C:8F:61:2C:2A like this?

ok. perfect with the other terminal it is working, but the sensors are still unavailbale. how looks your mac adress of the sensor. did you also add the BLE? like: BLE_XX:XX:XX:XX?

im using this 😦 Bild 3

@Dreamoffice Which terminal add-on are you using? use the communitiy one: SSH & Web Terminal that should contain this command

@DanielXYZ2000 i never used terminal in HA. when i type i bluetoothctl just this message comes on: Bild 2

IMHO there are two different bugs:

  1. since HA 0.103: bad connection which results in the graph described in the original bug message. This should be solved with #31156
  2. since HA 0.104: bluetooth crashes and doesn’t recover even if HA is stopped (please correct me if it started in 0.103) This will probably not be solved by my patch. I bet this is caused thru: a) Update BlueZ 5.52 see: https://github.com/home-assistant/operating-system/releases/tag/3.8 b) Some changes either in the miflora code or in HA resulting in multiple queries at the same time or too many queries are breaking bluez. related to: https://github.com/home-assistant/core/issues/30147

This works for me: odroid xu4 + usb bt dongle HA 0.105 dietpi / kernel 4.14.66+ / bluez 5.43-2+deb9u1
1 miflora sensor 2meter away, so good connection. I have a 2nd one with a hardware/firmware bug. it takes one new battery every 4 weeks… I will buy another one.

I think my issues started with 0.104.x as well, I lowered the baudrate of my Pi 3B last sunday and no issues so far (about 56 hours later), still receiving data which matches with the values from the Flower Care app.

Found it here; https://github.com/raspberrypi/linux/issues/2264#issuecomment-344911712

Anyone running https://github.com/home-assistant/hassos/releases/tag/3.8 yet? It has an update to BlueZ package, maybe a fix?

Actually, I believe that this is a culprit of the issue in Hass.io. Before I updated to 0.104.x and HassOS 3.8, my miFlora worked good enough for almost a year. I had a small automation that was controlling whether the values were up-to-date, so didn’t need @ferbar update either. Now everything related to miFlora is broken which is quite annoying.