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

Miflora not working (not getting sensor data) #10790

Closed
tactmaster opened this issue Nov 25, 2017 · 11 comments · Fixed by #11250
Closed

Miflora not working (not getting sensor data) #10790

tactmaster opened this issue Nov 25, 2017 · 11 comments · Fixed by #11250

Comments

@tactmaster
Copy link

Home Assistant release (hass --version):
0.58.0

Python release (python3 --version):
Python 3.5.3

Component/platform:
RPi 2 Stretch - venv
with CSR Bluetooth 4.0 dongle

Bus 001 Device 004: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)

Description of problem:

Does read miflora device at all.

Updating miflora sensor took longer than the scheduled update interval 0:00:30
12:16 helpers/entity_component.py (WARNING)

using miflora https://github.com/open-homeautomation/miflora/
works.
I have tired changing the timeout however I am not sure that behaves correctly.

Expected:

returns values for the sensor

Problem-relevant configuration.yaml entries and steps to reproduce:

  - platform: miflora
    mac: xx:xx:xx:xx:xx   
    name: Ben the Flower
    force_update: false
    #imeout : 300
    median: 3   
    retries : 10
    monitored_conditions:
      - moisture
      - light
      - temperature
      - conductivity
      - battery

Additional info:

  • platform: bluetooth_le_tracker worked on my system without problem

this maybe a repeat of #3458 however I not sure gatttool seems to working fine for me

@fabaff
Copy link
Member

fabaff commented Nov 25, 2017

Works fine for me on dev with the default configuration.

2017-11-25 16:58:06 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.miflora
2017-11-25 16:58:06 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=sensor.mi_flora_moisture, old_state=None, new_state=<state sensor.mi_flora_moisture=unknown; unit_of_measurement=%, friendly_name=Mi Flora Moisture @ 2017-11-25T16:58:06.670874+01:00>>
2017-11-25 16:58:06 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=sensor.mi_flora_light_intensity, old_state=None, new_state=<state sensor.mi_flora_light_intensity=unknown; unit_of_measurement=lux, friendly_name=Mi Flora Light intensity @ 2017-11-25T16:58:06.671482+01:00>>

Can you check if your sensor is detected?

$ bluetoothctl 
[NEW] Controller A3:A3:A0:B4:B4:B4 localhost.localdomain [default]
[NEW] Device C4:C5:E4:32:45:A4 Flower mate
Agent registered
[CHG] Device C4:C5:E4:32:45:A4 RSSI: -52

@tactmaster
Copy link
Author

tactmaster commented Nov 25, 2017

Yeap

$ bluetoothctl
[NEW] Controller 00:1A:7D:DA:71:0D pimund [default] 
# scan on
[NEW] Device C4:7C:8D:65:BD:4C Flower care
[CHG] Device C4:7C:8D:65:BD:4C RSSI: -88

(I have tired moving it closer no luck)
Also note the device is running firmware 3.1.8

@fabaff
Copy link
Member

fabaff commented Nov 26, 2017

Have you tried to disable the Bluetooth LE tracker? Also, keep in mind that it can take a while till the Mi Flora sensors are populated.

@tactmaster
Copy link
Author

I have no differnce and it been up for days now. Is there a way of getting more debug info. All I get is

Updating miflora sensor took longer than the scheduled update interval 0:00:30

@Frankster-NL
Copy link

I get the same error message since 0.58 but if I look at my influxdb values still come in rather frequently.

@ciotlosm
Copy link
Contributor

ciotlosm commented Dec 1, 2017

I have seen this problem in recent updates. With hassio afer a restart of bluetooth container I get data for a while until it gets stuck again

Later edit: Also found the below stacktrace in logs after a period of not working

Sun Dec 03 2017 07:20:46 GMT+0200 (EET)

Error looking up Bluetooth device
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/bluetooth/bluez.py", line 289, in _gethcisock
    sock = _bt.hci_open_dev (device_id)
_bluetooth.error: no available bluetoot devices

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/homeassistant/components/device_tracker/bluetooth_tracker.py", line 82, in update_bluetooth
    result = bluetooth.lookup_name(mac, timeout=5)
  File "/usr/lib/python3.6/site-packages/bluetooth/bluez.py", line 61, in lookup_name
    sock = _gethcisock ()
  File "/usr/lib/python3.6/site-packages/bluetooth/bluez.py", line 291, in _gethcisock
    raise BluetoothError ("error accessing bluetooth device")
bluetooth.btcommon.BluetoothError: error accessing bluetooth device

@fabaff
Copy link
Member

fabaff commented Dec 5, 2017

@eperdeme
Copy link

eperdeme commented Dec 6, 2017

Miflora python modules just been released to 0.2 which may help fix this due to the backend change.

@tactmaster
Copy link
Author

So upgrading to 0.2 worked.

I had to alter miflora.py with simple modifications and I had to hard code gatttool location.

I don't have hass installed from git so I can't set up a pull request. Also dealing with a pull request is prob more work than just fixing the code. :)

I wait for a proper fix but this should fix it :)

@ciotlosm
Copy link
Contributor

Any chance the fix would go into next HA release?

@ChristianKuehnel
Copy link
Contributor

ChristianKuehnel commented Dec 20, 2017

I just added a pull request to get the new version number in.

@tactmaster
I cannot hard-code the path to gatttool as this might vary on different operating systems. If gatttool is installed via your normal package manager I would expect it to be on the PATH somewhere.

edit

  • We did not change much on how data is read from the gatttool. So I would not expect any improvements there.
  • However we did add support for the bluepy Bluetooth library which should resolve quite a few problems. We can discuss if we want to Home Assistant to use this somehow...

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

Successfully merging a pull request may close this issue.

6 participants