Skip to content

Commit

Permalink
Added check for channel greater than one and not an NVR, now will not…
Browse files Browse the repository at this point in the history
… duplicate common controls
  • Loading branch information
ptyers committed Nov 27, 2021
1 parent a76127d commit 7c4dc27
Showing 1 changed file with 22 additions and 21 deletions.
43 changes: 22 additions & 21 deletions custom_components/reolink_dev/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,28 @@ async def async_setup_entry(hass: HomeAssistant, config_entry, async_add_devices
devices = []
base = hass.data[DOMAIN][config_entry.entry_id][BASE]

for capability in await base.api.get_switch_capabilities():
if capability == "ftp":
devices.append(FTPSwitch(hass, config_entry))
elif capability == "email":
devices.append(EmailSwitch(hass, config_entry))
elif capability == "audio":
devices.append(AudioSwitch(hass, config_entry))
elif capability == "irLights":
devices.append(IRLightsSwitch(hass, config_entry))
elif capability == "spotlight":
devices.append(SpotLightSwitch(hass, config_entry))
elif capability == "siren":
devices.append(SirenSwitch(hass, config_entry))
elif capability == "push":
devices.append(PushSwitch(hass, config_entry))
elif capability == "recording":
devices.append(RecordingSwitch(hass, config_entry))
else:
continue

async_add_devices(devices, update_before_add=False)
if (base.unique_id[13:] == "1") and not base.api.is_nvr():
for capability in await base.api.get_switch_capabilities():
if capability == "ftp":
devices.append(FTPSwitch(hass, config_entry))
elif capability == "email":
devices.append(EmailSwitch(hass, config_entry))
elif capability == "audio":
devices.append(AudioSwitch(hass, config_entry))
elif capability == "irLights":
devices.append(IRLightsSwitch(hass, config_entry))
elif capability == "spotlight":
devices.append(SpotLightSwitch(hass, config_entry))
elif capability == "siren":
devices.append(SirenSwitch(hass, config_entry))
elif capability == "push":
devices.append(PushSwitch(hass, config_entry))
elif capability == "recording":
devices.append(RecordingSwitch(hass, config_entry))
else:
continue

async_add_devices(devices, update_before_add=False)


class FTPSwitch(ReolinkEntity, ToggleEntity):
Expand Down

0 comments on commit 7c4dc27

Please sign in to comment.