Air Quality Monitor/Radon Meter: Airthings Wave Plus

I had this working and stream was enabled… i think however that my airthings device may have some comms issues regarding the number of client registrations… I can’t even connect to it from my iPhone anymore…

The connection from my phone is flaky, but after a few retries it works. I will try stream again, but for now I will prioritize the bluetooth.
Thanks for testing!

Another pie to throw in the test pot is the Raspberry. Use the Pi as bridge and then over to MQTT… With this at least there is a little more control over bluez… that seemed to be the most reliable setup for me… I use a cuople of Raspberry pi’s to bridge my miflora sensors and then pump that into HA over MQTT… so the model is the same… In fact I remember now that when i tried to connect the miflora sensors directly to the NUC, it was a little hit and miss… I have atround 30 of those around the house, so it was definately not sensor hardware related… have a look here: https://github.com/hpeyerl/airthingswave-mqtt

and my last logs:

Update for sensor.airthings_long_term_radon fails
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

Nice! I’m using esphome for the mifloras, but that doesn’t support Airthings. I have the Wave Plus, do you know if that’s supported with https://github.com/hpeyerl/airthingswave-mqtt ?

if you build it… :slight_smile: I don’t really use esp, personally I prefer the control/versatility of the RPI Zero which are neother here nor there when it cmes to price copared to the ESP’s… but I am sure that if you add the libraries to the sketch you could get something up and running…

There may also be something in the timeout:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 279, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 461, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/airthings/sensor.py", line 127, in update
    self._reader.update()
  File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 240, in wrapper
    result = method(*args, **kwargs)
  File "/config/custom_components/airthings/sensor.py", line 65, in update
    device = adapter.connect(self._mac)
  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 RE:DA:CT:ED after 5.0 seconds.

Hi, Can someone help? I am still having some stability issues with this custom component.

Herwith the logs

Update for sensor.airthings_voc fails

1:55 PM custom_components/airthings/sensor.py (ERROR) - message first occurred at 1:20 PM and shows up 35 times

Timed out connecting to A4:DA:32:14:19:8D after 5.0 seconds.

1:55 PM custom_components/airthings/sensor.py (ERROR) - message first occurred at 1:20 PM and shows up 243 times

Update for sensor.airthings_humidity fails

1:55 PM custom_components/airthings/sensor.py (ERROR) - message first occurred at 1:20 PM and shows up 35 times

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

1:55 PM helpers/entity_platform.py (WARNING) - message first occurred at 1:20 PM and shows up 35 times

Update for sensor.airthings_long_term_radon fails

1:55 PM custom_components/airthings/sensor.py (ERROR) - message first occurred at 1:20 PM and shows up 35 times

Update for sensor.airthings_temperature_2 fails

1:55 PM custom_components/airthings/sensor.py (ERROR) - message first occurred at 1:20 PM and shows up 34 times

Update for sensor.airthings_pressure fails

1:55 PM custom_components/airthings/sensor.py (ERROR) - message first occurred at 1:20 PM and shows up 35 times

I’ve had the same issues with steam: interfering with bluetooth on a Pi4. Do you know of a fix or workaround? Thanks.

Unfortunately no :confused:

@MartyTremblay tired using your custom component with an airthings wave plus and I get all sensors except for Radon. Is this a known issue? Any ideas on where to start troubleshooting?

I have the sensor working without issues here, if you enable debug printout and attached them preferably here: https://github.com/custom-components/sensor.airthings_wave/issues
I can have a look.

to enable debug printout add this to your config file:

logs:
  custom_components.airthings_wave: debug
1 Like

Has anyone looked into enabling the data from the new Airthings Hub? The hub does the job of connecting to Bluetooth to relay the data from the Wave to the airthings servers.

2 Likes

Hi all,

I’m trying to get @MartyTremblay 's integration to work. I have the Airthings Wave (not the “plus” version). I am running HassIO with the latest version (109.2) on a Raspberry Pi with a BT dongle. I get this:

Log Details (ERROR)
Logger: pygatt.backends.gatttool.gatttool
Source: custom_components/airthings_wave/airthings.py:127
First occurred: 7:56:22 AM (1 occurrences)
Last logged: 7:56:22 AM

Unexpected error when scanning: Invalid device: Network is down
Connection lost. Reconnecting…

and this:

Log Details (ERROR)
Logger: custom_components.airthings_wave.sensor
Source: custom_components/airthings_wave/airthings.py:127
First occurred: 7:56:22 AM (1 occurrences)
Last logged: 7:56:22 AM

