Skip to content

Commit

Permalink
fix: Missing extra state attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
davidrapan committed Dec 16, 2024
1 parent 118e8f8 commit 70a3f76
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions custom_components/solarman/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 70a3f76

Please sign in to comment.