Skip to content

Commit

Permalink
Updated "energySaved"
Browse files Browse the repository at this point in the history
"energySaved" sensor is now not even added to HA if it is not present
  • Loading branch information
veista committed Jan 6, 2022
1 parent 73a34cd commit 021ecb6
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions custom_components/smartthings/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -570,10 +570,14 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
]
)
elif capability == Capability.power_consumption_report:
reports = POWER_CONSUMPTION_REPORT_NAMES
if device.status.attributes["energySavingSupport"].value is False:
if "energySaved" in reports:
reports.remove("energySaved")
sensors.extend(
[
SmartThingsPowerConsumptionSensor(device, report_name)
for report_name in POWER_CONSUMPTION_REPORT_NAMES
for report_name in reports
]
)
else:
Expand Down Expand Up @@ -719,11 +723,6 @@ def available(self) -> bool:
value = self._device.status.attributes[Attribute.power_consumption].value
if value is None or value.get(self.report_name) is None:
return False
if (
self.report_name == "energySaved"
and self._device.status.attributes["energySavingSupport"].value is False
):
return False
return True

@property
Expand Down Expand Up @@ -757,4 +756,3 @@ def icon(self) -> str | None:
if self.report_name in ("deltaEnergy", "powerEnergy"):
return "mdi:current-ac"
return None

0 comments on commit 021ecb6

Please sign in to comment.