I would like to use external statistics in the energy dashboard (e.g. as energy consumption). But they are not shown in the list of entities to select.
Thx for the lightning-fast answer. Can I set the unit-class in the UI and/or Yaml configuration for an external statistic? Or do I have to set the unit-class in the integration creating the external statistics?
I did not find any docu how to determine the unit converter used for unit conversions
AI found STATISTIC_UNIT_TO_UNIT_CONVERTER :
def get_unit_class(unit: str | None) -> str | None:
"""
Resolve the unit_class for a given unit of measurement.
Uses Home Assistant's STATISTIC_UNIT_TO_UNIT_CONVERTER to find the converter
for the unit, then reverse-maps it to the unit_class string via
UNIT_CLASS_TO_UNIT_CONVERTER.
Args:
----
unit: The unit of measurement string (e.g., "kWh", "°C"), or None
Returns:
-------
str | None: The unit_class string (e.g., "energy", "temperature"),
or None if the unit has no compatible converter
"""
if unit is None:
return None
converter = STATISTIC_UNIT_TO_UNIT_CONVERTER.get(unit)
if converter is None:
return None
return _CONVERTER_TO_UNIT_CLASS.get(converter)