mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Use shorthand attributes in rpi_camera camera (#145274)
* Use shorthand attributes in rpi_camera camera * Improve
This commit is contained in:
parent
43ae0f2541
commit
642dc5b49c
@ -7,6 +7,7 @@ import os
|
|||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
from tempfile import NamedTemporaryFile
|
from tempfile import NamedTemporaryFile
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
from homeassistant.components.camera import Camera
|
from homeassistant.components.camera import Camera
|
||||||
from homeassistant.const import CONF_FILE_PATH, CONF_NAME, EVENT_HOMEASSISTANT_STOP
|
from homeassistant.const import CONF_FILE_PATH, CONF_NAME, EVENT_HOMEASSISTANT_STOP
|
||||||
@ -87,11 +88,11 @@ def setup_platform(
|
|||||||
class RaspberryCamera(Camera):
|
class RaspberryCamera(Camera):
|
||||||
"""Representation of a Raspberry Pi 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."""
|
"""Initialize Raspberry Pi camera component."""
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
self._name = device_info[CONF_NAME]
|
self._attr_name = device_info[CONF_NAME]
|
||||||
self._config = device_info
|
self._config = device_info
|
||||||
|
|
||||||
# Kill if there's raspistill instance
|
# Kill if there's raspistill instance
|
||||||
@ -150,11 +151,6 @@ class RaspberryCamera(Camera):
|
|||||||
return file.read()
|
return file.read()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def frame_interval(self) -> float:
|
||||||
"""Return the name of this camera."""
|
|
||||||
return self._name
|
|
||||||
|
|
||||||
@property
|
|
||||||
def frame_interval(self):
|
|
||||||
"""Return the interval between frames of the stream."""
|
"""Return the interval between frames of the stream."""
|
||||||
return self._config[CONF_TIMELAPSE] / 1000
|
return self._config[CONF_TIMELAPSE] / 1000
|
||||||
|
Loading…
x
Reference in New Issue
Block a user