hatasmota icon indicating copy to clipboard operation
hatasmota copied to clipboard

Sensor unit discovery for multi value sensor

Open pawelka opened this issue 3 years ago • 0 comments

I'm trying to use https://tasmota.github.io/docs/Smart-Meter-Interface for PV inverter and I have script that shows sensors in HA, but there is an issue is with unit and icons, which only work when name is exact as configured in SENSOR_UNIT_MAP (sensor.py). It means that I can have for example "Voltage" sensor only one, but in reality I have 5 voltage sensor 2 on DC site and 3 for AC site, so when I name "Voltage DC1" etc., standard sensor with unit ' ' is displayed.

The question is: Is it possible to add support for unit discovery if any on standard matching doesn't works? Means if unit not selected check if quantity String contains any of key for SENSOR_UNIT_MAP, if yes, unit is selected. This will allow to have multiple name for example "DC1 Voltage" or "Voltage DC1" or "Voltage.DC1" in any of those case "Voltage" unit will be selected.

I tried to analyse code and it's look like it's only option (correct me if I'm wrong), because units are not passed in "Tasmota integration", there are units passed in "HA integration", but this will require change in Tasmota for HA integration and I assume it will become obsolete in future, so I prefer find a solution for "Tasmota integration".

pawelka avatar Dec 05 '21 13:12 pawelka