mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 23:27:37 +00:00
Add Reolink privacy switch entity (#136521)
This commit is contained in:
parent
db2fed2034
commit
40127a5ca4
@ -371,6 +371,12 @@
|
|||||||
},
|
},
|
||||||
"led": {
|
"led": {
|
||||||
"default": "mdi:lightning-bolt-circle"
|
"default": "mdi:lightning-bolt-circle"
|
||||||
|
},
|
||||||
|
"privacy_mode": {
|
||||||
|
"default": "mdi:eye",
|
||||||
|
"state": {
|
||||||
|
"on": "mdi:eye-off"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -808,6 +808,9 @@
|
|||||||
},
|
},
|
||||||
"led": {
|
"led": {
|
||||||
"name": "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 = (
|
NVR_SWITCH_ENTITIES = (
|
||||||
ReolinkNVRSwitchEntityDescription(
|
ReolinkNVRSwitchEntityDescription(
|
||||||
key="email",
|
key="email",
|
||||||
@ -344,6 +355,12 @@ async def async_setup_entry(
|
|||||||
for entity_description in CHIME_SWITCH_ENTITIES
|
for entity_description in CHIME_SWITCH_ENTITIES
|
||||||
for chime in reolink_data.host.api.chime_list
|
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
|
# Can be removed in HA 2025.4.0
|
||||||
depricated_dict = {}
|
depricated_dict = {}
|
||||||
@ -409,6 +426,15 @@ class ReolinkSwitchEntity(ReolinkChannelCoordinatorEntity, SwitchEntity):
|
|||||||
self.async_write_ha_state()
|
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):
|
class ReolinkNVRSwitchEntity(ReolinkHostCoordinatorEntity, SwitchEntity):
|
||||||
"""Switch entity class for Reolink NVR features."""
|
"""Switch entity class for Reolink NVR features."""
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user