esphome / feature-requests

ESPHome Feature Request Tracker
https://esphome.io/
408 stars 26 forks source link

Add support for Airthings Wave (gen 1) #1467

Closed tiagofreire-pt closed 2 years ago

tiagofreire-pt commented 2 years ago

Describe the problem you have/What new integration you would like Add support for the simple Wave device, gen 1.

Please describe your use case for this integration and alternatives you've tried: This is another Radon measuring device, much simpler and cheaper. Only measures temperature, humidity, instantaneous radon decay, long term radon decay.

Additional context

100% Working implementation with ESP32: BLEUUID: https://github.com/tiagofreire-pt/AirthingsMQTT/blob/master/AirthingsMQTTBridge.ino#L84 References: https://github.com/tiagofreire-pt/AirthingsMQTT/blob/master/AirthingsMQTTBridge.ino#L114

ESPHome: Logs

[12:56:50][D][ble_client:045]: Found device at MAC address [00:81:F9:77:7F:11]
[12:56:50][I][ble_client:083]: Attempting BLE connection to 00:81:f9:77:7f:11
[12:56:51][I][airthings_wave_plus:013]: Connected successfully!
[12:56:52][I][ble_client:159]: Service UUID: 0x1800
[12:56:52][I][ble_client:160]:   start_handle: 0x1  end_handle: 0x7
[12:56:52][I][ble_client:339]:  characteristic 0x2A00, handle 0x3, properties 0x2
[12:56:52][I][ble_client:339]:  characteristic 0x2A01, handle 0x5, properties 0x2
[12:56:52][I][ble_client:339]:  characteristic 0x2A04, handle 0x7, properties 0x2
[12:56:52][I][ble_client:159]: Service UUID: 0x1801
[12:56:52][I][ble_client:160]:   start_handle: 0x8  end_handle: 0x8
[12:56:52][I][ble_client:159]: Service UUID: B42E1F6E-ADE7-11E4-89D3-123B93F75CBA
[12:56:52][I][ble_client:160]:   start_handle: 0x9  end_handle: 0x2c
[12:56:52][I][ble_client:339]:  characteristic 0x2A08, handle 0xb, properties 0xa
[12:56:53][I][ble_client:339]:  characteristic B42E24FA-ADE7-11E4-89D3-123B93F75CBA, handle 0xe, properties 0x2c
[12:56:53][I][ble_client:339]:  characteristic B42E27AC-ADE7-11E4-89D3-123B93F75CBA, handle 0x12, properties 0x10
[12:56:53][I][ble_client:339]:  characteristic B42E01AA-ADE7-11E4-89D3-123B93F75CBA, handle 0x16, properties 0x12
[12:56:53][I][ble_client:339]:  characteristic B42E1096-ADE7-11E4-89D3-123B93F75CBA, handle 0x1a, properties 0x12
[12:56:53][I][ble_client:339]:  characteristic B42E0A4C-ADE7-11E4-89D3-123B93F75CBA, handle 0x1e, properties 0x12
[12:56:53][I][ble_client:339]:  characteristic 0x2A6E, handle 0x22, properties 0x12
[12:56:53][I][ble_client:339]:  characteristic 0x2A6F, handle 0x26, properties 0x12
[12:56:53][I][ble_client:339]:  characteristic B42E1348-ADE7-11E4-89D3-123B93F75CBA, handle 0x2a, properties 0x12
[12:56:53][I][ble_client:159]: Service UUID: F000FFC0-0451-4000-B000-000000000000
[12:56:53][I][ble_client:339]:  characteristic F000FFC1-0451-4000-B000-000000000000, handle 0x2f, properties 0x1c
[12:56:53][I][ble_client:339]:  characteristic F000FFC2-0451-4000-B000-000000000000, handle 0x33, properties 0x1c
[12:56:53][I][ble_client:339]:  characteristic F000FFC3-0451-4000-B000-000000000000, handle 0x37, properties 0xc
[12:56:53][I][ble_client:159]: Service UUID: 0x180A
[12:56:53][I][ble_client:160]:   start_handle: 0x39  end_handle: 0xffff
[12:56:53][I][ble_client:339]:  characteristic 0x2A23, handle 0x3b, properties 0x2
[12:56:53][I][ble_client:339]:  characteristic 0x2A24, handle 0x3d, properties 0x2
[12:56:53][I][ble_client:339]:  characteristic 0x2A25, handle 0x3f, properties 0x2
[12:56:53][I][ble_client:339]:  characteristic 0x2A26, handle 0x41, properties 0x2

Config:

esp32_ble_tracker:

ble_client:
  - mac_address: 00:81:F9:77:7F:11
    id: airthings_01

