From 6658fcf3855abfd2ae649fa11f04b58c5c212740 Mon Sep 17 00:00:00 2001 From: Alex Hicks Date: Tue, 2 May 2023 04:17:09 -0400 Subject: [PATCH] Permit some config_entry options to be unset without throwing --- custom_components/cync_lights/light.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/custom_components/cync_lights/light.py b/custom_components/cync_lights/light.py index 8776140..e9ce28c 100644 --- a/custom_components/cync_lights/light.py +++ b/custom_components/cync_lights/light.py @@ -19,8 +19,10 @@ async def async_setup_entry( hub = hass.data[DOMAIN][config_entry.entry_id] new_devices = [] + config_rooms = "rooms" in config_entry.options and config_entry.options["rooms"] or {} + config_subgroups = "subgroups" in config_entry.options and config_entry.options["subgroups"] or {} for room in hub.cync_rooms: - if not hub.cync_rooms[room]._update_callback and (room in config_entry.options["rooms"] or room in config_entry.options["subgroups"]): + if not hub.cync_rooms[room]._update_callback and (room in config_rooms or room in config_subgroups): new_devices.append(CyncRoomEntity(hub.cync_rooms[room])) for switch_id in hub.cync_switches: @@ -250,4 +252,4 @@ async def async_turn_on(self, **kwargs: Any) -> None: async def async_turn_off(self, **kwargs: Any) -> None: """Turn off the light.""" - await self.cync_switch.turn_off() \ No newline at end of file + await self.cync_switch.turn_off()