Update powerwall to use CoordinatorEntity (#39389)

This commit is contained in:
J. Nick Koston authored and GitHub committed 2020-08-30 14:37:11 +02:00
1 parent ba75856f2b
commit f7d1cfb625
3 files changed
+10 -34

No files matched your search

+3 -3
View File
@@ -89,7 +89,7 @@ class PowerWallChargeSensor(PowerWallEntity):
@property
def state(self):
"""Get the current value in percentage."""
return self._coordinator.data[POWERWALL_API_CHARGE]
return self.coordinator.data[POWERWALL_API_CHARGE]
class PowerWallEnergySensor(PowerWallEntity):
@@ -134,7 +134,7 @@ class PowerWallEnergySensor(PowerWallEntity):
def state(self):
"""Get the current value in kW."""
return (
self._coordinator.data[POWERWALL_API_METERS]
self.coordinator.data[POWERWALL_API_METERS]
.get(self._meter)
.get_power(precision=3)
)
@@ -142,7 +142,7 @@ class PowerWallEnergySensor(PowerWallEntity):
@property
def device_state_attributes(self):
"""Return the device specific state attributes."""
meter = self._coordinator.data[POWERWALL_API_METERS].get(self._meter)
meter = self.coordinator.data[POWERWALL_API_METERS].get(self._meter)
return {
ATTR_FREQUENCY: round(meter.frequency, 1),
ATTR_ENERGY_EXPORTED: convert_to_kw(meter.energy_exported),