Add new ONVIF sensors (#70394)
* add digital input and relay sensors / clean up default sensor names * add relay * fix copy/paste errors
This commit is contained in:
parent
7f11df4c79
commit
0d9191c344
2 changed files with 55 additions and 13 deletions
|
@ -106,7 +106,7 @@ class ONVIFCameraEntity(ONVIFBaseEntity, Camera):
|
|||
@property
|
||||
def name(self) -> str:
|
||||
"""Return the name of this camera."""
|
||||
return f"{self.device.name} - {self.profile.name}"
|
||||
return f"{self.device.name} {self.profile.name}"
|
||||
|
||||
@property
|
||||
def unique_id(self) -> str:
|
||||
|
|
|
@ -35,7 +35,7 @@ async def async_parse_motion_alarm(uid: str, msg) -> Event:
|
|||
source = msg.Message._value_1.Source.SimpleItem[0].Value
|
||||
return Event(
|
||||
f"{uid}_{msg.Topic._value_1}_{source}",
|
||||
f"{source} Motion Alarm",
|
||||
"Motion Alarm",
|
||||
"binary_sensor",
|
||||
"motion",
|
||||
None,
|
||||
|
@ -58,7 +58,7 @@ async def async_parse_image_too_blurry(uid: str, msg) -> Event:
|
|||
source = msg.Message._value_1.Source.SimpleItem[0].Value
|
||||
return Event(
|
||||
f"{uid}_{msg.Topic._value_1}_{source}",
|
||||
f"{source} Image Too Blurry",
|
||||
"Image Too Blurry",
|
||||
"binary_sensor",
|
||||
"problem",
|
||||
None,
|
||||
|
@ -82,7 +82,7 @@ async def async_parse_image_too_dark(uid: str, msg) -> Event:
|
|||
source = msg.Message._value_1.Source.SimpleItem[0].Value
|
||||
return Event(
|
||||
f"{uid}_{msg.Topic._value_1}_{source}",
|
||||
f"{source} Image Too Dark",
|
||||
"Image Too Dark",
|
||||
"binary_sensor",
|
||||
"problem",
|
||||
None,
|
||||
|
@ -106,7 +106,7 @@ async def async_parse_image_too_bright(uid: str, msg) -> Event:
|
|||
source = msg.Message._value_1.Source.SimpleItem[0].Value
|
||||
return Event(
|
||||
f"{uid}_{msg.Topic._value_1}_{source}",
|
||||
f"{source} Image Too Bright",
|
||||
"Image Too Bright",
|
||||
"binary_sensor",
|
||||
"problem",
|
||||
None,
|
||||
|
@ -130,7 +130,7 @@ async def async_parse_scene_change(uid: str, msg) -> Event:
|
|||
source = msg.Message._value_1.Source.SimpleItem[0].Value
|
||||
return Event(
|
||||
f"{uid}_{msg.Topic._value_1}_{source}",
|
||||
f"{source} Global Scene Change",
|
||||
"Global Scene Change",
|
||||
"binary_sensor",
|
||||
"problem",
|
||||
None,
|
||||
|
@ -161,7 +161,7 @@ async def async_parse_detected_sound(uid: str, msg) -> Event:
|
|||
|
||||
return Event(
|
||||
f"{uid}_{msg.Topic._value_1}_{audio_source}_{audio_analytics}_{rule}",
|
||||
f"{rule} Detected Sound",
|
||||
"Detected Sound",
|
||||
"binary_sensor",
|
||||
"sound",
|
||||
None,
|
||||
|
@ -192,7 +192,7 @@ async def async_parse_field_detector(uid: str, msg) -> Event:
|
|||
|
||||
evt = Event(
|
||||
f"{uid}_{msg.Topic._value_1}_{video_source}_{video_analytics}_{rule}",
|
||||
f"{rule} Field Detection",
|
||||
"Field Detection",
|
||||
"binary_sensor",
|
||||
"motion",
|
||||
None,
|
||||
|
@ -224,7 +224,7 @@ async def async_parse_cell_motion_detector(uid: str, msg) -> Event:
|
|||
|
||||
return Event(
|
||||
f"{uid}_{msg.Topic._value_1}_{video_source}_{video_analytics}_{rule}",
|
||||
f"{rule} Cell Motion Detection",
|
||||
"Cell Motion Detection",
|
||||
"binary_sensor",
|
||||
"motion",
|
||||
None,
|
||||
|
@ -255,7 +255,7 @@ async def async_parse_motion_region_detector(uid: str, msg) -> Event:
|
|||
|
||||
return Event(
|
||||
f"{uid}_{msg.Topic._value_1}_{video_source}_{video_analytics}_{rule}",
|
||||
f"{rule} Motion Region Detection",
|
||||
"Motion Region Detection",
|
||||
"binary_sensor",
|
||||
"motion",
|
||||
None,
|
||||
|
@ -286,7 +286,7 @@ async def async_parse_tamper_detector(uid: str, msg) -> Event:
|
|||
|
||||
return Event(
|
||||
f"{uid}_{msg.Topic._value_1}_{video_source}_{video_analytics}_{rule}",
|
||||
f"{rule} Tamper Detection",
|
||||
"Tamper Detection",
|
||||
"binary_sensor",
|
||||
"problem",
|
||||
None,
|
||||
|
@ -297,6 +297,48 @@ async def async_parse_tamper_detector(uid: str, msg) -> Event:
|
|||
return None
|
||||
|
||||
|
||||
@PARSERS.register("tns1:Device/Trigger/DigitalInput")
|
||||
# pylint: disable=protected-access
|
||||
async def async_parse_digital_input(uid: str, msg) -> Event:
|
||||
"""Handle parsing event message.
|
||||
|
||||
Topic: tns1:Device/Trigger/DigitalInput
|
||||
"""
|
||||
try:
|
||||
source = msg.Message._value_1.Source.SimpleItem[0].Value
|
||||
return Event(
|
||||
f"{uid}_{msg.Topic._value_1}_{source}",
|
||||
"Digital Input",
|
||||
"binary_sensor",
|
||||
None,
|
||||
None,
|
||||
msg.Message._value_1.Data.SimpleItem[0].Value == "true",
|
||||
)
|
||||
except (AttributeError, KeyError):
|
||||
return None
|
||||
|
||||
|
||||
@PARSERS.register("tns1:Device/Trigger/Relay")
|
||||
# pylint: disable=protected-access
|
||||
async def async_parse_relay(uid: str, msg) -> Event:
|
||||
"""Handle parsing event message.
|
||||
|
||||
Topic: tns1:Device/Trigger/Relay
|
||||
"""
|
||||
try:
|
||||
source = msg.Message._value_1.Source.SimpleItem[0].Value
|
||||
return Event(
|
||||
f"{uid}_{msg.Topic._value_1}_{source}",
|
||||
"Relay Triggered",
|
||||
"binary_sensor",
|
||||
None,
|
||||
None,
|
||||
msg.Message._value_1.Data.SimpleItem[0].Value == "active",
|
||||
)
|
||||
except (AttributeError, KeyError):
|
||||
return None
|
||||
|
||||
|
||||
@PARSERS.register("tns1:Device/HardwareFailure/StorageFailure")
|
||||
# pylint: disable=protected-access
|
||||
async def async_parse_storage_failure(uid: str, msg) -> Event:
|
||||
|
@ -441,14 +483,14 @@ async def async_parse_last_clock_sync(uid: str, msg) -> Event:
|
|||
async def async_parse_jobstate(uid: str, msg) -> Event:
|
||||
"""Handle parsing event message.
|
||||
|
||||
Topic: tns1:RecordingConfig/JobState*
|
||||
Topic: tns1:RecordingConfig/JobState
|
||||
"""
|
||||
|
||||
try:
|
||||
source = msg.Message._value_1.Source.SimpleItem[0].Value
|
||||
return Event(
|
||||
f"{uid}_{msg.Topic._value_1}_{source}",
|
||||
f"{source} JobState",
|
||||
"Recording Job State",
|
||||
"binary_sensor",
|
||||
None,
|
||||
None,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue