Add tolo sensor platform (#60308)
This commit is contained in:
parent
f2a44553d8
commit
3372288c88
6 changed files with 81 additions and 4 deletions
|
@ -1094,6 +1094,7 @@ omit =
|
|||
homeassistant/components/tolo/__init__.py
|
||||
homeassistant/components/tolo/climate.py
|
||||
homeassistant/components/tolo/light.py
|
||||
homeassistant/components/tolo/sensor.py
|
||||
homeassistant/components/tomato/device_tracker.py
|
||||
homeassistant/components/toon/__init__.py
|
||||
homeassistant/components/toon/binary_sensor.py
|
||||
|
|
|
@ -22,7 +22,7 @@ from homeassistant.helpers.update_coordinator import (
|
|||
|
||||
from .const import DEFAULT_RETRY_COUNT, DEFAULT_RETRY_TIMEOUT, DOMAIN
|
||||
|
||||
PLATFORMS = ["climate", "light"]
|
||||
PLATFORMS = ["climate", "light", "sensor"]
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
"config_flow": true,
|
||||
"documentation": "https://www.home-assistant.io/integrations/tolo",
|
||||
"requirements": [
|
||||
"tololib==0.1.0b2"
|
||||
"tololib==0.1.0b3"
|
||||
],
|
||||
"codeowners": [
|
||||
"@MatthiasLohr"
|
||||
|
|
76
homeassistant/components/tolo/sensor.py
Normal file
76
homeassistant/components/tolo/sensor.py
Normal file
|
@ -0,0 +1,76 @@
|
|||
"""TOLO Sauna (non-binary, general) sensors."""
|
||||
|
||||
from homeassistant.components.sensor import STATE_CLASS_MEASUREMENT, SensorEntity
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
DEVICE_CLASS_TEMPERATURE,
|
||||
ENTITY_CATEGORY_DIAGNOSTIC,
|
||||
PERCENTAGE,
|
||||
TEMP_CELSIUS,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from . import ToloSaunaCoordinatorEntity, ToloSaunaUpdateCoordinator
|
||||
from .const import DOMAIN
|
||||
|
||||
|
||||
async def async_setup_entry(
|
||||
hass: HomeAssistant,
|
||||
entry: ConfigEntry,
|
||||
async_add_entities: AddEntitiesCallback,
|
||||
) -> None:
|
||||
"""Set up (non-binary, general) sensors for TOLO Sauna."""
|
||||
coordinator = hass.data[DOMAIN][entry.entry_id]
|
||||
async_add_entities(
|
||||
[
|
||||
ToloWaterLevelSensor(coordinator, entry),
|
||||
ToloTankTemperatureSensor(coordinator, entry),
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
class ToloWaterLevelSensor(ToloSaunaCoordinatorEntity, SensorEntity):
|
||||
"""Sensor for tank water level."""
|
||||
|
||||
_attr_entity_category = ENTITY_CATEGORY_DIAGNOSTIC
|
||||
_attr_name = "Water Level"
|
||||
_attr_icon = "mdi:waves-arrow-up"
|
||||
_attr_state_class = STATE_CLASS_MEASUREMENT
|
||||
_attr_native_unit_of_measurement = PERCENTAGE
|
||||
|
||||
def __init__(
|
||||
self, coordinator: ToloSaunaUpdateCoordinator, entry: ConfigEntry
|
||||
) -> None:
|
||||
"""Initialize TOLO Sauna tank water level sensor entity."""
|
||||
super().__init__(coordinator, entry)
|
||||
|
||||
self._attr_unique_id = f"{entry.entry_id}_water_level"
|
||||
|
||||
@property
|
||||
def native_value(self) -> int:
|
||||
"""Return current tank water level."""
|
||||
return self.coordinator.data.status.water_level_percent
|
||||
|
||||
|
||||
class ToloTankTemperatureSensor(ToloSaunaCoordinatorEntity, SensorEntity):
|
||||
"""Sensor for tank temperature."""
|
||||
|
||||
_attr_entity_category = ENTITY_CATEGORY_DIAGNOSTIC
|
||||
_attr_name = "Tank Temperature"
|
||||
_attr_device_class = DEVICE_CLASS_TEMPERATURE
|
||||
_attr_state_class = STATE_CLASS_MEASUREMENT
|
||||
_attr_native_unit_of_measurement = TEMP_CELSIUS
|
||||
|
||||
def __init__(
|
||||
self, coordinator: ToloSaunaUpdateCoordinator, entry: ConfigEntry
|
||||
) -> None:
|
||||
"""Initialize TOLO Sauna tank temperature sensor entity."""
|
||||
super().__init__(coordinator, entry)
|
||||
|
||||
self._attr_unique_id = f"{entry.entry_id}_tank_temperature"
|
||||
|
||||
@property
|
||||
def native_value(self) -> int:
|
||||
"""Return current tank temperature."""
|
||||
return self.coordinator.data.status.tank_temperature
|
|
@ -2317,7 +2317,7 @@ tmb==0.0.4
|
|||
todoist-python==8.0.0
|
||||
|
||||
# homeassistant.components.tolo
|
||||
tololib==0.1.0b2
|
||||
tololib==0.1.0b3
|
||||
|
||||
# homeassistant.components.toon
|
||||
toonapi==0.2.1
|
||||
|
|
|
@ -1351,7 +1351,7 @@ tellduslive==0.10.11
|
|||
tesla-powerwall==0.3.12
|
||||
|
||||
# homeassistant.components.tolo
|
||||
tololib==0.1.0b2
|
||||
tololib==0.1.0b3
|
||||
|
||||
# homeassistant.components.toon
|
||||
toonapi==0.2.1
|
||||
|
|
Loading…
Add table
Reference in a new issue