Use shorthand attributes in Tuya camera platform (#63228)

pull/63236/head
Franck Nijhof 2022-01-02 21:37:15 +01:00 committed by GitHub
parent 7de4801bfa
commit 76a7149a5e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 15 deletions

View File

@ -50,6 +50,9 @@ async def async_setup_entry(
class TuyaCameraEntity(TuyaEntity, CameraEntity):
"""Tuya Camera Entity."""
_attr_supported_features = SUPPORT_STREAM
_attr_brand = "Tuya"
def __init__(
self,
device: TuyaDevice,
@ -58,22 +61,13 @@ class TuyaCameraEntity(TuyaEntity, CameraEntity):
"""Init Tuya Camera."""
super().__init__(device, device_manager)
CameraEntity.__init__(self)
@property
def supported_features(self) -> int:
"""Flag supported features."""
return SUPPORT_STREAM
self._attr_model = device.product_name
@property
def is_recording(self) -> bool:
"""Return true if the device is recording."""
return self.device.status.get(DPCode.RECORD_SWITCH, False)
@property
def brand(self) -> str | None:
"""Return the camera brand."""
return "Tuya"
@property
def motion_detection_enabled(self) -> bool:
"""Return the camera motion detection status."""
@ -101,11 +95,6 @@ class TuyaCameraEntity(TuyaEntity, CameraEntity):
height=height,
)
@property
def model(self) -> str | None:
"""Return the camera model."""
return self.device.product_name
def enable_motion_detection(self) -> None:
"""Enable motion detection in the camera."""
self._send_command([{"code": DPCode.MOTION_SWITCH, "value": True}])