Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add AUX outputs #25

Merged
merged 4 commits into from
Dec 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion custom_components/webastoconnect/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}
Expand Down
2 changes: 1 addition & 1 deletion custom_components/webastoconnect/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
2 changes: 1 addition & 1 deletion custom_components/webastoconnect/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}
Expand Down
2 changes: 1 addition & 1 deletion custom_components/webastoconnect/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}
Expand Down
45 changes: 34 additions & 11 deletions custom_components/webastoconnect/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
]


Expand All @@ -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)

Expand Down Expand Up @@ -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",
}
Expand All @@ -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 = (
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -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
Loading