Airthings / airthings-ble

Library to control Airthings devices through BLE, primarily meant to be used in Home Assistant.
MIT License
21 stars 11 forks source link

Fix Wave gen 1 name #10

Closed LaStrada closed 1 year ago

LaStrada commented 1 year ago

This PR fixes naming for Wave gen. 1 + improve data for other devices.

What's fixed

Additional data

Adding more data to the AirthingsDevice class:

Device name

Wave gen. 1

Wave gen 1 returned AT#123456-2900Radon (Serial Number) on Linux and (Serial Number) on Mac. This is not masked serial number, but for some reason it was Serial Number.

For those devices the serial number is part of the advertisement data, but I wasn't able to fetch it. But it's also part of the name of the device, so this is now fetched from the name.

Other devices

Linux:

Mac:

Made a fallback if the device has no name so it will now be Airthings <model>.

Examples:

Other fixes

How to test

I have created a test branch for this. Remember to install this airthings-ble. https://github.com/LaStrada/core/tree/imrpve-airthings-ble

LaStrada commented 1 year ago

Will this break the current airthings ble integration in Home Assistant? By changing name I can see that all sensors get a new name. E.g. sensor.humidity is now unavailable (can be deleted) and a new sensor.airthings_wave_gen_1_humidity has shown up.

This is probably a thing to be fixed in HA Core, but I'm not sure how to fix that.

Edit: this was fixed by introducing a friendly_name only for devices without a name, so Airthings BLE integration in Home Assistant can still use the device.name (same as before) and then no new entities will be created.

vincegio commented 1 year ago

Perfect, thanks :)