mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Use shorthand attributes in push camera (#145273)
* Use shorthand attributes in push camera * Improve
This commit is contained in:
parent
c8183bd35a
commit
f9000ae08c
@ -61,7 +61,7 @@ async def async_setup_platform(
|
|||||||
if PUSH_CAMERA_DATA not in hass.data:
|
if PUSH_CAMERA_DATA not in hass.data:
|
||||||
hass.data[PUSH_CAMERA_DATA] = {}
|
hass.data[PUSH_CAMERA_DATA] = {}
|
||||||
|
|
||||||
webhook_id = config.get(CONF_WEBHOOK_ID)
|
webhook_id = config[CONF_WEBHOOK_ID]
|
||||||
|
|
||||||
cameras = [
|
cameras = [
|
||||||
PushCamera(
|
PushCamera(
|
||||||
@ -101,16 +101,27 @@ async def handle_webhook(
|
|||||||
class PushCamera(Camera):
|
class PushCamera(Camera):
|
||||||
"""The representation of a Push camera."""
|
"""The representation of a Push camera."""
|
||||||
|
|
||||||
def __init__(self, hass, name, buffer_size, timeout, image_field, webhook_id):
|
_attr_motion_detection_enabled = False
|
||||||
|
name: str
|
||||||
|
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
hass: HomeAssistant,
|
||||||
|
name: str,
|
||||||
|
buffer_size: int,
|
||||||
|
timeout: timedelta,
|
||||||
|
image_field: str,
|
||||||
|
webhook_id: str,
|
||||||
|
) -> None:
|
||||||
"""Initialize push camera component."""
|
"""Initialize push camera component."""
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self._name = name
|
self._attr_name = name
|
||||||
self._last_trip = None
|
self._last_trip = None
|
||||||
self._filename = None
|
self._filename = None
|
||||||
self._expired_listener = None
|
self._expired_listener = None
|
||||||
self._timeout = timeout
|
self._timeout = timeout
|
||||||
self.queue = deque([], buffer_size)
|
self.queue: deque[bytes] = deque([], buffer_size)
|
||||||
self._current_image = None
|
self._current_image: bytes | None = None
|
||||||
self._image_field = image_field
|
self._image_field = image_field
|
||||||
self.webhook_id = webhook_id
|
self.webhook_id = webhook_id
|
||||||
self.webhook_url = webhook.async_generate_url(hass, webhook_id)
|
self.webhook_url = webhook.async_generate_url(hass, webhook_id)
|
||||||
@ -171,16 +182,6 @@ class PushCamera(Camera):
|
|||||||
|
|
||||||
return self._current_image
|
return self._current_image
|
||||||
|
|
||||||
@property
|
|
||||||
def name(self):
|
|
||||||
"""Return the name of this camera."""
|
|
||||||
return self._name
|
|
||||||
|
|
||||||
@property
|
|
||||||
def motion_detection_enabled(self):
|
|
||||||
"""Camera Motion Detection Status."""
|
|
||||||
return False
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def extra_state_attributes(self):
|
def extra_state_attributes(self):
|
||||||
"""Return the state attributes."""
|
"""Return the state attributes."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user