mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 15:17:35 +00:00
Add Reolink privacy switch entity (#136521)
This commit is contained in:
parent
db2fed2034
commit
40127a5ca4
@ -371,6 +371,12 @@
|
||||
},
|
||||
"led": {
|
||||
"default": "mdi:lightning-bolt-circle"
|
||||
},
|
||||
"privacy_mode": {
|
||||
"default": "mdi:eye",
|
||||
"state": {
|
||||
"on": "mdi:eye-off"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -808,6 +808,9 @@
|
||||
},
|
||||
"led": {
|
||||
"name": "LED"
|
||||
},
|
||||
"privacy_mode": {
|
||||
"name": "Privacy mode"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -208,6 +208,17 @@ SWITCH_ENTITIES = (
|
||||
),
|
||||
)
|
||||
|
||||
AVAILABILITY_SWITCH_ENTITIES = (
|
||||
ReolinkSwitchEntityDescription(
|
||||
key="privacy_mode",
|
||||
translation_key="privacy_mode",
|
||||
entity_category=EntityCategory.CONFIG,
|
||||
supported=lambda api, ch: api.supported(ch, "privacy_mode"),
|
||||
value=lambda api, ch: api.baichuan.privacy_mode(ch),
|
||||
method=lambda api, ch, value: api.baichuan.set_privacy_mode(ch, value),
|
||||
),
|
||||
)
|
||||
|
||||
NVR_SWITCH_ENTITIES = (
|
||||
ReolinkNVRSwitchEntityDescription(
|
||||
key="email",
|
||||
@ -344,6 +355,12 @@ async def async_setup_entry(
|
||||
for entity_description in CHIME_SWITCH_ENTITIES
|
||||
for chime in reolink_data.host.api.chime_list
|
||||
)
|
||||
entities.extend(
|
||||
ReolinkAvailabilitySwitchEntity(reolink_data, channel, entity_description)
|
||||
for entity_description in AVAILABILITY_SWITCH_ENTITIES
|
||||
for channel in reolink_data.host.api.channels
|
||||
if entity_description.supported(reolink_data.host.api, channel)
|
||||
)
|
||||
|
||||
# Can be removed in HA 2025.4.0
|
||||
depricated_dict = {}
|
||||
@ -409,6 +426,15 @@ class ReolinkSwitchEntity(ReolinkChannelCoordinatorEntity, SwitchEntity):
|
||||
self.async_write_ha_state()
|
||||
|
||||
|
||||
class ReolinkAvailabilitySwitchEntity(ReolinkSwitchEntity):
|
||||
"""Switch entity class for Reolink IP cameras which will be available even if API is unavailable."""
|
||||
|
||||
@property
|
||||
def available(self) -> bool:
|
||||
"""Return True if entity is available."""
|
||||
return self._host.api.camera_online(self._channel)
|
||||
|
||||
|
||||
class ReolinkNVRSwitchEntity(ReolinkHostCoordinatorEntity, SwitchEntity):
|
||||
"""Switch entity class for Reolink NVR features."""
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user