Axis - Improve naming of some events (#39699)
* Add support for events from Loitering guard and Motion guard * Improve naming of events originating from applications Fence guard and VMD4 (Loitering guard and motion guard also benefit from this)
This commit is contained in:
parent
251d8919ea
commit
41abc08d63
6 changed files with 47 additions and 5 deletions
|
@ -8,6 +8,10 @@ from axis.event_stream import (
|
|||
CLASS_MOTION,
|
||||
CLASS_OUTPUT,
|
||||
CLASS_SOUND,
|
||||
FenceGuard,
|
||||
LoiteringGuard,
|
||||
MotionGuard,
|
||||
Vmd4,
|
||||
)
|
||||
|
||||
from homeassistant.components.binary_sensor import (
|
||||
|
@ -104,6 +108,21 @@ class AxisBinarySensor(AxisEventBase, BinarySensorEntity):
|
|||
f"{self.device.name} {self.device.api.vapix.ports[self.event.id].name}"
|
||||
)
|
||||
|
||||
if self.event.CLASS == CLASS_MOTION:
|
||||
|
||||
for event_class, event_data in (
|
||||
(FenceGuard, self.device.api.vapix.fence_guard),
|
||||
(LoiteringGuard, self.device.api.vapix.loitering_guard),
|
||||
(MotionGuard, self.device.api.vapix.motion_guard),
|
||||
(Vmd4, self.device.api.vapix.vmd4),
|
||||
):
|
||||
if (
|
||||
isinstance(self.event, event_class)
|
||||
and event_data
|
||||
and self.event.id in event_data
|
||||
):
|
||||
return f"{self.device.name} {self.event.TYPE} {event_data[self.event.id].name}"
|
||||
|
||||
return super().name
|
||||
|
||||
@property
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue