custom-components / sensor.airthings_wave

hassio support for Airthings Wave BLE environmental radon sensor.
MIT License
100 stars 28 forks source link

Failure to connect with HassOs + Airthings Wave Plus #24

Closed nullnullnul closed 4 years ago

nullnullnul commented 4 years ago

Raspberry Pi4 running HassOS latest Airthings Wave Plus sensor firmware updated + registered to cloud service Git clone 1.4.2020 of Airthings sensor

After configuration in Hassio, no sensors are visible. If MAC address is not declared in configuration.yaml, sensor is not found message is brought. In logs, it attempts to connect to 4 other Bluetooth devices but none with Airthings Wave Plus MAC address. When MAC address is declared in configuration.yaml following errors arise:

Logger: custom_components.airthings_wave.airthings Source: custom_components/airthings_wave/airthings.py:165 First occurred: 9.34.07 (4 occurrences) Last logged: 9.34.11

Traceback (most recent call last): File "/config/custom_components/airthings_wave/airthings.py", line 165, in get_info data = dev.char_read(characteristic.uuid) File "/usr/local/lib/python3.7/site-packages/pygatt/backends/gatttool/device.py", line 17, in wrapper return func(self, *args, kwargs) File "/usr/local/lib/python3.7/site-packages/pygatt/backends/gatttool/device.py", line 40, in char_read return self._backend.char_read(self, uuid, *args, *kwargs) File "/usr/local/lib/python3.7/site-packages/pygatt/backends/gatttool/gatttool.py", line 50, in wrapper return func(self, args, kwargs) File "/usr/local/lib/python3.7/site-packages/pygatt/backends/gatttool/gatttool.py", line 593, in char_read self.sendline('char-read-uuid %s' % uuid) File "/usr/local/lib/python3.7/contextlib.py", line 119, in exit next(self.gen) File "/usr/local/lib/python3.7/site-packages/pygatt/backends/gatttool/gatttool.py", line 191, in event self.wait(event, timeout) File "/usr/local/lib/python3.7/site-packages/pygatt/backends/gatttool/gatttool.py", line 157, in wait raise NotificationTimeout() pygatt.exceptions.NotificationTimeout: None

Setup of sensor platform airthings_wave is taking over 10 seconds.

Logger: custom_components.airthings_wave.airthings Source: custom_components/airthings_wave/airthings.py:183 First occurred: 9.41.26 (1 occurrences) Last logged: 9.41.26 Failed to discover sensors

Traceback (most recent call last): File "/config/custom_components/airthings_wave/airthings.py", line 183, in get_sensors characteristics = dev.discover_characteristics() File "/usr/local/lib/python3.7/site-packages/pygatt/backends/gatttool/device.py", line 17, in wrapper return func(self, *args, kwargs) File "/usr/local/lib/python3.7/site-packages/pygatt/backends/gatttool/device.py", line 58, in discover_characteristics self, *args, *kwargs) File "/usr/local/lib/python3.7/site-packages/pygatt/backends/gatttool/gatttool.py", line 50, in wrapper return func(self, args, kwargs) File "/usr/local/lib/python3.7/site-packages/pygatt/backends/gatttool/gatttool.py", line 531, in discover_characteristics raise NotConnectedError("Characteristic discovery failed") pygatt.exceptions.NotConnectedError: Characteristic discovery failed

MartyTremblay commented 4 years ago

Hi @nullnullnul

Thanks for the detailed info.

The only question I have is, how far is the device from your Pi? I've had better experience when it was just 2 or 3 meters away. I find that the Airthings Wave (and Plus) have a weak BLE signal.

nullnullnul commented 4 years ago

I think I need to retest this still more thoroughly, as I'm also facing issues outside HassOs with the sensor.

https://github.com/Airthings/waveplus-reader/issues/19

The distance does not matter here, from 5 cm to 10 m there seems to be a "luck" factor there if it connects or not.

nullnullnul commented 4 years ago

I've been logging in to HassOs score and initiated bluetoothctl / hcitool scans, both of these can identify the MAC address of the sensor, but still within HassOs the above failures are shown. Basically it seems that bluetooth connection is up and running.

