diff --git a/src/pyatmo/const.py b/src/pyatmo/const.py index f182dfc2..f4a3c2c8 100644 --- a/src/pyatmo/const.py +++ b/src/pyatmo/const.py @@ -88,6 +88,8 @@ SCHEDULES = "schedules" EVENTS = "events" +COMFORT = "comfort" +AWAY = "away" STATION_TEMPERATURE_TYPE = "temperature" STATION_PRESSURE_TYPE = "pressure" diff --git a/src/pyatmo/modules/legrand.py b/src/pyatmo/modules/legrand.py index 0fe68e4f..6b4c1f08 100644 --- a/src/pyatmo/modules/legrand.py +++ b/src/pyatmo/modules/legrand.py @@ -5,6 +5,7 @@ import logging from pyatmo.modules.module import ( + ApplianceTypeMixin, BatteryMixin, ContactorMixin, Dimmer, @@ -35,19 +36,19 @@ class NLT(FirmwareMixin, BatteryMixin, Module): """Legrand global remote control.""" -class NLP(Switch, HistoryMixin, PowerMixin, OffloadMixin, Module): +class NLP(Switch, HistoryMixin, PowerMixin, OffloadMixin, ApplianceTypeMixin, Module): """Legrand plug.""" -class NLPM(Switch): +class NLPM(Switch, ApplianceTypeMixin): """Legrand mobile plug.""" -class NLPO(ContactorMixin, OffloadMixin, Switch): +class NLPO(ContactorMixin, OffloadMixin, ApplianceTypeMixin, Switch): """Legrand contactor.""" -class NLPT(Switch): +class NLPT(Switch, ApplianceTypeMixin): """Legrand latching relay/teleruptor.""" @@ -107,7 +108,15 @@ class NLPS(FirmwareMixin, PowerMixin, EnergyMixin, Module): """Legrand / BTicino smart load shedder.""" -class NLC(FirmwareMixin, SwitchMixin, HistoryMixin, PowerMixin, OffloadMixin, Module): +class NLC( + FirmwareMixin, + SwitchMixin, + HistoryMixin, + PowerMixin, + OffloadMixin, + ApplianceTypeMixin, + Module, +): """Legrand / BTicino cable outlet.""" @@ -159,7 +168,9 @@ class NLTS(Module): """NLTS motion sensor.""" -class NLPD(FirmwareMixin, SwitchMixin, EnergyMixin, PowerMixin, Module): +class NLPD( + FirmwareMixin, SwitchMixin, EnergyMixin, PowerMixin, ApplianceTypeMixin, Module +): """NLPD dry contact.""" diff --git a/src/pyatmo/modules/module.py b/src/pyatmo/modules/module.py index b918c2b4..39aaaea6 100644 --- a/src/pyatmo/modules/module.py +++ b/src/pyatmo/modules/module.py @@ -41,6 +41,7 @@ "device_category", "device_type", "features", + "appliance_type", } @@ -286,7 +287,7 @@ def __init__(self, home: Home, module: ModuleT): """Initialize appliance type mixin.""" super().__init__(home, module) # type: ignore # mypy issue 4335 - self.appliance_type: str | None = None + self.appliance_type: str | None = module.get("appliance_type", None) class EnergyMixin(EntityBase): diff --git a/src/pyatmo/room.py b/src/pyatmo/room.py index f6229081..041c2d3e 100644 --- a/src/pyatmo/room.py +++ b/src/pyatmo/room.py @@ -34,6 +34,7 @@ class Room(NetatmoBase): reachable: bool | None = None therm_setpoint_temperature: float | None = None therm_setpoint_mode: str | None = None + therm_setpoint_fp: str | None = None therm_measured_temperature: float | None = None therm_setpoint_start_time: int | None = None therm_setpoint_end_time: int | None = None @@ -71,10 +72,14 @@ def update_topology(self, raw_data: RawData) -> None: def evaluate_device_type(self) -> None: """Evaluate the device type of the room.""" + has_radiator = False + for module in self.modules.values(): self.device_types.add(module.device_type) if module.device_category is not None: self.features.add(module.device_category.name) + if module.device_type == "NLC" and module.appliance_type == "radiator": + has_radiator = True if "OTM" in self.device_types: self.climate_type = DeviceType.OTM @@ -85,6 +90,8 @@ def evaluate_device_type(self) -> None: elif "BNS" in self.device_types: self.climate_type = DeviceType.BNS self.features.add("humidity") + elif "NLC" in self.device_types and has_radiator: + self.climate_type = DeviceType.NLC def update(self, raw_data: RawData) -> None: """Update room data.""" @@ -94,6 +101,7 @@ def update(self, raw_data: RawData) -> None: self.reachable = raw_data.get("reachable") self.therm_measured_temperature = raw_data.get("therm_measured_temperature") self.therm_setpoint_mode = raw_data.get("therm_setpoint_mode") + self.therm_setpoint_fp = raw_data.get("therm_setpoint_fp") self.therm_setpoint_temperature = raw_data.get("therm_setpoint_temperature") self.therm_setpoint_start_time = raw_data.get("therm_setpoint_start_time") self.therm_setpoint_end_time = raw_data.get("therm_setpoint_end_time") @@ -101,11 +109,12 @@ def update(self, raw_data: RawData) -> None: async def async_therm_manual( self, temp: float | None = None, + fp: str | None = None, end_time: int | None = None, ) -> None: """Set room temperature set point to manual.""" - await self.async_therm_set(MANUAL, temp, end_time) + await self.async_therm_set(MANUAL, temp, fp, end_time) async def async_therm_home(self, end_time: int | None = None) -> None: """Set room temperature set point to home.""" @@ -121,6 +130,7 @@ async def async_therm_set( self, mode: str, temp: float | None = None, + fp: str | None = None, end_time: int | None = None, ) -> None: """Set room temperature set point.""" @@ -133,12 +143,13 @@ async def async_therm_set( await self._async_set_thermpoint(mode, temp, end_time) else: - await self._async_therm_set(mode, temp, end_time) + await self._async_therm_set(mode, temp, fp, end_time) async def _async_therm_set( self, mode: str, temp: float | None = None, + fp: str | None = None, end_time: int | None = None, ) -> bool: """Set room temperature set point (OTM).""" @@ -158,6 +169,9 @@ async def _async_therm_set( if end_time: json_therm_set["rooms"][0]["therm_setpoint_end_time"] = end_time + if fp: + json_therm_set["rooms"][0]["therm_setpoint_fp"] = fp + return await self.home.async_set_state(json_therm_set) async def _async_set_thermpoint(