home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
71.82k stars 30.08k forks source link

Support for Aranet2 #101212

Closed thecode closed 11 months ago

thecode commented 12 months ago

The problem

Hi @aschmitz,

I was contacted by Aranet manufacture (via a third party they cooperate with) and asked to add support for Aranet2 . This is a simpler device that doesn't have a CO2 & pressure sensors. I have protocol definitions both for Aranet2 & Aranet4. Devices uses the same service UUIDs so will be needed to be parsed on the same method to decide if it is an Aranet2 or Aranet4 device. I already have a modified Aranet4-Python which parse the Aranet2 correctly but I am not sure if they will be accepted by the package owner.

Currently as I see it there are two options:

I would like to discuss with you what is your preferred option, was triyng to catch you on lardbucket.org.

Please let me know if you preffer to try to add the support for Aranet2 in the existing Aranet4-Python or add a dedicated parser at Bluetooth Devices for Home Assistant. I can add myself as a codewoner to help with future issues. If you preffer to make a discussion here or any other method, let me know, my contact details are on my GitiHub Profile

Thanks.

What version of Home Assistant Core has the issue?

core-2023.9.2

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Aranet

Link to integration documentation on our website

https://www.home-assistant.io/integrations/aranet/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 12 months ago

Hey there @aschmitz, mind taking a look at this issue as it has been labeled with an integration (aranet) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `aranet` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign aranet` Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


aranet documentation aranet source (message by IssueLinks)

aschmitz commented 12 months ago

Hi, thanks for reaching out.

If the changes for Aranet4-Python aren't major (it sounds like they probably won't be, if they use the same service UUIDs?), I suspect that's probably the right route: even though the package will have a misleading name: it would be nice to have the standalone library and executable continue to be updated if that's feasible. That said, I'm not especially opposed to the other dedicated repository route if that doesn't pan out.

I'm also happy to have you add yourself as a codeowner - I really just got the Aranet4 integration working because I wanted it working, but if you've got a connection to the manufacturer, you may be better positioned to investigate any issues that arise. (Speaking of, do you know if the Aranet4 PRO also broadcasts BLE status information? It came up as a question in https://github.com/home-assistant/home-assistant.io/issues/28894, but I don't have one and it's a bit pricey just to solve a documentation question. :slightly_smiling_face:)

Anrijs commented 12 months ago

@aschmitz Latest version of aranet4 library (v2.2.2) supports Aranet2. After updating to v2.2.2, just don't show readings with value -1.

This could work (sensor.py):

def sensor_update_to_bluetooth_data_update(
    adv: Aranet4Advertisement,
) -> PassiveBluetoothDataUpdate:
    """Convert a sensor update to a Bluetooth data update."""
    data = {}
    names = {}
    descs = {}
    for key, desc in SENSOR_DESCRIPTIONS.items():
        tag = _device_key_to_bluetooth_entity_key(adv.device, key)
        val = getattr(adv.readings, key)
        if val != -1:
            data[tag] = val
            names[tag] = desc.name
            descs[tag] = desc
    return PassiveBluetoothDataUpdate(
        devices={adv.device.address: _sensor_device_info_to_hass(adv)},
        entity_descriptions=descs,
        entity_data=data,
        entity_names=names,
    )
thecode commented 12 months ago

@Anrijs thanks for the update, I didn't look at the latest aranet4 library, I was planning to check what is needed to add to support Aranet2 in your lib and make a PR there. I will make a PR add support for Aranet2 this weekend.