Fix camera state and attributes for agent_dvr (#54049)
* Fix camera state and attributes for agent_dvr * tweak * tweakpull/54278/head
parent
89bb95b0be
commit
7590cb2861
|
@ -67,8 +67,6 @@ async def async_setup_entry(
|
|||
class AgentCamera(MjpegCamera):
|
||||
"""Representation of an Agent Device Stream."""
|
||||
|
||||
_attr_supported_features = SUPPORT_ON_OFF
|
||||
|
||||
def __init__(self, device):
|
||||
"""Initialize as a subclass of MjpegCamera."""
|
||||
device_info = {
|
||||
|
@ -80,7 +78,6 @@ class AgentCamera(MjpegCamera):
|
|||
self._removed = False
|
||||
self._attr_name = f"{device.client.name} {device.name}"
|
||||
self._attr_unique_id = f"{device._client.unique}_{device.typeID}_{device.id}"
|
||||
self._attr_should_poll = True
|
||||
super().__init__(device_info)
|
||||
self._attr_device_info = {
|
||||
"identifiers": {(AGENT_DOMAIN, self.unique_id)},
|
||||
|
@ -102,10 +99,10 @@ class AgentCamera(MjpegCamera):
|
|||
if self.device.client.is_available and not self._removed:
|
||||
_LOGGER.error("%s lost", self.name)
|
||||
self._removed = True
|
||||
self._attr_available = self.device.client.is_available
|
||||
self._attr_icon = "mdi:camcorder-off"
|
||||
if self.is_on:
|
||||
self._attr_icon = "mdi:camcorder"
|
||||
self._attr_available = self.device.client.is_available
|
||||
self._attr_extra_state_attributes = {
|
||||
ATTR_ATTRIBUTION: ATTRIBUTION,
|
||||
"editable": False,
|
||||
|
@ -117,6 +114,11 @@ class AgentCamera(MjpegCamera):
|
|||
"alerts_enabled": self.device.alerts_active,
|
||||
}
|
||||
|
||||
@property
|
||||
def should_poll(self) -> bool:
|
||||
"""Update the state periodically."""
|
||||
return True
|
||||
|
||||
@property
|
||||
def is_recording(self) -> bool:
|
||||
"""Return whether the monitor is recording."""
|
||||
|
@ -137,6 +139,11 @@ class AgentCamera(MjpegCamera):
|
|||
"""Return True if entity is connected."""
|
||||
return self.device.connected
|
||||
|
||||
@property
|
||||
def supported_features(self) -> int:
|
||||
"""Return supported features."""
|
||||
return SUPPORT_ON_OFF
|
||||
|
||||
@property
|
||||
def is_on(self) -> bool:
|
||||
"""Return true if on."""
|
||||
|
|
Loading…
Reference in New Issue