1 """Support for Tuya cameras."""
3 from __future__
import annotations
5 from tuya_sharing
import CustomerDevice, Manager
13 from .
import TuyaConfigEntry
14 from .const
import TUYA_DISCOVERY_NEW, DPCode
15 from .entity
import TuyaEntity
19 CAMERAS: tuple[str, ...] = (
27 hass: HomeAssistant, entry: TuyaConfigEntry, async_add_entities: AddEntitiesCallback
29 """Set up Tuya cameras dynamically through Tuya discovery."""
30 hass_data = entry.runtime_data
34 """Discover and add a discovered Tuya camera."""
35 entities: list[TuyaCameraEntity] = []
36 for device_id
in device_ids:
37 device = hass_data.manager.device_map[device_id]
38 if device.category
in CAMERAS:
45 entry.async_on_unload(
51 """Tuya Camera Entity."""
53 _attr_supported_features = CameraEntityFeature.STREAM
59 device: CustomerDevice,
60 device_manager: Manager,
62 """Init Tuya Camera."""
63 super().
__init__(device, device_manager)
64 CameraEntity.__init__(self)
69 """Return true if the device is recording."""
70 return self.
devicedevice.status.get(DPCode.RECORD_SWITCH,
False)
74 """Return the camera motion detection status."""
75 return self.
devicedevice.status.get(DPCode.MOTION_SWITCH,
False)
78 """Return the source of the stream."""
79 return await self.
hasshass.async_add_executor_job(
86 self, width: int |
None =
None, height: int |
None =
None
88 """Return a still image response from the camera."""
92 return await ffmpeg.async_get_image(
100 """Enable motion detection in the camera."""
101 self.
_send_command_send_command([{
"code": DPCode.MOTION_SWITCH,
"value":
True}])
104 """Disable motion detection in camera."""
105 self.
_send_command_send_command([{
"code": DPCode.MOTION_SWITCH,
"value":
False}])
bool motion_detection_enabled(self)
None enable_motion_detection(self)
None disable_motion_detection(self)
bytes|None async_camera_image(self, int|None width=None, int|None height=None)
None __init__(self, CustomerDevice device, Manager device_manager)
str|None stream_source(self)
None _send_command(self, list[dict[str, Any]] commands)
ElkSystem|None async_discover_device(HomeAssistant hass, str host)
None async_setup_entry(HomeAssistant hass, TuyaConfigEntry entry, AddEntitiesCallback async_add_entities)
Callable[[], None] async_dispatcher_connect(HomeAssistant hass, str signal, Callable[..., Any] target)