From 55664fff38ef0efb3e33815d231630104ee39d95 Mon Sep 17 00:00:00 2001 From: Malene Trab Date: Fri, 29 Dec 2023 11:50:22 +0000 Subject: [PATCH 1/4] Update Home Assistant version --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 8095aa3..8c9c2a0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ colorlog==6.8.0 -homeassistant==2023.10.1 +homeassistant==2023.12.4 pip>=21.0,<23.4 ruff==0.1.9 \ No newline at end of file From 01642df6431046ef7f261f030f8ad2a1df9af261 Mon Sep 17 00:00:00 2001 From: Malene Trab Date: Fri, 29 Dec 2023 11:50:34 +0000 Subject: [PATCH 2/4] Update pywebasto version --- custom_components/webastoconnect/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/webastoconnect/manifest.json b/custom_components/webastoconnect/manifest.json index fa0cb19..2507d8c 100644 --- a/custom_components/webastoconnect/manifest.json +++ b/custom_components/webastoconnect/manifest.json @@ -12,7 +12,7 @@ "iot_class": "cloud_polling", "issue_tracker": "https://github.com/MTrab/webastoconnect/issues", "requirements": [ - "pywebasto==0.1.0" + "pywebasto==1.0.0" ], "version": "0.1.1" } \ No newline at end of file From 3f0fed2a7a28b75bf94a4318ceb8a67ba8ef2da6 Mon Sep 17 00:00:00 2001 From: Malene Trab Date: Fri, 29 Dec 2023 12:39:10 +0000 Subject: [PATCH 3/4] Fixing device name --- custom_components/webastoconnect/binary_sensor.py | 2 +- custom_components/webastoconnect/number.py | 2 +- custom_components/webastoconnect/sensor.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/custom_components/webastoconnect/binary_sensor.py b/custom_components/webastoconnect/binary_sensor.py index 5ead607..3fbe6de 100644 --- a/custom_components/webastoconnect/binary_sensor.py +++ b/custom_components/webastoconnect/binary_sensor.py @@ -82,7 +82,7 @@ def __init__( self._attr_device_info = { "identifiers": {(DOMAIN, self.coordinator.cloud.device_id)}, - "name": self.name, + "name": self.coordinator.cloud.name, "model": "ThermoConnect", "manufacturer": "Webasto", } diff --git a/custom_components/webastoconnect/number.py b/custom_components/webastoconnect/number.py index fe495d7..6e14988 100644 --- a/custom_components/webastoconnect/number.py +++ b/custom_components/webastoconnect/number.py @@ -90,7 +90,7 @@ def __init__( self._attr_should_poll = False self._attr_device_info = { "identifiers": {(DOMAIN, self.coordinator.cloud.device_id)}, - "name": self.name, + "name": self.coordinator.cloud.name, "model": "ThermoConnect", "manufacturer": "Webasto", } diff --git a/custom_components/webastoconnect/sensor.py b/custom_components/webastoconnect/sensor.py index d32bb4b..205d7d9 100644 --- a/custom_components/webastoconnect/sensor.py +++ b/custom_components/webastoconnect/sensor.py @@ -108,7 +108,7 @@ def __init__( self._attr_device_info = { "identifiers": {(DOMAIN, self.coordinator.cloud.device_id)}, - "name": self.name, + "name": self.coordinator.cloud.name, "model": "ThermoConnect", "manufacturer": "Webasto", } From 240420e0fab280023eef6c6a50df59bc6e1d7edf Mon Sep 17 00:00:00 2001 From: Malene Trab Date: Fri, 29 Dec 2023 12:39:21 +0000 Subject: [PATCH 4/4] Add support for multiple outputs --- custom_components/webastoconnect/switch.py | 45 ++++++++++++++++------ 1 file changed, 34 insertions(+), 11 deletions(-) diff --git a/custom_components/webastoconnect/switch.py b/custom_components/webastoconnect/switch.py index 96c53dd..8a7ac42 100644 --- a/custom_components/webastoconnect/switch.py +++ b/custom_components/webastoconnect/switch.py @@ -25,19 +25,37 @@ key="main_output", name="Output", entity_category=None, - value_fn=lambda webasto: cast(bool, webasto.output), - command_fn=lambda webasto, state: webasto.set_output(state), - name_fn=lambda webasto: webasto.output_name, + value_fn=lambda webasto: cast(bool, webasto.output_main), + command_fn=lambda webasto, state: webasto.set_output_main(state), + name_fn=lambda webasto: webasto.output_main_name, entity_registry_enabled_default=True, ), WebastoConnectSwitchEntityDescription( key="ventilation_mode", name="Ventilation Mode", entity_category=EntityCategory.CONFIG, - value_fn=lambda webasto: cast(bool, webasto.isVentilation), + value_fn=lambda webasto: cast(bool, webasto.is_ventilation), command_fn=lambda webasto, state: webasto.ventilation_mode(state), entity_registry_enabled_default=False, ), + WebastoConnectSwitchEntityDescription( + key="aux1_output", + name="AUX1", + entity_category=None, + value_fn=lambda webasto: cast(bool, webasto.output_aux1), + command_fn=lambda webasto, state: webasto.set_output_aux1(state), + name_fn=lambda webasto: webasto.output_aux1_name, + entity_registry_enabled_default=True, + ), + WebastoConnectSwitchEntityDescription( + key="aux2_output", + name="AUX2", + entity_category=None, + value_fn=lambda webasto: cast(bool, webasto.output_aux2), + command_fn=lambda webasto, state: webasto.set_output_aux2(state), + name_fn=lambda webasto: webasto.output_aux2_name, + entity_registry_enabled_default=True, + ), ] @@ -48,11 +66,16 @@ async def async_setup_entry(hass, entry: ConfigEntry, async_add_devices): coordinator = hass.data[DOMAIN][entry.entry_id][ATTR_COORDINATOR] for swi in SWITCHES: - entity = WebastoConnectSwitch(swi, coordinator) - LOGGER.debug( - "Adding switch '%s' with entity_id '%s'", swi.name, entity.entity_id - ) - switches.append(entity) + LOGGER.debug("Testing '%s'", swi.name) + if ( + isinstance(swi.name_fn, type(None)) + or swi.name_fn(coordinator.cloud) is not False + ): + entity = WebastoConnectSwitch(swi, coordinator) + LOGGER.debug( + "Adding switch '%s' with entity_id '%s'", swi.name, entity.entity_id + ) + switches.append(entity) async_add_devices(switches) @@ -89,7 +112,7 @@ def __init__( self._attr_device_info = { "identifiers": {(DOMAIN, self.coordinator.cloud.device_id)}, - "name": self.name, + "name": self.coordinator.cloud.name, "model": "ThermoConnect", "manufacturer": "Webasto", } @@ -114,7 +137,7 @@ def _handle_states(self) -> None: self._attr_is_on = self.entity_description.value_fn(self.coordinator.cloud) if self.entity_description.key == "main_output": - if self.coordinator.cloud.isVentilation: + if self.coordinator.cloud.is_ventilation: self._attr_icon = "mdi:fan" if self._attr_is_on else "mdi:fan-off" else: self._attr_icon = (