1 """Support for Abode Security System cameras."""
3 from __future__
import annotations
5 from datetime
import timedelta
6 from typing
import Any, cast
8 from jaraco.abode.devices.base
import Device
9 from jaraco.abode.devices.camera
import Camera
as AbodeCam
10 from jaraco.abode.helpers
import timeline
12 from requests.models
import Response
21 from .
import AbodeSystem
22 from .const
import DOMAIN, LOGGER
23 from .entity
import AbodeDevice
29 hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
31 """Set up Abode camera devices."""
32 data: AbodeSystem = hass.data[DOMAIN]
36 for device
in data.abode.get_devices(generic_type=
"camera")
41 """Representation of an Abode camera."""
46 def __init__(self, data: AbodeSystem, device: Device, event: Event) ->
None:
47 """Initialize the Abode device."""
48 AbodeDevice.__init__(self, data, device)
51 self.
_response_response: Response |
None =
None
54 """Subscribe Abode events."""
57 self.
hasshass.async_add_executor_job(
58 self.
_data_data.abode.events.add_timeline_callback,
63 signal = f
"abode_camera_capture_{self.entity_id}"
67 """Request a new image capture."""
70 @Throttle(MIN_TIME_BETWEEN_UPDATES)
72 """Find a new image on the timeline."""
77 """Attempt to download the most recent capture."""
78 if self.
_device_device.image_url:
81 self.
_device_device.image_url, stream=
True, timeout=10
84 self.
_response_response.raise_for_status()
85 except requests.HTTPError
as err:
86 LOGGER.warning(
"Failed to get camera image: %s", err)
92 self, width: int |
None =
None, height: int |
None =
None
94 """Get a camera image."""
103 """Turn on camera."""
104 self.
_device_device.privacy_mode(
False)
107 """Turn off camera."""
108 self.
_device_device.privacy_mode(
True)
111 """Update the image with the device then refresh device."""
112 self.
_device_device.update_image_location(capture)
118 """Return true if on."""
119 return cast(bool, self.
_device_device.is_on)
None async_added_to_hass(self)
bytes|None camera_image(self, int|None width=None, int|None height=None)
None __init__(self, AbodeSystem data, Device device, Event event)
None _capture_callback(self, Any capture)
None async_on_remove(self, CALLBACK_TYPE func)
None schedule_update_ha_state(self, bool force_refresh=False)
None async_setup_entry(HomeAssistant hass, ConfigEntry entry, AddEntitiesCallback async_add_entities)
Callable[[], None] async_dispatcher_connect(HomeAssistant hass, str signal, Callable[..., Any] target)