Skip to content

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Bre77 committed Feb 3, 2024
1 parent f74f91d commit 9c03472
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions custom_components/teslemetry/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
ENERGY_INFO_INTERVAL = timedelta(seconds=300)

def flatten(
self, data: dict[str, Any], parent: str | None = None
data: dict[str, Any], parent: str | None = None
) -> dict[str, Any]:
"""Flatten the data structure."""
result = {}
for key, value in data.items():
if parent:
key = f"{parent}_{key}"
if isinstance(value, dict):
result.update(self._flatten(value, key))
result.update(flatten(value, key))
else:
result[key] = value
return result
Expand Down
8 changes: 4 additions & 4 deletions custom_components/teslemetry/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ class TeslemetrySensorEntityDescription(SensorEntityDescription):
),
)

ENERGY_DESCRIPTIONS: tuple[SensorEntityDescription, ...] = (
ENERGY_LIVE_DESCRIPTIONS: tuple[SensorEntityDescription, ...] = (
SensorEntityDescription(
key="solar_power",
state_class=SensorStateClass.MEASUREMENT,
Expand Down Expand Up @@ -369,15 +369,15 @@ async def async_setup_entry(
async_add_entities(
TeslemetryEnergySensorEntity(energysite, description)
for energysite in data.energysites
for description in ENERGY_DESCRIPTIONS
if description.key in energysite.coordinator.data
for description in ENERGY_LIVE_DESCRIPTIONS
if description.key in energysite.live_coordinator.data
)

# Add wall connectors
async_add_entities(
TeslemetryWallConnectorSensorEntity(energysite, din, description)
for energysite in data.energysites
for din in energysite.coordinator.data.get("wall_connectors", {})
for din in energysite.live_coordinator.data.get("wall_connectors", {})
for description in WALL_CONNECTOR_DESCRIPTIONS
)

Expand Down

0 comments on commit 9c03472

Please sign in to comment.