From 20451a301d2688e24947c983f0c5610dfd0ad5de Mon Sep 17 00:00:00 2001 From: Seb Ruiz Date: Sat, 19 Aug 2023 21:53:22 +1000 Subject: [PATCH] Don't create program switches for disabled devices. Fixes #201 (#216) --- custom_components/bhyve/switch.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/custom_components/bhyve/switch.py b/custom_components/bhyve/switch.py index 507effe..79a0b55 100644 --- a/custom_components/bhyve/switch.py +++ b/custom_components/bhyve/switch.py @@ -194,7 +194,7 @@ async def async_setup_entry( for program in programs: program_device = device_by_id.get(program.get("device_id")) program_id = program.get("program") - if program_id is not None: + if program_device is not None and program_id is not None: _LOGGER.info("Creating switch: Program %s", program.get("name")) switches.append( BHyveProgramSwitch( @@ -416,8 +416,8 @@ def _setup(self, device): self._attrs[ATTR_MANUAL_RUNTIME] = self._manual_preset_runtime next_start_time = orbit_time_to_local_time( - status.get("next_start_time") - ).isoformat() + status.get("next_start_time") + ).isoformat() if next_start_time is not None: next_start_programs = status.get("next_start_programs") self._attrs.update(