mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 15:17:35 +00:00
Use shorthand attributes in Nest (#99606)
This commit is contained in:
parent
22e90a5755
commit
2391087836
@ -24,7 +24,6 @@ from homeassistant.components.stream import CONF_EXTRA_PART_WAIT_TIME
|
|||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
from homeassistant.helpers.device_registry import DeviceInfo
|
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.helpers.event import async_track_point_in_utc_time
|
from homeassistant.helpers.event import async_track_point_in_utc_time
|
||||||
from homeassistant.util.dt import utcnow
|
from homeassistant.util.dt import utcnow
|
||||||
@ -68,7 +67,10 @@ class NestCamera(Camera):
|
|||||||
"""Initialize the camera."""
|
"""Initialize the camera."""
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self._device = device
|
self._device = device
|
||||||
self._device_info = NestDeviceInfo(device)
|
nest_device_info = NestDeviceInfo(device)
|
||||||
|
self._attr_device_info = nest_device_info.device_info
|
||||||
|
self._attr_brand = nest_device_info.device_brand
|
||||||
|
self._attr_model = nest_device_info.device_model
|
||||||
self._stream: RtspStream | None = None
|
self._stream: RtspStream | None = None
|
||||||
self._create_stream_url_lock = asyncio.Lock()
|
self._create_stream_url_lock = asyncio.Lock()
|
||||||
self._stream_refresh_unsub: Callable[[], None] | None = None
|
self._stream_refresh_unsub: Callable[[], None] | None = None
|
||||||
@ -84,33 +86,14 @@ class NestCamera(Camera):
|
|||||||
if StreamingProtocol.RTSP in trait.supported_protocols:
|
if StreamingProtocol.RTSP in trait.supported_protocols:
|
||||||
self._rtsp_live_stream_trait = trait
|
self._rtsp_live_stream_trait = trait
|
||||||
self.stream_options[CONF_EXTRA_PART_WAIT_TIME] = 3
|
self.stream_options[CONF_EXTRA_PART_WAIT_TIME] = 3
|
||||||
|
# The API "name" field is a unique device identifier.
|
||||||
|
self._attr_unique_id = f"{self._device.name}-camera"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def use_stream_for_stills(self) -> bool:
|
def use_stream_for_stills(self) -> bool:
|
||||||
"""Whether or not to use stream to generate stills."""
|
"""Whether or not to use stream to generate stills."""
|
||||||
return self._rtsp_live_stream_trait is not None
|
return self._rtsp_live_stream_trait is not None
|
||||||
|
|
||||||
@property
|
|
||||||
def unique_id(self) -> str:
|
|
||||||
"""Return a unique ID."""
|
|
||||||
# The API "name" field is a unique device identifier.
|
|
||||||
return f"{self._device.name}-camera"
|
|
||||||
|
|
||||||
@property
|
|
||||||
def device_info(self) -> DeviceInfo:
|
|
||||||
"""Return device specific attributes."""
|
|
||||||
return self._device_info.device_info
|
|
||||||
|
|
||||||
@property
|
|
||||||
def brand(self) -> str | None:
|
|
||||||
"""Return the camera brand."""
|
|
||||||
return self._device_info.device_brand
|
|
||||||
|
|
||||||
@property
|
|
||||||
def model(self) -> str | None:
|
|
||||||
"""Return the camera model."""
|
|
||||||
return self._device_info.device_model
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def frontend_stream_type(self) -> StreamType | None:
|
def frontend_stream_type(self) -> StreamType | None:
|
||||||
"""Return the type of stream supported by this camera."""
|
"""Return the type of stream supported by this camera."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user