Skip to content

Commit

Permalink
Improve switch error correction.
Browse files Browse the repository at this point in the history
  • Loading branch information
RenierM26 committed Feb 18, 2021
1 parent c30b658 commit 0ee6712
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions custom_components/ezviz_cloud/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ async def async_setup_entry(
supported_switches = set(supported_switches)

for idx, camera in enumerate(coordinator.data):
if camera.get("switches"):
for switch in camera.get("switches"):
if switch in supported_switches:
switch_entities.append(EzvizSwitch(coordinator, idx, switch))
if not camera.get("switches"):
continue
for switch in camera["switches"]:
if switch not in supported_switches:
continue
switch_entities.append(EzvizSwitch(coordinator, idx, switch))

async_add_entities(switch_entities)

Expand Down

0 comments on commit 0ee6712

Please sign in to comment.