1 """Demo camera platform that has a fake camera."""
3 from __future__
import annotations
5 from pathlib
import Path
15 config_entry: ConfigEntry,
16 async_add_entities: AddEntitiesCallback,
18 """Set up the Demo config entry."""
29 """The representation of a Demo camera."""
31 _attr_is_streaming =
True
32 _attr_motion_detection_enabled =
False
33 _attr_supported_features = CameraEntityFeature.ON_OFF | CameraEntityFeature.STREAM
35 def __init__(self, name: str, content_type: str) ->
None:
36 """Initialize demo camera component."""
43 self, width: int |
None =
None, height: int |
None =
None
45 """Return a faked still image response."""
47 ext =
"jpg" if self.
content_typecontent_type ==
"image/jpg" else "png"
48 image_path = Path(__file__).parent / f
"demo_{self._images_index}.{ext}"
50 return await self.
hasshass.async_add_executor_job(image_path.read_bytes)
53 """Enable the Motion detection in base station (Arm)."""
58 """Disable the motion detection in base station (Disarm)."""
63 """Turn off camera."""
76 """The representation of a Demo camera without stream."""
78 _attr_supported_features = CameraEntityFeature.ON_OFF
None async_write_ha_state(self)
None async_enable_motion_detection(self)
_attr_motion_detection_enabled
None async_disable_motion_detection(self)
None async_turn_off(self)
bytes async_camera_image(self, int|None width=None, int|None height=None)
None __init__(self, str name, str content_type)
bool _attr_motion_detection_enabled
None async_write_ha_state(self)
None async_setup_entry(HomeAssistant hass, ConfigEntry config_entry, AddEntitiesCallback async_add_entities)