Failed intial setup.
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/pexpect/spawnbase.py", line 166, in read_nonblocking
    s = os.read(self.child_fd, size)
OSError: [Errno 5] I/O error

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/pexpect/expect.py", line 111, in expect_loop
    incoming = spawn.read_nonblocking(spawn.maxread, timeout)
  File "/usr/local/lib/python3.7/site-packages/pexpect/pty_spawn.py", line 485, in read_nonblocking
    return super(spawn, self).read_nonblocking(size)
  File "/usr/local/lib/python3.7/site-packages/pexpect/spawnbase.py", line 171, in read_nonblocking
    raise EOF('End Of File (EOF). Exception style platform.')
pexpect.exceptions.EOF: End Of File (EOF). Exception style platform.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/pygatt/backends/gatttool/gatttool.py", line 342, in scan
    scan.expect('foooooo', timeout=timeout)
  File "/usr/local/lib/python3.7/site-packages/pexpect/spawnbase.py", line 341, in expect
    timeout, searchwindowsize, async_)
  File "/usr/local/lib/python3.7/site-packages/pexpect/spawnbase.py", line 369, in expect_list
    return exp.expect_loop(timeout)
  File "/usr/local/lib/python3.7/site-packages/pexpect/expect.py", line 117, in expect_loop
    return self.eof(e)
  File "/usr/local/lib/python3.7/site-packages/pexpect/expect.py", line 63, in eof
    raise EOF(msg)
pexpect.exceptions.EOF: End Of File (EOF). Exception style platform.
<pexpect.pty_spawn.spawn object at 0x6c0374f0>
command: /usr/bin/hcitool
args: ['/usr/bin/hcitool', '-i', 'hci0', 'lescan']
buffer (last 100 chars): b''
before (last 100 chars): b'Invalid device: Network is down\r\n'
after: <class 'pexpect.exceptions.EOF'>
match: None
match_index: None
exitstatus: 1
flag_eof: True
pid: 295
child_fd: 31
closed: False
timeout: 30
delimiter: <class 'pexpect.exceptions.EOF'>
logfile: None
logfile_read: None
logfile_send: None
maxread: 2000
ignorecase: False
searchwindowsize: None
delaybeforesend: 0.05
delayafterclose: 0.1
delayafterterminate: 0.1
searcher: searcher_re:
    0: re.compile(b'foooooo')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/config/custom_components/airthings_wave/sensor.py", line 142, in setup_platform
    num_devices_found = airthingsdetect.find_devices()
  File "/config/custom_components/airthings_wave/airthings.py", line 127, in find_devices
    devices = self.adapter.scan(timeout=3)
  File "/usr/local/lib/python3.7/site-packages/pygatt/backends/gatttool/gatttool.py", line 353, in scan
    raise BLEError(message)
pygatt.exceptions.BLEError: Unexpected error when scanning: Invalid device: Network is down

Connection lost. Reconnecting…

Any idea? Thanks!

Gatttool is depracated, and I guess pygatt is also. Is Bluepy now the preferred method to connect?

I had problems with Airthings_wave and Airthings of connection errors, stack faults and eventually Raspberry will come to complete halt.

