Replies: 2 comments 1 reply
-
The reason why the model aliases are not in model.json yet is because I wanted to eliminate unnecessary I/O as much as possible. To know all possible model aliases I have to load all model.json files before the setup procedure starts. So that's why aliases are here currently: https://github.com/bramstroker/homeassistant-powercalc/blob/master/custom_components/powercalc/aliases.py I agree it will be much cleaner when we can just add these aliases in the model.json files to have everything about the model together. I think I will revisit this in the nearby future as it makes a lot of sense to have this included in model.json. Maybe I will create an github action to write all the model aliases to a python dictionary to keep the zero IO approach, as the aliases only change when a PR is submitted. Currently you can already add more than 1 alias in aliases.py for a given model. However it is only an exact match. |
Beta Was this translation helpful? Give feedback.
-
I did a lot of work to refactor and cleanup some code regarding to the power profile library and added support to add aliases to the model.json files. See #942 Need to do some more work on it, but I think I might wrap it up today. Would you like to take on the task of moving the model aliases from |
Beta Was this translation helpful? Give feedback.
-
In #904 we talked a little about flags to help detect the right model for a LUT.
Annoyingly, with companies like Arlec, or Mirabella Genio; it's all Tuya under the hood; and their product numbers, model numbers vs what is presented through the various APIs all vary.
https://www.mirabellagenio.com.au/product-range/mirabella-genio-wi-fi-dimmable-5w-g95-filament-led-bulb/
Packaging, globe itself feature identifiers like:
Mirabella Genio Wi-Fi Dimmable 5W G95 ES CCT Filament LED Bulb
Item # I002747
Presented through the office Tuya integration, and viewing Devices > Device Diagnostics:
Via localtuya, with the cloud integration turned on:
While ideally this would be consistent, and everyone would just populate "model" with an agreed identifier... it's not.
I imagine a variety of other bulbs
Possible solutions
Directory structure - messy, likely to cause conflicts, etc.
An array of aliases? - this is better, as you get multiple possible matches; but if it's just an array of strings trying to map against model name; you can't look up other attributes
An array of alias regexps? - also good, allows wildcards, etc, possibly a bit of a pain encoding in JSON. Built in support in python; fairly well understood. Doesn't know about other attributes to look at though.
An array of JSONPaths? - More complicated; requires an external library, but https://pypi.org/project/jsonpath-ng/ does seem to support both paths and regex matchers:
How would the configuration flow work?
For each model.json, where !exact match, present a list of suggested matches based on .aliases.
Beta Was this translation helpful? Give feedback.
All reactions