andrew-codechimp / HA-Battery-Notes

A Home Assistant integration to provide battery notes of devices
MIT License
529 stars 92 forks source link

Refactor batteries library to allow multiple definitions for model #88

Closed codyc1515 closed 10 months ago

codyc1515 commented 10 months ago

Checklist

Is your feature request related to a problem? Please describe.

The definitions library of batteries is blowing out in size. I observed that some of my devices are already in that file but were not auto-detected simply due to differences in how different integrations, i.e. ZHA vs. Zigbee2MQTT, present models and manufacturers.

Describe the solution you'd like

Allow for one, or more, models and manufacturers against each key in the libraries definition file, e.g.

{
    "manufacturer": [
        "Xiaomi",
        "Aqara"
    ],
    "model": [
        "Aqara human body movement and illuminance sensor (RTCGQ11LM)",
        "RTCGQ11LM"
    ],
    "battery_type": "CR2450"
}

Or some similar format.

Describe alternatives you've considered

We could simply keep adding to the database but it's going to grow larger and more unmanageable over time, especially so if there were to say be a dropdown selection of models in the future to maybe choose from.

Additional context

.

WendelFelius commented 10 months ago

This would work for Philips / Signify Netherlands B.V. and IKEA / IKEA of Sweden devices too.

codyc1515 commented 10 months ago

Xiaomi and Aqara would be another similar pairing.

andrew-codechimp commented 10 months ago

This is something I've been thinking about as well but at the moment I'm not going to implement.

The library is under 30kb so no issues on performance yet.

The schema is complex enough for many to edit and I'm regularly adding missing commas, brackets etc. Adding array's will make my maintenance a lot harder. The json validator catches things but I don't want to be hard and reject submissions as I want to grow the library rather than having people lose interest.

I may implement a GitHub Issues form to submit new devices, this wouldn't be able to handle arrays.

I may change my mind in future though :)