Use _attr for Suez water (#57278)
parent
8275110c44
commit
3a2d6a6343
|
@ -11,12 +11,13 @@ from homeassistant.const import CONF_PASSWORD, CONF_USERNAME, VOLUME_LITERS
|
|||
import homeassistant.helpers.config_validation as cv
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
CONF_COUNTER_ID = "counter_id"
|
||||
|
||||
SCAN_INTERVAL = timedelta(hours=12)
|
||||
|
||||
COMPONENT_ICON = "mdi:water-pump"
|
||||
COMPONENT_NAME = "Suez Water Client"
|
||||
CONF_COUNTER_ID = "counter_id"
|
||||
|
||||
NAME = "Suez Water Client"
|
||||
ICON = "mdi:water-pump"
|
||||
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||
{
|
||||
|
@ -49,6 +50,10 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
|||
class SuezSensor(SensorEntity):
|
||||
"""Representation of a Sensor."""
|
||||
|
||||
_attr_name = NAME
|
||||
_attr_icon = ICON
|
||||
_attr_native_unit_of_measurement = VOLUME_LITERS
|
||||
|
||||
def __init__(self, client):
|
||||
"""Initialize the data object."""
|
||||
self._attributes = {}
|
||||
|
@ -56,31 +61,16 @@ class SuezSensor(SensorEntity):
|
|||
self._available = None
|
||||
self.client = client
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""Return the name of the sensor."""
|
||||
return COMPONENT_NAME
|
||||
|
||||
@property
|
||||
def native_value(self):
|
||||
"""Return the state of the sensor."""
|
||||
return self._state
|
||||
|
||||
@property
|
||||
def native_unit_of_measurement(self):
|
||||
"""Return the unit of measurement."""
|
||||
return VOLUME_LITERS
|
||||
|
||||
@property
|
||||
def extra_state_attributes(self):
|
||||
"""Return the state attributes."""
|
||||
return self._attributes
|
||||
|
||||
@property
|
||||
def icon(self):
|
||||
"""Return the icon of the sensor."""
|
||||
return COMPONENT_ICON
|
||||
|
||||
def _fetch_data(self):
|
||||
"""Fetch latest data from Suez."""
|
||||
try:
|
||||
|
|
Loading…
Reference in New Issue