Airthings / wave-reader

MIT License
50 stars 18 forks source link

2nd generation Airthings Wave not working #6

Closed RomanGar closed 4 years ago

RomanGar commented 4 years ago

I have purchased the 2nd generation Wave (model 2950) on beginning of December, with intention to integrate it in to the openHAB home automation. Unfortunately, wave_read.py does not work with this device. I tried to troubleshoot it a bit deeper and found that UUIDs that are used to retrieve date, humidity, temperature and radon values are reported as invalid by gatttool

The device itself presents as "Airthings Wave+" (uuid: 00002a00-0000-1000-8000-00805f9b34fb). So I tried it with read_waveplus.py script. but it does not work either.

Firmware was updated and currently is: MSP:1.1.2 CC:1.2.4

RomanGar commented 4 years ago

Here is the traceback from running read_wave.py

... [11:10:25] openhabian@openhab:~/bt$ sudo python2 read_wave.py 295000XXXX 120 Traceback (most recent call last): File "read_wave.py", line 197, in wave.connect() File "read_wave.py", line 150, in connect self.datetime_char = self.periph.getCharacteristics(uuid=self.UUID_DATETIME)[0] File "/usr/local/lib/python2.7/dist-packages/bluepy/btle.py", line 475, in getCharacteristics rsp = self._getResp('find') File "/usr/local/lib/python2.7/dist-packages/bluepy/btle.py", line 377, in _getResp resp = self._waitResp(wantType + ['ntfy', 'ind'], timeout) File "/usr/local/lib/python2.7/dist-packages/bluepy/btle.py", line 340, in _waitResp raise BTLEException(BTLEException.COMM_ERROR, "Error from Bluetooth stack (%s)" % errcode) bluepy.btle.BTLEException: Error from Bluetooth stack (comerr) ...

RomanGar commented 4 years ago

running on Raspberry Pi 4 Linux openhab 4.19.75-v7l+ #1270 SMP Tue Sep 24 18:51:41 BST 2019 armv7l GNU/Linux bluepy is at vesrion 1.2.0

RomanGar commented 4 years ago

from the traceback above it is apparent that read_wave.py fails upon attempting to read the DATETIME UUID, which suppose to be at 0x2a08, but there is no UUID that starts with 0x2a08, when available characteristics are listed with gatttool __handle: 0x0001, uuid: 00002800-0000-1000-8000-00805f9b34fb handle: 0x0002, uuid: 00002803-0000-1000-8000-00805f9b34fb handle: 0x0003, uuid: 00002a00-0000-1000-8000-00805f9b34fb handle: 0x0004, uuid: 00002803-0000-1000-8000-00805f9b34fb handle: 0x0005, uuid: 00002a01-0000-1000-8000-00805f9b34fb handle: 0x0006, uuid: 00002803-0000-1000-8000-00805f9b34fb handle: 0x0007, uuid: 00002a04-0000-1000-8000-00805f9b34fb handle: 0x0008, uuid: 00002803-0000-1000-8000-00805f9b34fb handle: 0x0009, uuid: 00002ac9-0000-1000-8000-00805f9b34fb handle: 0x000a, uuid: 00002800-0000-1000-8000-00805f9b34fb handle: 0x000b, uuid: 00002800-0000-1000-8000-00805f9b34fb handle: 0x000c, uuid: 00002803-0000-1000-8000-00805f9b34fb handle: 0x000d, uuid: b42e4dcc-ade7-11e4-89d3-123b93f75cba handle: 0x000e, uuid: 00002901-0000-1000-8000-00805f9b34fb handle: 0x000f, uuid: 00002803-0000-1000-8000-00805f9b34fb handle: 0x0010, uuid: b42e50d8-ade7-11e4-89d3-123b93f75cba handle: 0x0011, uuid: 00002901-0000-1000-8000-00805f9b34fb handle: 0x0012, uuid: 00002902-0000-1000-8000-00805f9b34fb handle: 0x0013, uuid: 00002803-0000-1000-8000-00805f9b34fb handle: 0x0014, uuid: b42e538a-ade7-11e4-89d3-123b93f75cba handle: 0x0015, uuid: 00002901-0000-1000-8000-00805f9b34fb handle: 0x0016, uuid: 00002902-0000-1000-8000-00805f9b34fb handle: 0x0017, uuid: 00002800-0000-1000-8000-00805f9b34fb handle: 0x0018, uuid: 00002803-0000-1000-8000-00805f9b34fb handle: 0x0019, uuid: f000ffc1-0451-4000-b000-000000000000 handle: 0x001a, uuid: 00002902-0000-1000-8000-00805f9b34fb handle: 0x001b, uuid: 00002901-0000-1000-8000-00805f9b34fb handle: 0x001c, uuid: 00002803-0000-1000-8000-00805f9b34fb handle: 0x001d, uuid: f000ffc2-0451-4000-b000-000000000000 handle: 0x001e, uuid: 00002902-0000-1000-8000-00805f9b34fb handle: 0x001f, uuid: 00002901-0000-1000-8000-00805f9b34fb handle: 0x0020, uuid: 00002803-0000-1000-8000-00805f9b34fb handle: 0x0021, uuid: f000ffc5-0451-4000-b000-000000000000 handle: 0x0022, uuid: 00002902-0000-1000-8000-00805f9b34fb handle: 0x0023, uuid: 00002901-0000-1000-8000-00805f9b34fb handle: 0x0024, uuid: 00002800-0000-1000-8000-00805f9b34fb handle: 0x0025, uuid: 00002803-0000-1000-8000-00805f9b34fb handle: 0x0026, uuid: 00002a23-0000-1000-8000-00805f9b34fb handle: 0x0027, uuid: 00002803-0000-1000-8000-00805f9b34fb handle: 0x0028, uuid: 00002a24-0000-1000-8000-00805f9b34fb handle: 0x0029, uuid: 00002803-0000-1000-8000-00805f9b34fb handle: 0x002a, uuid: 00002a25-0000-1000-8000-00805f9b34fb handle: 0x002b, uuid: 00002803-0000-1000-8000-00805f9b34fb handle: 0x002c, uuid: 00002a26-0000-1000-8000-00805f9b34fb handle: 0x002d, uuid: 00002803-0000-1000-8000-00805f9b34fb handle: 0x002e, uuid: 00002a27-0000-1000-8000-00805f9b34fb handle: 0x002f, uuid: 00002803-0000-1000-8000-00805f9b34fb handle: 0x0030, uuid: 00002a29-0000-1000-8000-00805f9b34fb