MartyTremblay commented 4 years ago

Thanks for that info. I'm also facing the same issue with my regular wave but always assumed it was due to a hardware or kernel issue specific to my Odroid XU4 setup using a USB dongle.

Interesting to hear that the Pi is experiencing something similar. I hope that the Airthings folks can help resolve this.

kaareseras commented 4 years ago

I also cant connect, running Hassio

HassOS 3.13 Home Assistant 0.106.2 RPi 3b Airthing plus

2020-04-17 15:07:03 INFO (Thread-6) [pygatt.backends.gatttool.gatttool] Running... 2020-04-17 15:07:03 INFO (SyncWorker_14) [pygatt.backends.gatttool.gatttool] Connecting to b0:91:22:68:43:cc with timeout=3 2020-04-17 15:07:05 INFO (SyncWorker_14) [pygatt.backends.gatttool.gatttool] Stopping 2020-04-17 15:07:05 INFO (Thread-6) [pygatt.backends.gatttool.gatttool] Listener thread finished

goegsig commented 4 years ago

Log Details (ERROR)

Logger: custom_components.airthings_wave.airthings Source: custom_components/airthings_wave/airthings.py:162 First occurred: 8:27:27 PM (1 occurrences) Last logged: 8:27:27 PM

Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/pygatt/backends/gatttool/gatttool.py", line 415, in connect self.sendline(cmd) File "/usr/local/lib/python3.7/contextlib.py", line 119, in exit next(self.gen) File "/usr/local/lib/python3.7/site-packages/pygatt/backends/gatttool/gatttool.py", line 191, in event self.wait(event, timeout) File "/usr/local/lib/python3.7/site-packages/pygatt/backends/gatttool/gatttool.py", line 157, in wait raise NotificationTimeout() pygatt.exceptions.NotificationTimeout: None Traceback (most recent call last): File "/config/custom_components/airthings_wave/airthings.py", line 162, in get_info dev = self.adapter.connect(mac, 3) File "/usr/local/lib/python3.7/site-packages/pygatt/backends/gatttool/gatttool.py", line 421, in connect raise NotConnectedError(message) pygatt.exceptions.NotConnectedError: Timed out connecting to 00:81:f9:f0:5c:f9 after 3 seconds.

MartyTremblay commented 4 years ago

I had issues running on Odroid XU4 but I'm having much better success connecting my BLE dongle on an Odroid C2 and using https://github.com/lukas-hetzenecker/home-assistant-remote to pull the data back into my main HA on the XU4.

Hard to determine root cause since the underlying problem seems to be low level with the kernel or hardware. That being said, I'm surprised that you're both having issues with built-in BLE on a RPi 3+ or 4 as other people have reported good success with these platforms.

goegsig commented 4 years ago

Mine is a Rpi 4, 4gb ram

arch aarch64
dev false
docker true
hassio true
os_name Linux
os_version 4.19.114-v8
python_version 3.7.7
timezone Europe/Copenhagen
version 0.108.8
virtualenv false
nullnullnul commented 4 years ago

This remains still unsovled, but I was able to satisfy my needs by using this code from https://github.com/hpeyerl/airthingswave-mqtt. I am now able to collect data from another Raspberry Pi which is connected to Airthings device and then send it as MQTT messages to Hassio Mosquitto Broker running in my HassOs Pi. There is one extra step, but at least it works so far.

MartyTremblay commented 4 years ago

Thanks for the update @nullnullnul . The project airthingswave-mqtt uses bluepy rather than pigatt. In retrospect, I wish I had used bluepy as well. If time permits, perhaps I, or someone else, can port this project to use bluepy. ;) ;)

jayscovill commented 4 years ago

Are there any plans to get this working with the Airthings Wave Plus?

Edit: Odd! Even though in the logs it says it couldn't find an Airthings device I do have sensors showing up in Home Assistant!

MartyTremblay commented 4 years ago

Closing this issue due to being stale. We can revisit if someone reports similar issues with newer HA releases.