May 18 12:07:16 homeautomation hass[465]: 2020-05-18 12:07:16 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.airthings_temperature fails May 18 12:07:16 homeautomation hass[465]: Traceback (most recent call last): May 18 12:07:16 homeautomation hass[465]: File "/home/pi/.homeassistant/deps/lib/python3.7/site-packages/pygatt/backends/gatttool/gatttool.py", line 415, in connect May 18 12:07:16 homeautomation hass[465]: self.sendline(cmd) May 18 12:07:16 homeautomation hass[465]: File "/usr/lib/python3.7/contextlib.py", line 119, in __exit__ May 18 12:07:16 homeautomation hass[465]: next(self.gen) May 18 12:07:16 homeautomation hass[465]: File "/home/pi/.homeassistant/deps/lib/python3.7/site-packages/pygatt/backends/gatttool/gatttool.py", line 191, in event May 18 12:07:16 homeautomation hass[465]: self.wait(event, timeout) May 18 12:07:16 homeautomation hass[465]: File "/home/pi/.homeassistant/deps/lib/python3.7/site-packages/pygatt/backends/gatttool/gatttool.py", line 157, in wait May 18 12:07:16 homeautomation hass[465]: raise NotificationTimeout() May 18 12:07:16 homeautomation hass[465]: pygatt.exceptions.NotificationTimeout: None May 18 12:07:16 homeautomation hass[465]: During handling of the above exception, another exception occurred: May 18 12:07:16 homeautomation hass[465]: Traceback (most recent call last): May 18 12:07:16 homeautomation hass[465]: File "/usr/local/lib/python3.7/dist-packages/homeassistant/helpers/entity.py", line 279, in async_update_ha_state May 18 12:07:16 homeautomation hass[465]: await self.async_device_update() May 18 12:07:16 homeautomation hass[465]: File "/usr/local/lib/python3.7/dist-packages/homeassistant/helpers/entity.py", line 476, in async_device_update May 18 12:07:16 homeautomation hass[465]: await self.hass.async_add_executor_job(self.update) May 18 12:07:16 homeautomation hass[465]: File "/usr/lib/python3.7/concurrent/futures/thread.py", line 57, in run May 18 12:07:16 homeautomation hass[465]: result = self.fn(*self.args, **self.kwargs) May 18 12:07:16 homeautomation hass[465]: File "/home/pi/.homeassistant/custom_components/airthings/sensor.py", line 128, in update May 18 12:07:16 homeautomation hass[465]: self._reader.update() May 18 12:07:16 homeautomation hass[465]: File "/usr/local/lib/python3.7/dist-packages/homeassistant/util/__init__.py", line 240, in wrapper May 18 12:07:16 homeautomation hass[465]: result = method(*args, **kwargs) May 18 12:07:16 homeautomation hass[465]: File "/home/pi/.homeassistant/custom_components/airthings/sensor.py", line 66, in update May 18 12:07:16 homeautomation hass[465]: device = adapter.connect(self._mac,5) May 18 12:07:16 homeautomation hass[465]: File "/home/pi/.homeassistant/deps/lib/python3.7/site-packages/pygatt/backends/gatttool/gatttool.py", line 421, in connect May 18 12:07:16 homeautomation hass[465]: raise NotConnectedError(message) May 18 12:07:16 homeautomation hass[465]: pygatt.exceptions.NotConnectedError: Timed out connecting to 00:81:f9:f8:5c:bb after 5 seconds.

There is a parameter in starting pyGatt reset_on_start that will run
/bin/systemctl restart bluetooth /bin/hciconfig hci0 reset

From pygatt:
:param bool reset_on_start: Perhaps due to a bug in gatttol or pygatt, but if the bluez backend isn't restarted, it can sometimes lock up the computer when trying to make a connection to HCI device.

That is not normally set because it doesn’t work if Home Assistant does not have sudo-rights.
Not all installations have.

I changed the parameter from code and now it has been running one day without crashing. It still gives connection errors, but gatttool does not hang.

From airthings_wave/airthings.py:
``

adapter.start(reset_on_start=False)

         adapter.start(reset_on_start=True)

``

( WTF is this editor doing, writing log in without line-breaks even when it’s marked code, and when code has a comment #, it writes it as a headline?? )

Seems my Bluetooth is now working more reliable.

I think the most important change is I dropped BT connection speed a lot.

vi /usr/bin/btuart
/usr/bin/hciattach /dev/serial1 bcm43xx 921600 noflow - xx:xx:xx:xx:xx:xx
I changed 921600 -> 115200

It now been running 24h without any errors.

1 Like

I have an Airthings Hub and I’ve scanned it with nmap; it doesn’t show any open ports. No web API I can find to get data out of it for homeassistant, either. It only has IFTTT and I’ve never liked that service.

2 Likes

Do you know if having the Airthings Hub gives you access to the developer API or is that restricted to business accounts? I ask because I only see references to the API in the business area of the Airthings site. I also noticed the business hardware pack that includes the hub states it includes 1 year of service which also makes me think the API is restricted to business accounts.

Made an integration for Airthings cloud (so no Bluetooth):


It is still a work in progress
4 Likes

This it great. Thanks a lot!
Few comments/suggestions:

  • I can also see the TVOC measurement in the Airthings apps, so I guess a sensor could be added for that.
  • For the Radon sensor I customised the unit_of_measurment to: Bq/m³ (notice the raised 3) and the icon to mdi:radioactive. A bit harsh icon :slight_smile:, but is very close to the icon that Airthings uses themselves

Thanks for doing this! Happy to be a tester. i have two wave pluses and a hub incoming this weekend.

For those interested on integrating this sensor (gen1), through an ESP32 and MQTT, check this arduino sketch: https://github.com/tiagofreire-pt/AirthingsMQTT

Kudos to debsahu and sabeechen.

2 Likes