sensor:
  - platform: airthings_wave_plus
    ble_client_id: airthings_01
    update_interval: 5min # default
    temperature:
      name: "Airthings Temperature"
    humidity:
      name: "Airthings Humidity"
    radon:
      name: "Airthings Radon"
    radon_long_term:
      name: "Airthings Radon Long Term"
arungpillai commented 2 years ago

Thanks for creating this issue, I bought two of them last week when there was a big sale. However, I am not able to connect wave or wave_mini using EP32. Kindly help add support to these devices too.

Wave-mini, don't allow me to save and install not sure if there is any mistake in the spell of the example and the actual class please check.

funroompc commented 2 years ago

I’m having similar issues with my original wave device too. It looks like there are different repositories for each of the different models (for integration with raspberry pi) https://github.com/airthings

hirofairlane commented 2 years ago

There were two versions of the wave devices there seem to be some changes in the data structure according to the own Airthings sample code https://github.com/Airthings/wave-reader I own one of each, tested both as a airthings_wave_plus and didn't worked

debsahu commented 2 years ago

tagging @jeromelaban because https://github.com/esphome/esphome/pull/1656

Any ideas of how to get Airthings Wave Gen 1 supported?

These UUIDs that are known to work from https://github.com/sabeechen/AirthingsMQTT

serviceUUID: b42e1f6e-ade7-11e4-89d3-123b93f75cba
charUUID: b42e01aa-ade7-11e4-89d3-123b93f75cba
radon24UUID: b42e01aa-ade7-11e4-89d3-123b93f75cba
radonLongTermUUID: b42e0a4c-ade7-11e4-89d3-123b93f75cba
datetimeUUID: ((uint32_t)0x2A08)
temperatureUUID: ((uint32_t)0x2A6E)
humidityUUID: ((uint32_t)0x2A6F)

Edit: based on Airthings/wave-reader Very similar to Wave Plus: struct.unpack("<4B8H", rawdata)

serviceUUID: b42e1f6e-ade7-11e4-89d3-123b93f75cba
charUUID: b42e4dcc-ade7-11e4-89d3-123b93f75cba
debsahu commented 2 years ago

For gen 1 wave one can just create custom BLE client sensor:

esp32_ble_tracker:

ble_client:
  - mac_address: AA:BB:CC:DD:EE:00
    id: airthings01

sensor:
  - platform: ble_client
    ble_client_id: airthings01
    name: "Radon Sensor: radon"
    service_uuid: 'b42e1f6e-ade7-11e4-89d3-123b93f75cba'
    characteristic_uuid: 'b42e01aa-ade7-11e4-89d3-123b93f75cba'
    icon: 'mdi:radioactive'
    unit_of_measurement: 'pCi/L'
    accuracy_decimals: 2
    lambda: |-
      return *((uint16_t*)(&x[0]))/37.0f;
  - platform: ble_client
    ble_client_id: airthings01
    name: "Radon Sensor: radon long term"
    service_uuid: 'b42e1f6e-ade7-11e4-89d3-123b93f75cba'
    characteristic_uuid: 'b42e0a4c-ade7-11e4-89d3-123b93f75cba'
    icon: 'mdi:radioactive'
    unit_of_measurement: 'pCi/L'
    accuracy_decimals: 2
    lambda: |-
      return *((uint16_t*)(&x[0]))/37.0f;
  - platform: ble_client
    ble_client_id: airthings01
    name: "Radon Sensor: temperature"
    service_uuid: 'b42e1f6e-ade7-11e4-89d3-123b93f75cba'
    characteristic_uuid: 2A6E
    unit_of_measurement: '°C'
    device_class: "temperature"
    accuracy_decimals: 1
    lambda: |-
      return *((uint16_t*)(&x[0]))/100.0f;
  - platform: ble_client
    ble_client_id: airthings01
    name: "Radon Sensor: humidity"
    service_uuid: 'b42e1f6e-ade7-11e4-89d3-123b93f75cba'
    characteristic_uuid: 2A6F
    unit_of_measurement: '%'
    device_class: "humidity"
    accuracy_decimals: 1
    lambda: |-
      return *((uint16_t*)(&x[0]))/100.0f;
hirofairlane commented 2 years ago

@debsahu Thanks a lot for the tip,

I tried it with my wave 1 and it kinda work, but it shows unknown most of the time, I guess that the device only sends data when there is a change on the value or sort of that. Anyway in HA the values are shown as unknown most of the time, I think that showing the latest reading would make it mostly usable. My biggest concern is that I'm used to Bq/m3 readings instead of pci/L, but I guess that some magic in the lambda part would make the deal.

In my wave 2 (the one with battery indicator) the structure and the uuid are not the same and it doesn't work, I could paste my log output if it can help.

wormiedk commented 2 years ago

I am trying to get my airthings wave gen 2 to work with ESPHOME. I tried with the airthingsplus code and the device is detected but then nothing more happens. Sensors are created but always "unknown". Tried above custom BLE code but get this:


