Skip to content

Commit

Permalink
Don't create program switches for disabled devices. Fixes #201 (#216)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebr authored Aug 19, 2023
1 parent c7fd9f9 commit 20451a3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions custom_components/bhyve/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 20451a3

Please sign in to comment.