Skip to content
This repository was archived by the owner on Apr 6, 2023. It is now read-only.

Revert 7c4dc271 and re-add common controls, because duplicated contro… #549

Merged
merged 1 commit into from
Sep 14, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 21 additions & 22 deletions custom_components/reolink_dev/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,27 @@ async def async_setup_entry(hass: HomeAssistant, config_entry, async_add_devices
devices = []
base = hass.data[DOMAIN][config_entry.entry_id][BASE]

if (base.unique_id[13:] == "1") and not base.api.is_nvr(): # prevent controls from being created several times with multi channel devices
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)
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