From 3468e38da2135f68d17a253e15d209780e6fec4d Mon Sep 17 00:00:00 2001 From: Elad Bar Date: Thu, 2 Mar 2023 12:11:12 +0200 Subject: [PATCH] Align core --- .../edgeos/core/components/camera.py | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/custom_components/edgeos/core/components/camera.py b/custom_components/edgeos/core/components/camera.py index 2e7e9b5..7ecba4f 100644 --- a/custom_components/edgeos/core/components/camera.py +++ b/custom_components/edgeos/core/components/camera.py @@ -12,7 +12,11 @@ import aiohttp import async_timeout -from homeassistant.components.camera import DEFAULT_CONTENT_TYPE, SUPPORT_STREAM, Camera +from homeassistant.components.camera import ( + DEFAULT_CONTENT_TYPE, + Camera, + CameraEntityFeature, +) from homeassistant.core import HomeAssistant from homeassistant.exceptions import TemplateError from homeassistant.helpers.aiohttp_client import async_get_clientsession @@ -80,20 +84,19 @@ def initialize( still_image_url_template = cv.template(snapshot) - stream_support = DOMAIN_STREAM in self.hass.data - - stream_support_flag = ( - SUPPORT_STREAM if stream_source and stream_support else 0 - ) - self._still_image_url = still_image_url_template self._still_image_url.hass = hass self._stream_source = stream_source self._frame_interval = SINGLE_FRAME_PS / fps - self._supported_features = stream_support_flag self._is_recording_state = self.entity.details.get(ATTR_MODE_RECORD) + self._attr_is_streaming = stream_source is not None + + if self._stream_source: + self._attr_supported_features = CameraEntityFeature.STREAM + else: + self._attr_supported_features = CameraEntityFeature(0) if username and password: self._auth = aiohttp.BasicAuth(username, password=password) @@ -114,11 +117,6 @@ def is_recording(self) -> bool: def motion_detection_enabled(self): return self.entity.details.get(CONF_MOTION_DETECTION, False) - @property - def supported_features(self): - """Return supported features for this camera.""" - return self._supported_features - @property def frame_interval(self): """Return the interval between frames of the mjpeg stream."""