[W][ble_sensor:119]: [Radon Sensor: radon long term] Cannot poll, not connected
[W][ble_sensor:119]: [Radon Sensor: radon] Cannot poll, not connected
[W][ble_sensor:119]: [Radon Sensor: temperature] Cannot poll, not connected

Now got

D][ble_client:047]: Found device at MAC address [F4:60:77:74:BA:D1]
[I][ble_client:085]: Attempting BLE connection to f4:60:77:74:ba:d1
[I][ble_sensor:033]: [Radon Sensor: radon] Connected successfully!
[I][ble_sensor:033]: [Radon Sensor: radon long term] Connected successfully!
[I][ble_sensor:033]: [Radon Sensor: temperature] Connected successfully!
[I][ble_sensor:033]: [Radon Sensor: humidity] Connected successfully!
[I][ble_client:161]: Service UUID: 0x1800
[I][ble_client:162]:   start_handle: 0x1  end_handle: 0x9
[I][ble_client:341]:  characteristic 0x2A00, handle 0x3, properties 0x2
[I][ble_client:341]:  characteristic 0x2A01, handle 0x5, properties 0x2
[I][ble_client:341]:  characteristic 0x2A04, handle 0x7, properties 0x2
[I][ble_client:341]:  characteristic 0x2AC9, handle 0x9, properties 0x2
[I][ble_client:161]: Service UUID: 0x1801
[I][ble_client:162]:   start_handle: 0xa  end_handle: 0xa
[I][ble_client:161]: Service UUID: B42E4A8E-ADE7-11E4-89D3-123B93F75CBA
[I][ble_client:162]:   start_handle: 0xb  end_handle: 0x16
[I][ble_client:341]:  characteristic B42E4DCC-ADE7-11E4-89D3-123B93F75CBA, handle 0xd, properties 0x2
[I][ble_client:341]:  characteristic B42E50D8-ADE7-11E4-89D3-123B93F75CBA, handle 0x10, properties 0x2c
[I][ble_client:341]:  characteristic B42E538A-ADE7-11E4-89D3-123B93F75CBA, handle 0x14, properties 0x10
[I][ble_client:161]: Service UUID: F000FFC0-0451-4000-B000-000000000000
[I][ble_client:162]:   start_handle: 0x17  end_handle: 0x23
[I][ble_client:341]:  characteristic F000FFC1-0451-4000-B000-000000000000, handle 0x19, properties 0x1c
[I][ble_client:341]:  characteristic F000FFC2-0451-4000-B000-000000000000, handle 0x1d, properties 0x1c
[I][ble_client:341]:  characteristic F000FFC5-0451-4000-B000-000000000000, handle 0x21, properties 0x14
[I][ble_client:161]: Service UUID: 0x180A
[I][ble_client:162]:   start_handle: 0x24  end_handle: 0xffff
[I][ble_client:341]:  characteristic 0x2A23, handle 0x26, properties 0x2
[I][ble_client:341]:  characteristic 0x2A24, handle 0x28, properties 0x2
[I][ble_client:341]:  characteristic 0x2A25, handle 0x2a, properties 0x2
[I][ble_client:341]:  characteristic 0x2A26, handle 0x2c, properties 0x2
[I][ble_client:341]:  characteristic 0x2A27, handle 0x2e, properties 0x2
[I][ble_client:341]:  characteristic 0x2A29, handle 0x30, properties 0x2
[D][sensor:113]: 'Radon Sensor: radon': Sending state nan pCi/L with 2 decimals of accuracy
[W][ble_sensor:051]: No sensor characteristic found at service B42E1F6E-ADE7-11E4-89D3-123B93F75CBA char B42E01AA-ADE7-11E4-89D3-123B93F75CBA
[D][sensor:113]: 'Radon Sensor: radon long term': Sending state nan pCi/L with 2 decimals of accuracy
[W][ble_sensor:051]: No sensor characteristic found at service B42E1F6E-ADE7-11E4-89D3-123B93F75CBA char B42E0A4C-ADE7-11E4-89D3-123B93F75CBA
[D][sensor:113]: 'Radon Sensor: temperature': Sending state nan °C with 1 decimals of accuracy
[W][ble_sensor:051]: No sensor characteristic found at service B42E1F6E-ADE7-11E4-89D3-123B93F75CBA char 0x2A6E
[D][sensor:113]: 'Radon Sensor: humidity': Sending state nan % with 1 decimals of accuracy
[W][ble_sensor:051]: No sensor characteristic found at service B42E1F6E-ADE7-11E4-89D3-123B93F75CBA char 0x2A6F
cjwazzy commented 2 years ago

I'll add another req for wave gen 1 support. Wave pro is expensive for radon only needs and mini is a simple device. Why support pro and mini but not the original device?

