Fix some sensor classes (#48254)
* Fix some sensor classes * Tweak * Tweak
This commit is contained in:
parent
6932cf9534
commit
a09c8eecb7
19 changed files with 88 additions and 61 deletions
|
@ -1,4 +1,5 @@
|
||||||
"""Abstraction form AEMET OpenData sensors."""
|
"""Abstraction form AEMET OpenData sensors."""
|
||||||
|
from homeassistant.components.sensor import SensorEntity
|
||||||
from homeassistant.const import ATTR_ATTRIBUTION
|
from homeassistant.const import ATTR_ATTRIBUTION
|
||||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||||
|
|
||||||
|
@ -6,7 +7,7 @@ from .const import ATTRIBUTION, SENSOR_DEVICE_CLASS, SENSOR_NAME, SENSOR_UNIT
|
||||||
from .weather_update_coordinator import WeatherUpdateCoordinator
|
from .weather_update_coordinator import WeatherUpdateCoordinator
|
||||||
|
|
||||||
|
|
||||||
class AbstractAemetSensor(CoordinatorEntity):
|
class AbstractAemetSensor(CoordinatorEntity, SensorEntity):
|
||||||
"""Abstract class for an AEMET OpenData sensor."""
|
"""Abstract class for an AEMET OpenData sensor."""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
|
|
|
@ -143,13 +143,6 @@ class HydrawiseEntity(Entity):
|
||||||
"""Call update method."""
|
"""Call update method."""
|
||||||
self.async_schedule_update_ha_state(True)
|
self.async_schedule_update_ha_state(True)
|
||||||
|
|
||||||
@property
|
|
||||||
def unit_of_measurement(self):
|
|
||||||
"""Return the units of measurement."""
|
|
||||||
return DEVICE_MAP[self._sensor_type][
|
|
||||||
DEVICE_MAP_INDEX.index("UNIT_OF_MEASURE_INDEX")
|
|
||||||
]
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def extra_state_attributes(self):
|
def extra_state_attributes(self):
|
||||||
"""Return the state attributes."""
|
"""Return the state attributes."""
|
||||||
|
|
|
@ -8,7 +8,7 @@ from homeassistant.const import CONF_MONITORED_CONDITIONS
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.util import dt
|
from homeassistant.util import dt
|
||||||
|
|
||||||
from . import DATA_HYDRAWISE, SENSORS, HydrawiseEntity
|
from . import DATA_HYDRAWISE, DEVICE_MAP, DEVICE_MAP_INDEX, SENSORS, HydrawiseEntity
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -44,6 +44,13 @@ class HydrawiseSensor(HydrawiseEntity, SensorEntity):
|
||||||
"""Return the state of the sensor."""
|
"""Return the state of the sensor."""
|
||||||
return self._state
|
return self._state
|
||||||
|
|
||||||
|
@property
|
||||||
|
def unit_of_measurement(self):
|
||||||
|
"""Return the units of measurement."""
|
||||||
|
return DEVICE_MAP[self._sensor_type][
|
||||||
|
DEVICE_MAP_INDEX.index("UNIT_OF_MEASURE_INDEX")
|
||||||
|
]
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
"""Get the latest data and updates the states."""
|
"""Get the latest data and updates the states."""
|
||||||
mydata = self.hass.data[DATA_HYDRAWISE].data
|
mydata = self.hass.data[DATA_HYDRAWISE].data
|
||||||
|
|
|
@ -6,6 +6,7 @@ from functools import partial
|
||||||
from pyiqvia import Client
|
from pyiqvia import Client
|
||||||
from pyiqvia.errors import IQVIAError
|
from pyiqvia.errors import IQVIAError
|
||||||
|
|
||||||
|
from homeassistant.components.sensor import SensorEntity
|
||||||
from homeassistant.const import ATTR_ATTRIBUTION
|
from homeassistant.const import ATTR_ATTRIBUTION
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
from homeassistant.helpers import aiohttp_client
|
from homeassistant.helpers import aiohttp_client
|
||||||
|
@ -109,7 +110,7 @@ async def async_unload_entry(hass, entry):
|
||||||
return unload_ok
|
return unload_ok
|
||||||
|
|
||||||
|
|
||||||
class IQVIAEntity(CoordinatorEntity):
|
class IQVIAEntity(CoordinatorEntity, SensorEntity):
|
||||||
"""Define a base IQVIA entity."""
|
"""Define a base IQVIA entity."""
|
||||||
|
|
||||||
def __init__(self, coordinator, entry, sensor_type, name, icon):
|
def __init__(self, coordinator, entry, sensor_type, name, icon):
|
||||||
|
|
|
@ -3,7 +3,6 @@ from statistics import mean
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
from homeassistant.components.sensor import SensorEntity
|
|
||||||
from homeassistant.const import ATTR_STATE
|
from homeassistant.const import ATTR_STATE
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
|
|
||||||
|
@ -99,7 +98,7 @@ def calculate_trend(indices):
|
||||||
return TREND_FLAT
|
return TREND_FLAT
|
||||||
|
|
||||||
|
|
||||||
class ForecastSensor(IQVIAEntity, SensorEntity):
|
class ForecastSensor(IQVIAEntity):
|
||||||
"""Define sensor related to forecast data."""
|
"""Define sensor related to forecast data."""
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
|
@ -138,7 +137,7 @@ class ForecastSensor(IQVIAEntity, SensorEntity):
|
||||||
self._state = average
|
self._state = average
|
||||||
|
|
||||||
|
|
||||||
class IndexSensor(IQVIAEntity, SensorEntity):
|
class IndexSensor(IQVIAEntity):
|
||||||
"""Define sensor related to indices."""
|
"""Define sensor related to indices."""
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
|
|
|
@ -363,11 +363,6 @@ class NestSensorDevice(Entity):
|
||||||
"""Return the name of the nest, if any."""
|
"""Return the name of the nest, if any."""
|
||||||
return self._name
|
return self._name
|
||||||
|
|
||||||
@property
|
|
||||||
def unit_of_measurement(self):
|
|
||||||
"""Return the unit the value is expressed in."""
|
|
||||||
return self._unit
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def should_poll(self):
|
def should_poll(self):
|
||||||
"""Do not need poll thanks using Nest streaming API."""
|
"""Do not need poll thanks using Nest streaming API."""
|
||||||
|
|
|
@ -153,6 +153,11 @@ async def async_setup_legacy_entry(hass, entry, async_add_entities):
|
||||||
class NestBasicSensor(NestSensorDevice, SensorEntity):
|
class NestBasicSensor(NestSensorDevice, SensorEntity):
|
||||||
"""Representation a basic Nest sensor."""
|
"""Representation a basic Nest sensor."""
|
||||||
|
|
||||||
|
@property
|
||||||
|
def unit_of_measurement(self):
|
||||||
|
"""Return the unit the value is expressed in."""
|
||||||
|
return self._unit
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def state(self):
|
def state(self):
|
||||||
"""Return the state of the sensor."""
|
"""Return the state of the sensor."""
|
||||||
|
@ -188,6 +193,11 @@ class NestTempSensor(NestSensorDevice, SensorEntity):
|
||||||
"""Return the state of the sensor."""
|
"""Return the state of the sensor."""
|
||||||
return self._state
|
return self._state
|
||||||
|
|
||||||
|
@property
|
||||||
|
def unit_of_measurement(self):
|
||||||
|
"""Return the unit the value is expressed in."""
|
||||||
|
return self._unit
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_class(self):
|
def device_class(self):
|
||||||
"""Return the device class of the sensor."""
|
"""Return the device class of the sensor."""
|
||||||
|
|
|
@ -7,6 +7,7 @@ from google_nest_sdm.device import Device
|
||||||
from google_nest_sdm.device_traits import HumidityTrait, TemperatureTrait
|
from google_nest_sdm.device_traits import HumidityTrait, TemperatureTrait
|
||||||
from google_nest_sdm.exceptions import GoogleNestException
|
from google_nest_sdm.exceptions import GoogleNestException
|
||||||
|
|
||||||
|
from homeassistant.components.sensor import SensorEntity
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
DEVICE_CLASS_HUMIDITY,
|
DEVICE_CLASS_HUMIDITY,
|
||||||
|
@ -15,7 +16,6 @@ from homeassistant.const import (
|
||||||
TEMP_CELSIUS,
|
TEMP_CELSIUS,
|
||||||
)
|
)
|
||||||
from homeassistant.exceptions import PlatformNotReady
|
from homeassistant.exceptions import PlatformNotReady
|
||||||
from homeassistant.helpers.entity import Entity
|
|
||||||
from homeassistant.helpers.typing import HomeAssistantType
|
from homeassistant.helpers.typing import HomeAssistantType
|
||||||
|
|
||||||
from .const import DATA_SUBSCRIBER, DOMAIN
|
from .const import DATA_SUBSCRIBER, DOMAIN
|
||||||
|
@ -53,7 +53,7 @@ async def async_setup_sdm_entry(
|
||||||
async_add_entities(entities)
|
async_add_entities(entities)
|
||||||
|
|
||||||
|
|
||||||
class SensorBase(Entity):
|
class SensorBase(SensorEntity):
|
||||||
"""Representation of a dynamically updated Sensor."""
|
"""Representation of a dynamically updated Sensor."""
|
||||||
|
|
||||||
def __init__(self, device: Device):
|
def __init__(self, device: Device):
|
||||||
|
|
|
@ -54,11 +54,6 @@ class OneWireBaseEntity(Entity):
|
||||||
"""Return the class of this device."""
|
"""Return the class of this device."""
|
||||||
return self._device_class
|
return self._device_class
|
||||||
|
|
||||||
@property
|
|
||||||
def unit_of_measurement(self) -> str | None:
|
|
||||||
"""Return the unit the value is expressed in."""
|
|
||||||
return self._unit_of_measurement
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def extra_state_attributes(self) -> dict[str, Any] | None:
|
def extra_state_attributes(self) -> dict[str, Any] | None:
|
||||||
"""Return the state attributes of the entity."""
|
"""Return the state attributes of the entity."""
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
"""Support for 1-Wire environment sensors."""
|
"""Support for 1-Wire environment sensors."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
from glob import glob
|
from glob import glob
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
@ -394,7 +396,16 @@ def get_entities(onewirehub: OneWireHub, config):
|
||||||
return entities
|
return entities
|
||||||
|
|
||||||
|
|
||||||
class OneWireProxySensor(OneWireProxyEntity, SensorEntity):
|
class OneWireSensor(OneWireBaseEntity, SensorEntity):
|
||||||
|
"""Mixin for sensor specific attributes."""
|
||||||
|
|
||||||
|
@property
|
||||||
|
def unit_of_measurement(self) -> str | None:
|
||||||
|
"""Return the unit the value is expressed in."""
|
||||||
|
return self._unit_of_measurement
|
||||||
|
|
||||||
|
|
||||||
|
class OneWireProxySensor(OneWireProxyEntity, OneWireSensor):
|
||||||
"""Implementation of a 1-Wire sensor connected through owserver."""
|
"""Implementation of a 1-Wire sensor connected through owserver."""
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -403,7 +414,7 @@ class OneWireProxySensor(OneWireProxyEntity, SensorEntity):
|
||||||
return self._state
|
return self._state
|
||||||
|
|
||||||
|
|
||||||
class OneWireDirectSensor(OneWireBaseEntity, SensorEntity):
|
class OneWireDirectSensor(OneWireSensor):
|
||||||
"""Implementation of a 1-Wire sensor directly connected to RPI GPIO."""
|
"""Implementation of a 1-Wire sensor directly connected to RPI GPIO."""
|
||||||
|
|
||||||
def __init__(self, name, device_file, device_info, owsensor):
|
def __init__(self, name, device_file, device_info, owsensor):
|
||||||
|
@ -431,7 +442,7 @@ class OneWireDirectSensor(OneWireBaseEntity, SensorEntity):
|
||||||
self._state = value
|
self._state = value
|
||||||
|
|
||||||
|
|
||||||
class OneWireOWFSSensor(OneWireBaseEntity, SensorEntity): # pragma: no cover
|
class OneWireOWFSSensor(OneWireSensor): # pragma: no cover
|
||||||
"""Implementation of a 1-Wire sensor through owfs.
|
"""Implementation of a 1-Wire sensor through owfs.
|
||||||
|
|
||||||
This part of the implementation does not conform to policy regarding 3rd-party libraries, and will not longer be updated.
|
This part of the implementation does not conform to policy regarding 3rd-party libraries, and will not longer be updated.
|
||||||
|
|
|
@ -160,11 +160,6 @@ class RainCloudEntity(Entity):
|
||||||
"""Call update method."""
|
"""Call update method."""
|
||||||
self.schedule_update_ha_state(True)
|
self.schedule_update_ha_state(True)
|
||||||
|
|
||||||
@property
|
|
||||||
def unit_of_measurement(self):
|
|
||||||
"""Return the units of measurement."""
|
|
||||||
return UNIT_OF_MEASUREMENT_MAP.get(self._sensor_type)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def extra_state_attributes(self):
|
def extra_state_attributes(self):
|
||||||
"""Return the state attributes."""
|
"""Return the state attributes."""
|
||||||
|
|
|
@ -8,7 +8,13 @@ from homeassistant.const import CONF_MONITORED_CONDITIONS
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.icon import icon_for_battery_level
|
from homeassistant.helpers.icon import icon_for_battery_level
|
||||||
|
|
||||||
from . import DATA_RAINCLOUD, ICON_MAP, SENSORS, RainCloudEntity
|
from . import (
|
||||||
|
DATA_RAINCLOUD,
|
||||||
|
ICON_MAP,
|
||||||
|
SENSORS,
|
||||||
|
UNIT_OF_MEASUREMENT_MAP,
|
||||||
|
RainCloudEntity,
|
||||||
|
)
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -46,6 +52,11 @@ class RainCloudSensor(RainCloudEntity, SensorEntity):
|
||||||
"""Return the state of the sensor."""
|
"""Return the state of the sensor."""
|
||||||
return self._state
|
return self._state
|
||||||
|
|
||||||
|
@property
|
||||||
|
def unit_of_measurement(self):
|
||||||
|
"""Return the units of measurement."""
|
||||||
|
return UNIT_OF_MEASUREMENT_MAP.get(self._sensor_type)
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
"""Get the latest data and updates the states."""
|
"""Get the latest data and updates the states."""
|
||||||
_LOGGER.debug("Updating RainCloud sensor: %s", self._name)
|
_LOGGER.debug("Updating RainCloud sensor: %s", self._name)
|
||||||
|
|
|
@ -267,11 +267,6 @@ class ShellyBlockAttributeEntity(ShellyBlockEntity, entity.Entity):
|
||||||
|
|
||||||
return self.description.value(value)
|
return self.description.value(value)
|
||||||
|
|
||||||
@property
|
|
||||||
def unit_of_measurement(self):
|
|
||||||
"""Return unit of sensor."""
|
|
||||||
return self._unit
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_class(self):
|
def device_class(self):
|
||||||
"""Device class of sensor."""
|
"""Device class of sensor."""
|
||||||
|
@ -348,11 +343,6 @@ class ShellyRestAttributeEntity(update_coordinator.CoordinatorEntity):
|
||||||
)
|
)
|
||||||
return self._last_value
|
return self._last_value
|
||||||
|
|
||||||
@property
|
|
||||||
def unit_of_measurement(self):
|
|
||||||
"""Return unit of sensor."""
|
|
||||||
return self.description.unit
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_class(self):
|
def device_class(self):
|
||||||
"""Device class of sensor."""
|
"""Device class of sensor."""
|
||||||
|
|
|
@ -212,6 +212,11 @@ class ShellySensor(ShellyBlockAttributeEntity, SensorEntity):
|
||||||
"""Return value of sensor."""
|
"""Return value of sensor."""
|
||||||
return self.attribute_value
|
return self.attribute_value
|
||||||
|
|
||||||
|
@property
|
||||||
|
def unit_of_measurement(self):
|
||||||
|
"""Return unit of sensor."""
|
||||||
|
return self._unit
|
||||||
|
|
||||||
|
|
||||||
class ShellyRestSensor(ShellyRestAttributeEntity, SensorEntity):
|
class ShellyRestSensor(ShellyRestAttributeEntity, SensorEntity):
|
||||||
"""Represent a shelly REST sensor."""
|
"""Represent a shelly REST sensor."""
|
||||||
|
@ -221,6 +226,11 @@ class ShellyRestSensor(ShellyRestAttributeEntity, SensorEntity):
|
||||||
"""Return value of sensor."""
|
"""Return value of sensor."""
|
||||||
return self.attribute_value
|
return self.attribute_value
|
||||||
|
|
||||||
|
@property
|
||||||
|
def unit_of_measurement(self):
|
||||||
|
"""Return unit of sensor."""
|
||||||
|
return self.description.unit
|
||||||
|
|
||||||
|
|
||||||
class ShellySleepingSensor(ShellySleepingBlockAttributeEntity, SensorEntity):
|
class ShellySleepingSensor(ShellySleepingBlockAttributeEntity, SensorEntity):
|
||||||
"""Represent a shelly sleeping sensor."""
|
"""Represent a shelly sleeping sensor."""
|
||||||
|
@ -232,3 +242,8 @@ class ShellySleepingSensor(ShellySleepingBlockAttributeEntity, SensorEntity):
|
||||||
return self.attribute_value
|
return self.attribute_value
|
||||||
|
|
||||||
return self.last_state
|
return self.last_state
|
||||||
|
|
||||||
|
@property
|
||||||
|
def unit_of_measurement(self):
|
||||||
|
"""Return unit of sensor."""
|
||||||
|
return self._unit
|
||||||
|
|
|
@ -72,7 +72,6 @@ from .const import (
|
||||||
STORAGE_VOL_SENSORS,
|
STORAGE_VOL_SENSORS,
|
||||||
SYNO_API,
|
SYNO_API,
|
||||||
SYSTEM_LOADED,
|
SYSTEM_LOADED,
|
||||||
TEMP_SENSORS_KEYS,
|
|
||||||
UNDO_UPDATE_LISTENER,
|
UNDO_UPDATE_LISTENER,
|
||||||
UTILISATION_SENSORS,
|
UTILISATION_SENSORS,
|
||||||
)
|
)
|
||||||
|
@ -631,13 +630,6 @@ class SynologyDSMBaseEntity(CoordinatorEntity):
|
||||||
"""Return the icon."""
|
"""Return the icon."""
|
||||||
return self._icon
|
return self._icon
|
||||||
|
|
||||||
@property
|
|
||||||
def unit_of_measurement(self) -> str:
|
|
||||||
"""Return the unit the value is expressed in."""
|
|
||||||
if self.entity_type in TEMP_SENSORS_KEYS:
|
|
||||||
return self.hass.config.units.temperature_unit
|
|
||||||
return self._unit
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_class(self) -> str:
|
def device_class(self) -> str:
|
||||||
"""Return the class of this device."""
|
"""Return the class of this device."""
|
||||||
|
|
|
@ -87,7 +87,18 @@ async def async_setup_entry(
|
||||||
async_add_entities(entities)
|
async_add_entities(entities)
|
||||||
|
|
||||||
|
|
||||||
class SynoDSMUtilSensor(SynologyDSMBaseEntity, SensorEntity):
|
class SynoDSMSensor(SynologyDSMBaseEntity):
|
||||||
|
"""Mixin for sensor specific attributes."""
|
||||||
|
|
||||||
|
@property
|
||||||
|
def unit_of_measurement(self) -> str:
|
||||||
|
"""Return the unit the value is expressed in."""
|
||||||
|
if self.entity_type in TEMP_SENSORS_KEYS:
|
||||||
|
return self.hass.config.units.temperature_unit
|
||||||
|
return self._unit
|
||||||
|
|
||||||
|
|
||||||
|
class SynoDSMUtilSensor(SynoDSMSensor, SensorEntity):
|
||||||
"""Representation a Synology Utilisation sensor."""
|
"""Representation a Synology Utilisation sensor."""
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -119,7 +130,7 @@ class SynoDSMUtilSensor(SynologyDSMBaseEntity, SensorEntity):
|
||||||
return bool(self._api.utilisation)
|
return bool(self._api.utilisation)
|
||||||
|
|
||||||
|
|
||||||
class SynoDSMStorageSensor(SynologyDSMDeviceEntity, SensorEntity):
|
class SynoDSMStorageSensor(SynologyDSMDeviceEntity, SynoDSMSensor, SensorEntity):
|
||||||
"""Representation a Synology Storage sensor."""
|
"""Representation a Synology Storage sensor."""
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -140,7 +151,7 @@ class SynoDSMStorageSensor(SynologyDSMDeviceEntity, SensorEntity):
|
||||||
return attr
|
return attr
|
||||||
|
|
||||||
|
|
||||||
class SynoDSMInfoSensor(SynologyDSMBaseEntity, SensorEntity):
|
class SynoDSMInfoSensor(SynoDSMSensor, SensorEntity):
|
||||||
"""Representation a Synology information sensor."""
|
"""Representation a Synology information sensor."""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
|
|
|
@ -967,11 +967,6 @@ class BaseWithingsSensor(Entity):
|
||||||
"""Return a unique, Home Assistant friendly identifier for this entity."""
|
"""Return a unique, Home Assistant friendly identifier for this entity."""
|
||||||
return self._unique_id
|
return self._unique_id
|
||||||
|
|
||||||
@property
|
|
||||||
def unit_of_measurement(self) -> str:
|
|
||||||
"""Return the unit of measurement of this entity, if any."""
|
|
||||||
return self._attribute.unit_of_measurement
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def icon(self) -> str:
|
def icon(self) -> str:
|
||||||
"""Icon to use in the frontend, if any."""
|
"""Icon to use in the frontend, if any."""
|
||||||
|
|
|
@ -35,3 +35,8 @@ class WithingsHealthSensor(BaseWithingsSensor, SensorEntity):
|
||||||
def state(self) -> None | str | int | float:
|
def state(self) -> None | str | int | float:
|
||||||
"""Return the state of the entity."""
|
"""Return the state of the entity."""
|
||||||
return self._state_data
|
return self._state_data
|
||||||
|
|
||||||
|
@property
|
||||||
|
def unit_of_measurement(self) -> str:
|
||||||
|
"""Return the unit of measurement of this entity, if any."""
|
||||||
|
return self._attribute.unit_of_measurement
|
||||||
|
|
|
@ -9,6 +9,7 @@ import xbee_helper.const as xb_const
|
||||||
from xbee_helper.device import convert_adc
|
from xbee_helper.device import convert_adc
|
||||||
from xbee_helper.exceptions import ZigBeeException, ZigBeeTxFailure
|
from xbee_helper.exceptions import ZigBeeException, ZigBeeTxFailure
|
||||||
|
|
||||||
|
from homeassistant.components.sensor import SensorEntity
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_ADDRESS,
|
CONF_ADDRESS,
|
||||||
CONF_DEVICE,
|
CONF_DEVICE,
|
||||||
|
@ -365,7 +366,7 @@ class XBeeDigitalOut(XBeeDigitalIn):
|
||||||
self._state = self._config.state2bool[pin_state]
|
self._state = self._config.state2bool[pin_state]
|
||||||
|
|
||||||
|
|
||||||
class XBeeAnalogIn(Entity):
|
class XBeeAnalogIn(SensorEntity):
|
||||||
"""Representation of a GPIO pin configured as an analog input."""
|
"""Representation of a GPIO pin configured as an analog input."""
|
||||||
|
|
||||||
def __init__(self, config, device):
|
def __init__(self, config, device):
|
||||||
|
|
Loading…
Add table
Reference in a new issue