diff --git a/custom_components/weishaupt_modbus/number.py b/custom_components/weishaupt_modbus/number.py index 8c2055e..0effcd7 100644 --- a/custom_components/weishaupt_modbus/number.py +++ b/custom_components/weishaupt_modbus/number.py @@ -42,6 +42,7 @@ async def async_setup_entry( HK_Raum_Soll_Normal(host, port), HK_Raum_Soll_Absenk(host, port), HK_Heizkennlinie(host, port), + HK_SommerWinterUmschaltung(host, port), ], update_before_add=True, ) @@ -398,3 +399,46 @@ def device_info(self) -> DeviceInfo: return { "identifiers": {(DOMAIN, "Heizkreis")}, } + + +class HK_SommerWinterUmschaltung(NumberEntity): + """Representation of a WEM Portal number.""" + + _attr_name = "HK Sommer Winter Umschaltung" + _attr_unique_id = DOMAIN + _attr_name + _attr_native_value = 0 + _attr_should_poll = True + _attr_native_min_value = 3 + _attr_native_max_value = 30 + _attr_native_step = 0.5 + _attr_native_unit_of_measurement = UnitOfTemperature.CELSIUS + + def __init__(self, host, port) -> None: + """Init.""" + self._host = host + self._port = port + # whp = wp.heat_pump(host, port) + # whp.connect() + # self._attr_native_value = whp.WW_Absenk + # self.async_write_ha_state() + + async def async_set_native_value(self, value: float) -> None: + """Update the current value.""" + whp = wp.heat_pump(self._host, self._port) + whp.connect() + whp.HK_SommerWinterUmschaltung = value + self._attr_native_value = whp.HK_SommerWinterUmschaltung + self.async_write_ha_state() + + async def async_update(self) -> None: + """Update Entity Only used by the generic entity update service.""" + whp = wp.heat_pump(self._host, self._port) + whp.connect() + self._attr_native_value = whp.HK_SommerWinterUmschaltung + + @property + def device_info(self) -> DeviceInfo: + """Information about this entity/device.""" + return { + "identifiers": {(DOMAIN, "Heizkreis")}, + } diff --git a/custom_components/weishaupt_modbus/wp.py b/custom_components/weishaupt_modbus/wp.py index 47a0eb0..42a21fa 100644 --- a/custom_components/weishaupt_modbus/wp.py +++ b/custom_components/weishaupt_modbus/wp.py @@ -363,6 +363,15 @@ def HK_Heizkennlinie(self): def HK_Heizkennlinie(self, value): self.WWP.write_register(41108, int(value * 100), slave=1) + @property + def HK_SommerWinterUmschaltung(self): + """Test.""" + return self.WWP.read_holding_registers(41109, slave=1).registers[0] / 10 + + @HK_SommerWinterUmschaltung.setter + def HK_SommerWinterUmschaltung(self, value): + self.WWP.write_register(41109, int(value * 10), slave=1) + ##################### # Warm Water # #####################