Use shorthand attributes in Tuya camera platform (#63228)

This commit is contained in:
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

View File

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