Fix some sensor classes (#48254)

* Fix some sensor classes

* Tweak

* Tweak
This commit is contained in:
Erik Montnemery 2021-03-23 15:56:33 +01:00 committed by GitHub
parent 6932cf9534
commit a09c8eecb7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 88 additions and 61 deletions

View file

@ -8,7 +8,13 @@ from homeassistant.const import CONF_MONITORED_CONDITIONS
import homeassistant.helpers.config_validation as cv
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__)
@ -46,6 +52,11 @@ class RainCloudSensor(RainCloudEntity, SensorEntity):
"""Return the state of the sensor."""
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):
"""Get the latest data and updates the states."""
_LOGGER.debug("Updating RainCloud sensor: %s", self._name)