1 """Support for viewing the camera feed from a DoorBird video doorbell."""
3 from __future__
import annotations
15 from .entity
import DoorBirdEntity
16 from .models
import DoorBirdConfigEntry, DoorBirdData
18 _LAST_VISITOR_INTERVAL = datetime.timedelta(minutes=2)
19 _LAST_MOTION_INTERVAL = datetime.timedelta(seconds=30)
20 _LIVE_INTERVAL = datetime.timedelta(seconds=45)
21 _LOGGER = logging.getLogger(__name__)
27 config_entry: DoorBirdConfigEntry,
28 async_add_entities: AddEntitiesCallback,
30 """Set up the DoorBird camera platform."""
31 door_bird_data = config_entry.runtime_data
32 device = door_bird_data.door_station.device
38 device.live_image_url,
41 device.rtsp_live_video_url,
45 device.history_image_url(1,
"doorbell"),
47 _LAST_VISITOR_INTERVAL,
51 device.history_image_url(1,
"motionsensor"),
53 _LAST_MOTION_INTERVAL,
60 """The camera on a DoorBird device."""
64 door_bird_data: DoorBirdData,
67 interval: datetime.timedelta,
68 stream_url: str |
None =
None,
70 """Initialize the camera on a DoorBird device."""
83 """Return the stream source."""
87 self, width: int |
None =
None, height: int |
None =
None
89 """Pull a still image from the camera."""
90 now = dt_util.utcnow()
97 self.
_url_url, timeout=_TIMEOUT
100 _LOGGER.error(
"DoorBird %s: Camera image timed out", self.
namename)
102 except aiohttp.ClientError
as error:
104 "DoorBird %s: Error getting camera image: %s", self.
namename, error
112 """Subscribe to events."""
114 event_to_entity_id = self.
_door_bird_data_door_bird_data.event_entity_ids
116 event_to_entity_id[event] = self.
entity_identity_id
119 """Unsubscribe from events."""
120 event_to_entity_id = self.
_door_bird_data_door_bird_data.event_entity_ids
123 event_to_entity_id.pop(event,
None)
None async_will_remove_from_hass(self)
str|None stream_source(self)
None async_added_to_hass(self)
None __init__(self, DoorBirdData door_bird_data, str url, str camera_id, datetime.timedelta interval, str|None stream_url=None)
bytes|None async_camera_image(self, int|None width=None, int|None height=None)
str|UndefinedType|None name(self)
None async_setup_entry(HomeAssistant hass, DoorBirdConfigEntry config_entry, AddEntitiesCallback async_add_entities)