Powerwall sensor add is_active, round state attributes and change thresholding for charging status sensor (#34582)

* Change sensor values and thresholding

* Update tests
This commit is contained in:
jrester authored and Paulus Schoutsen committed 2020-04-23 12:57:54 -07:00
1 parent 370838ea7b
commit 7c54cd5583
4 files changed
+33 -34

No files matched your search

@@ -14,7 +14,6 @@ from .const import (
ATTR_GRID_CODE,
ATTR_NOMINAL_SYSTEM_POWER,
ATTR_REGION,
CHARGING_MARGIN_OF_ERROR,
DOMAIN,
POWERWALL_API_DEVICE_TYPE,
POWERWALL_API_GRID_STATUS,
@@ -139,7 +138,7 @@ class PowerWallGridStatusSensor(PowerWallEntity, BinarySensorDevice):
class PowerWallChargingStatusSensor(PowerWallEntity, BinarySensorDevice):
"""Representation of an Powerwall grid status sensor."""
"""Representation of an Powerwall charging status sensor."""
@property
def name(self):
@@ -158,10 +157,8 @@ class PowerWallChargingStatusSensor(PowerWallEntity, BinarySensorDevice):
@property
def is_on(self):
"""Grid is online."""
return (
self._coordinator.data[POWERWALL_API_METERS][
POWERWALL_BATTERY_METER
].instant_power
< CHARGING_MARGIN_OF_ERROR
)
"""Powerwall is charging."""
# is_sending_to returns true for values greater than 100 watts
return self._coordinator.data[POWERWALL_API_METERS][
POWERWALL_BATTERY_METER
].is_sending_to()