Add state class to Smart Meter Texas sensor (#55665)

This commit is contained in:
Adam Feldman 2021-09-09 08:32:03 -05:00 committed by GitHub
parent 9d2861afe3
commit cbbbc3c4f0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,8 +1,8 @@
"""Support for Smart Meter Texas sensors."""
from smart_meter_texas import Meter
from homeassistant.components.sensor import SensorEntity
from homeassistant.const import CONF_ADDRESS, ENERGY_KILO_WATT_HOUR
from homeassistant.components.sensor import STATE_CLASS_TOTAL_INCREASING, SensorEntity
from homeassistant.const import CONF_ADDRESS, DEVICE_CLASS_ENERGY, ENERGY_KILO_WATT_HOUR
from homeassistant.core import callback
from homeassistant.helpers.restore_state import RestoreEntity
from homeassistant.helpers.update_coordinator import (
@ -33,6 +33,8 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
class SmartMeterTexasSensor(CoordinatorEntity, RestoreEntity, SensorEntity):
"""Representation of an Smart Meter Texas sensor."""
_attr_device_class = DEVICE_CLASS_ENERGY
_attr_state_class = STATE_CLASS_TOTAL_INCREASING
_attr_native_unit_of_measurement = ENERGY_KILO_WATT_HOUR
def __init__(self, meter: Meter, coordinator: DataUpdateCoordinator) -> None: