From 70a3f764d4a5212bea3a9daa7ad25415293c1713 Mon Sep 17 00:00:00 2001 From: David Rapan Date: Mon, 16 Dec 2024 01:00:59 +0100 Subject: [PATCH] fix: Missing extra state attributes --- custom_components/solarman/entity.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/custom_components/solarman/entity.py b/custom_components/solarman/entity.py index 909c043..336a21c 100644 --- a/custom_components/solarman/entity.py +++ b/custom_components/solarman/entity.py @@ -79,7 +79,7 @@ def update(self): if "inverse" in self.attributes and self._attr_native_value: self._attr_extra_state_attributes["−x"] = -self._attr_native_value for attr in filter(lambda a: a in self.coordinator.data, self.attributes): - self._attr_extra_state_attributes[attr.replace(f"{self._attr_name} ", "")] = get_tuple(self.coordinator.data.get(attr)) + self._attr_extra_state_attributes[self.attributes[attr].replace(f"{self._attr_name} ", "")] = get_tuple(self.coordinator.data.get(attr)) class SolarmanEntity(SolarmanCoordinatorEntity): def __init__(self, coordinator, sensor): @@ -111,7 +111,7 @@ def __init__(self, coordinator, sensor): if description := sensor.get("description"): self._attr_extra_state_attributes = self._attr_extra_state_attributes | { "description": description } - self.attributes = sensor.get("attributes") + self.attributes = {slugify('_'.join(filter(None, (x, "sensor")))): x for x in attrs} if (attrs := sensor.get("attributes")) is not None else None self.registers = sensor.get("registers") def _friendly_name_internal(self) -> str | None: