2024-02-22 22:09:38 +00:00
|
|
|
"""Implementation of humidity module."""
|
2024-04-16 18:21:20 +00:00
|
|
|
|
2024-04-17 13:39:24 +00:00
|
|
|
from __future__ import annotations
|
|
|
|
|
2024-02-22 22:09:38 +00:00
|
|
|
from typing import TYPE_CHECKING
|
|
|
|
|
2024-04-24 16:38:52 +00:00
|
|
|
from ...feature import Feature
|
2024-02-22 22:09:38 +00:00
|
|
|
from ..smartmodule import SmartModule
|
|
|
|
|
|
|
|
if TYPE_CHECKING:
|
|
|
|
from ..smartdevice import SmartDevice
|
|
|
|
|
|
|
|
|
|
|
|
class HumiditySensor(SmartModule):
|
|
|
|
"""Implementation of humidity module."""
|
|
|
|
|
|
|
|
REQUIRED_COMPONENT = "humidity"
|
|
|
|
QUERY_GETTER_NAME = "get_comfort_humidity_config"
|
|
|
|
|
2024-04-17 13:39:24 +00:00
|
|
|
def __init__(self, device: SmartDevice, module: str):
|
2024-02-22 22:09:38 +00:00
|
|
|
super().__init__(device, module)
|
|
|
|
self._add_feature(
|
|
|
|
Feature(
|
|
|
|
device,
|
2024-05-07 09:13:35 +00:00
|
|
|
id="humidity",
|
|
|
|
name="Humidity",
|
2024-02-22 22:09:38 +00:00
|
|
|
container=self,
|
|
|
|
attribute_getter="humidity",
|
|
|
|
icon="mdi:water-percent",
|
2024-05-02 13:05:26 +00:00
|
|
|
unit="%",
|
2024-05-07 09:13:35 +00:00
|
|
|
category=Feature.Category.Primary,
|
2024-02-22 22:09:38 +00:00
|
|
|
)
|
|
|
|
)
|
|
|
|
self._add_feature(
|
|
|
|
Feature(
|
|
|
|
device,
|
2024-05-07 09:13:35 +00:00
|
|
|
id="humidity_warning",
|
|
|
|
name="Humidity warning",
|
2024-02-22 22:09:38 +00:00
|
|
|
container=self,
|
|
|
|
attribute_getter="humidity_warning",
|
2024-04-24 16:38:52 +00:00
|
|
|
type=Feature.Type.BinarySensor,
|
2024-02-22 22:09:38 +00:00
|
|
|
icon="mdi:alert",
|
2024-05-07 09:13:35 +00:00
|
|
|
category=Feature.Category.Debug,
|
2024-02-22 22:09:38 +00:00
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
@property
|
|
|
|
def humidity(self):
|
|
|
|
"""Return current humidity in percentage."""
|
|
|
|
return self._device.sys_info["current_humidity"]
|
|
|
|
|
|
|
|
@property
|
|
|
|
def humidity_warning(self) -> bool:
|
|
|
|
"""Return true if humidity is outside of the wanted range."""
|
|
|
|
return self._device.sys_info["current_humidity_exception"] != 0
|