Add UniFi Protect chime button/camera switch (#73195)

This commit is contained in:
Christopher Bailey 2022-06-08 18:29:46 -04:00 committed by GitHub
parent 4435c641de
commit 4c45cb5c52
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 81 additions and 7 deletions

View file

@ -140,9 +140,9 @@ class ProtectCamera(ProtectDeviceEntity, Camera):
def _async_update_device_from_protect(self) -> None:
super()._async_update_device_from_protect()
self.channel = self.device.channels[self.channel.id]
motion_enabled = self.device.recording_settings.enable_motion_detection
self._attr_motion_detection_enabled = (
self.device.state == StateType.CONNECTED
and self.device.feature_flags.has_motion_zones
motion_enabled if motion_enabled is not None else True
)
self._attr_is_recording = (
self.device.state == StateType.CONNECTED and self.device.is_recording
@ -171,3 +171,11 @@ class ProtectCamera(ProtectDeviceEntity, Camera):
async def stream_source(self) -> str | None:
"""Return the Stream Source."""
return self._stream_source
async def async_enable_motion_detection(self) -> None:
"""Call the job and enable motion detection."""
await self.device.set_motion_detection(True)
async def async_disable_motion_detection(self) -> None:
"""Call the job and disable motion detection."""
await self.device.set_motion_detection(False)