Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions homeassistant/components/devolo_home_control/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
DEVICE_CLASS_POWER,
DEVICE_CLASS_TEMPERATURE,
DEVICE_CLASS_VOLTAGE,
STATE_CLASS_MEASUREMENT,
STATE_CLASS_TOTAL_INCREASING,
SensorEntity,
)
from homeassistant.config_entries import ConfigEntry
Expand Down Expand Up @@ -162,10 +162,7 @@ def __init__(
)

if consumption == "total":
self._attr_state_class = STATE_CLASS_MEASUREMENT
self._attr_last_reset = device_instance.consumption_property[
element_uid
].total_since
self._attr_state_class = STATE_CLASS_TOTAL_INCREASING

self._value = getattr(
device_instance.consumption_property[element_uid], consumption
Expand All @@ -180,15 +177,11 @@ def unique_id(self) -> str:

def _sync(self, message: tuple) -> None:
"""Update the consumption sensor state."""
if message[0] == self._attr_unique_id and message[2] != "total_since":
if message[0] == self._attr_unique_id:
self._value = getattr(
self._device_instance.consumption_property[self._attr_unique_id],
self._sensor_type,
)
elif message[0] == self._attr_unique_id and message[2] == "total_since":
self._attr_last_reset = self._device_instance.consumption_property[
self._attr_unique_id
].total_since
else:
self._generic_message(message)
self.schedule_update_ha_state()