Add Device Type Energy to Srp Energy Sensor (#58147)

This commit is contained in:
Brig Lamoreaux
2021-10-21 08:35:59 +02:00
committed by GitHub
parent 62c20860ac
commit 50686bd06d
2 changed files with 24 additions and 3 deletions
+16 -2
View File
@@ -5,8 +5,12 @@ import logging
import async_timeout
from requests.exceptions import ConnectionError as ConnectError, HTTPError, Timeout
from homeassistant.components.sensor import SensorEntity
from homeassistant.const import ATTR_ATTRIBUTION, ENERGY_KILO_WATT_HOUR
from homeassistant.components.sensor import STATE_CLASS_TOTAL_INCREASING, SensorEntity
from homeassistant.const import (
ATTR_ATTRIBUTION,
DEVICE_CLASS_ENERGY,
ENERGY_KILO_WATT_HOUR,
)
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
from .const import (
@@ -137,6 +141,16 @@ class SrpEntity(SensorEntity):
"""Return if entity is available."""
return self.coordinator.last_update_success
@property
def device_class(self):
"""Return the device class."""
return DEVICE_CLASS_ENERGY
@property
def state_class(self):
"""Return the state class."""
return STATE_CLASS_TOTAL_INCREASING
async def async_added_to_hass(self):
"""When entity is added to hass."""
self.async_on_remove(