orjangj commented 4 years ago

Hi RomanGar,

Yes, there's currently no support for reading the sensor values from a 2nd generation Wave device.

However, with some small modification to the waveplus_reader.py script in the waveplus-reader repository, you should be able to get some readings.

In class WavePlus init method, change self.uuid to UUID("b42e4dcc-ade7-11e4-89d3-123b93f75cba")

Note that Wave 2nd generation does not have Pressure, CO2 and VOC readings. So you could optionally remove the code related to these values.

About the traceback: In my experience, instantiating a communication link between a raspberry pi and a BLE target using bluepy does not always succeed on the first try. Although the simple reader script does not provide exception handling, I suggest that you implement this yourself. Here's a small code snippet of how you could start handling exceptions.

` try:

1) connect to device

except Exception as e:

Maybe do some logging here?

# Note that this exception handler block catches all exceptions (even user errors).
# So you could limit the exceptions you catch to the ones raised by bluepy.

else:

This else-block is only executed if no exception is raised.

# 2) Read sensor values
# 3) print/log etc... sensor values
# 4) disconnect from device

time.sleep(...) `

RomanGar commented 4 years ago

Sorry for duplicate post, for some reason it did not show up when I logged in second time. Roman

RomanGar commented 4 years ago

Hi orjangj,

Thanks for quick response and the new UUID. I am aware that the 2nd generation Wave does not support barometric pressure, CO2 and VOC.

With the new UUID, the read_waveplus.py script seems to work as I am now getting readings for RH, Radon ST avg, Radon LT avg and Temperature. The pressure, CO2 and VOC readings show maximum sensor values, as expected.

Not sure how you are affiliated with Airthings, but do you know if there are any plans to improve integration of their sensors in to the home automation systems?

It would be nice if they publish some documentation, at least publishing/describing UUIDs for individual models and how values/descriptors are structured.

Thanks for your help, Roman

orjangj commented 4 years ago

Great that you got the script working :)

Regarding the last questions: I think it's best if you contact Airthings through Customer Service since I cannot answer these questions :/

orjangj commented 4 years ago

I'll mark this issue as resolved, since you got your custom script working.