Use shorthand attributes in rpi_camera camera (#145274)

* Use shorthand attributes in rpi_camera camera

* Improve
This commit is contained in:
epenet 2025-05-20 11:47:49 +02:00 committed by GitHub
parent 43ae0f2541
commit 642dc5b49c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -7,6 +7,7 @@ import os
import shutil
import subprocess
from tempfile import NamedTemporaryFile
from typing import Any
from homeassistant.components.camera import Camera
from homeassistant.const import CONF_FILE_PATH, CONF_NAME, EVENT_HOMEASSISTANT_STOP
@ -87,11 +88,11 @@ def setup_platform(
class RaspberryCamera(Camera):
"""Representation of a Raspberry Pi camera."""
def __init__(self, device_info):
def __init__(self, device_info: dict[str, Any]) -> None:
"""Initialize Raspberry Pi camera component."""
super().__init__()
self._name = device_info[CONF_NAME]
self._attr_name = device_info[CONF_NAME]
self._config = device_info
# Kill if there's raspistill instance
@ -150,11 +151,6 @@ class RaspberryCamera(Camera):
return file.read()
@property
def name(self):
"""Return the name of this camera."""
return self._name
@property
def frame_interval(self):
def frame_interval(self) -> float:
"""Return the interval between frames of the stream."""
return self._config[CONF_TIMELAPSE] / 1000