mirror of
https://github.com/home-assistant/core.git
synced 2025-11-13 04:50:17 +00:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user