Presets for single ZONNSMART TRV (#67157)

* Presets for single ZONNSMART TRV

* added zonnsmart climate tests

* black8 fix
This commit is contained in:
rforro 2022-02-24 14:48:15 +01:00 committed by GitHub
parent 636e4ed90b
commit cbdfff25ca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 191 additions and 0 deletions

View file

@ -771,3 +771,68 @@ class StelproFanHeater(Thermostat):
def hvac_modes(self) -> tuple[str, ...]:
"""Return only the heat mode, because the device can't be turned off."""
return (HVAC_MODE_HEAT,)
@STRICT_MATCH(
channel_names=CHANNEL_THERMOSTAT,
manufacturers={
"_TZE200_hue3yfsn",
},
)
class ZONNSMARTThermostat(Thermostat):
"""
ZONNSMART Thermostat implementation.
Notice that this device uses two holiday presets (2: HolidayMode,
3: HolidayModeTemp), but only one of them can be set.
"""
PRESET_HOLIDAY = "holiday"
PRESET_FROST = "frost protect"
def __init__(self, unique_id, zha_device, channels, **kwargs):
"""Initialize ZHA Thermostat instance."""
super().__init__(unique_id, zha_device, channels, **kwargs)
self._presets = [
PRESET_NONE,
self.PRESET_HOLIDAY,
PRESET_SCHEDULE,
self.PRESET_FROST,
]
self._supported_flags |= SUPPORT_PRESET_MODE
async def async_attribute_updated(self, record):
"""Handle attribute update from device."""
if record.attr_name == "operation_preset":
if record.value == 0:
self._preset = PRESET_SCHEDULE
if record.value == 1:
self._preset = PRESET_NONE
if record.value == 2:
self._preset = self.PRESET_HOLIDAY
if record.value == 3:
self._preset = self.PRESET_HOLIDAY
if record.value == 4:
self._preset = self.PRESET_FROST
await super().async_attribute_updated(record)
async def async_preset_handler(self, preset: str, enable: bool = False) -> bool:
"""Set the preset mode."""
mfg_code = self._zha_device.manufacturer_code
if not enable:
return await self._thrm.write_attributes(
{"operation_preset": 1}, manufacturer=mfg_code
)
if preset == PRESET_SCHEDULE:
return await self._thrm.write_attributes(
{"operation_preset": 0}, manufacturer=mfg_code
)
if preset == self.PRESET_HOLIDAY:
return await self._thrm.write_attributes(
{"operation_preset": 3}, manufacturer=mfg_code
)
if preset == self.PRESET_FROST:
return await self._thrm.write_attributes(
{"operation_preset": 4}, manufacturer=mfg_code
)
return False