tsthst commented 2 years ago

I think that many of us have bought the cheaper Wave, just to be able to measure the radon levels. Would be very nice to be able to pull data from it, and have support via ESPHome :-) And unfortunately my programming skills are not good enough to make pull request and do it myself.

sorenbache commented 2 years ago

I also want to support the idea of ESPHome to support the Airthings Wave (not plus). That would be nice.

galambert75 commented 2 years ago

Same for Airthings Wave (not plus) v2.

galambert75 commented 2 years ago

Maybe possible to re-use code from this HA custom component.

sorenbache commented 2 years ago

I actually did my own custom component based on the esphome wave plus code (copy/pasted the code) and changed the uuid's to this

static const char *const SERVICE_UUID = "b42e4a8e-ade7-11e4-89d3-123b93f75cba"; static const char *const CHARACTERISTIC_UUID = "b42e4dcc-ade7-11e4-89d3-123b93f75cba";

And then just ignore the things that the non-plus version do not support like CO2 level.

cjwazzy commented 2 years ago

I actually did my own custom component based on the esphome wave plus code (copy/pasted the code) and changed the uuid's to this

static const char *const SERVICE_UUID = "b42e4a8e-ade7-11e4-89d3-123b93f75cba"; static const char *const CHARACTERISTIC_UUID = "b42e4dcc-ade7-11e4-89d3-123b93f75cba";

And then just ignore the things that the non-plus version do not support like CO2 level.

Are you able/willing to provide a little more detail about how you did this for those of us that are just learning some of the nuances of home automation?

Thanks for you contribution and time.

Sorry for the idiot level question.

systematicallyrandom commented 2 years ago

I actually did my own custom component based on the esphome wave plus code (copy/pasted the code) and changed the uuid's to this

static const char *const SERVICE_UUID = "b42e4a8e-ade7-11e4-89d3-123b93f75cba"; static const char *const CHARACTERISTIC_UUID = "b42e4dcc-ade7-11e4-89d3-123b93f75cba";

And then just ignore the things that the non-plus version do not support like CO2 level.

This makes me think it would be simple for someone, who knows what they are doing, to fix the official ESPHome integration with an additional Wave non-plus type.

galambert75 commented 2 years ago

I actually did my own custom component based on the esphome wave plus code (copy/pasted the code) and changed the uuid's to this static const char *const SERVICE_UUID = "b42e4a8e-ade7-11e4-89d3-123b93f75cba"; static const char *const CHARACTERISTIC_UUID = "b42e4dcc-ade7-11e4-89d3-123b93f75cba"; And then just ignore the things that the non-plus version do not support like CO2 level.

This makes me think it would be simple for someone, who knows what they are doing, to fix the official ESPHome integration with an additional Wave non-plus type.

In addition, Airthings has provided Python code for the Wave here

sorenbache commented 2 years ago

Are you able/willing to provide a little more detail about how you did this for those of us that are just learning some of the nuances of home automation?

So I do not have any development environment and wanted to use the easyness of ESPHome addon in HA to compile and deploy OTA.

I copied the emitted code from having aithings_wave_plus specified in the yaml-file. It was placed here

esphome/.esphome/build/temperaturer/src/esphome/components/airthings_wave_plus

I copied that folder and renamed it to some name, e.g. aithings_wave_plus_xx:

esphome/custom_components/airthings_wave_plus_xx

Make sure to also rename all names of files from airthings_wave_plus to airthings_wave_plus_xx. This includes namespace and TAG

Then I replaced the UUIDs as specified in the .h file with the ones I mentioned.

When this is done you should be able to change your yaml-file to include the reference to your own new custom component:

- platform: airthings_wave_plus_xx ble_client_id: airthings01 ...

funroompc commented 2 years ago

Was someone able to get this to work?

systematicallyrandom commented 2 years ago

Was someone able to get this to work?

Not me. I looked in the docs and there is still no plain Wave option, just there Wave Plus and Mini ones. I've been curious why the issue was closed when it wasn't actually resolved, especially since it seems too be an easy fix for someone who knows what they are doing.

funroompc commented 2 years ago

I tried the alternative offered but was unable to get it to work. Did anyone have any luck with the custom component?

sorenbache commented 2 years ago

Not me. I looked in the docs and there is still no plain Wave option, just there Wave Plus and Mini ones. I've been curious why the issue was closed when it wasn't actually resolved, especially since it seems too be an easy fix for someone who knows what they are doing.

I agree. Fair enough that it was tagged with 'alternative-offered', but it is not resolved and I think the alternative is quite a laborious one.

funroompc commented 2 years ago

Well, I tried the alternative and I was not able to get it to work. I will make another attempt this week and will post my work here. Just curious if someone got the alternative working