diff --git a/homeassistant/components/yi/camera.py b/homeassistant/components/yi/camera.py index b2fac03954d..10b84f933ef 100644 --- a/homeassistant/components/yi/camera.py +++ b/homeassistant/components/yi/camera.py @@ -66,36 +66,22 @@ async def async_setup_platform( class YiCamera(Camera): """Define an implementation of a Yi Camera.""" - def __init__(self, hass, config): + _attr_brand = DEFAULT_BRAND + + def __init__(self, hass: HomeAssistant, config: ConfigType) -> None: """Initialize.""" super().__init__() self._extra_arguments = config.get(CONF_FFMPEG_ARGUMENTS) - self._last_image = None + self._last_image: bytes | None = None self._last_url = None self._manager = get_ffmpeg_manager(hass) - self._name = config[CONF_NAME] - self._is_on = True + self._attr_name = config[CONF_NAME] self.host = config[CONF_HOST] self.port = config[CONF_PORT] self.path = config[CONF_PATH] self.user = config[CONF_USERNAME] self.passwd = config[CONF_PASSWORD] - @property - def brand(self): - """Camera brand.""" - return DEFAULT_BRAND - - @property - def is_on(self): - """Determine whether the camera is on.""" - return self._is_on - - @property - def name(self): - """Return the name of this camera.""" - return self._name - async def _get_latest_video_url(self): """Retrieve the latest video file from the customized Yi FTP server.""" ftp = Client() @@ -122,14 +108,14 @@ class YiCamera(Camera): return None await ftp.quit() - self._is_on = True + self._attr_is_on = True return ( f"ftp://{self.user}:{self.passwd}@{self.host}:" f"{self.port}{self.path}/{latest_dir}/{videos[-1]}" ) except (ConnectionRefusedError, StatusCodeError) as err: _LOGGER.error("Error while fetching video: %s", err) - self._is_on = False + self._attr_is_on = False return None async def async_camera_image( @@ -151,7 +137,7 @@ class YiCamera(Camera): async def handle_async_mjpeg_stream(self, request): """Generate an HTTP MJPEG stream from the camera.""" - if not self._is_on: + if not self._attr_is_on: return None stream = CameraMjpeg(self._manager.binary)