From 6828f3e9a89f0667ea03196e5b0bba7cef097448 Mon Sep 17 00:00:00 2001 From: Andre Basche Date: Mon, 8 May 2023 21:30:07 +0200 Subject: [PATCH] Fix missing switches again --- custom_components/hon/manifest.json | 2 +- custom_components/hon/switch.py | 22 ++++++++++++---------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/custom_components/hon/manifest.json b/custom_components/hon/manifest.json index ea962e3..85cbf29 100644 --- a/custom_components/hon/manifest.json +++ b/custom_components/hon/manifest.json @@ -7,5 +7,5 @@ "iot_class": "cloud_polling", "issue_tracker": "https://github.com/Andre0512/hon/issues", "requirements": ["pyhOn==0.10.6"], - "version": "0.7.3-beta.1" + "version": "0.7.3-beta.2" } diff --git a/custom_components/hon/switch.py b/custom_components/hon/switch.py index 6979dc1..8b7e0f5 100644 --- a/custom_components/hon/switch.py +++ b/custom_components/hon/switch.py @@ -323,16 +323,18 @@ async def async_setup_entry(hass, entry: ConfigEntry, async_add_entities) -> Non if descriptions := SWITCHES.get(device.appliance_type): for description in descriptions: - if ( - description.entity_category == EntityCategory.CONFIG - and description.key not in device.available_settings - or not any( - device.get(description.key) is not None - or description.turn_on_key in list(device.commands) - or description.turn_off_key in list(device.commands) - ) - ): - continue + if description.entity_category == EntityCategory.CONFIG: + if description.key not in device.available_settings: + continue + else: + if not any( + [ + device.get(description.key) is not None, + description.turn_on_key in list(device.commands), + description.turn_off_key in list(device.commands), + ] + ): + continue appliances.extend( [HonSwitchEntity(hass, coordinator, entry, device, description)] )