mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
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
@ -106,7 +106,7 @@ class ONVIFCameraEntity(ONVIFBaseEntity, Camera):
|
|||||||
@property
|
@property
|
||||||
def name(self) -> str:
|
def name(self) -> str:
|
||||||
"""Return the name of this camera."""
|
"""Return the name of this camera."""
|
||||||
return f"{self.device.name} - {self.profile.name}"
|
return f"{self.device.name} {self.profile.name}"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unique_id(self) -> str:
|
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
|
source = msg.Message._value_1.Source.SimpleItem[0].Value
|
||||||
return Event(
|
return Event(
|
||||||
f"{uid}_{msg.Topic._value_1}_{source}",
|
f"{uid}_{msg.Topic._value_1}_{source}",
|
||||||
f"{source} Motion Alarm",
|
"Motion Alarm",
|
||||||
"binary_sensor",
|
"binary_sensor",
|
||||||
"motion",
|
"motion",
|
||||||
None,
|
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
|
source = msg.Message._value_1.Source.SimpleItem[0].Value
|
||||||
return Event(
|
return Event(
|
||||||
f"{uid}_{msg.Topic._value_1}_{source}",
|
f"{uid}_{msg.Topic._value_1}_{source}",
|
||||||
f"{source} Image Too Blurry",
|
"Image Too Blurry",
|
||||||
"binary_sensor",
|
"binary_sensor",
|
||||||
"problem",
|
"problem",
|
||||||
None,
|
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
|
source = msg.Message._value_1.Source.SimpleItem[0].Value
|
||||||
return Event(
|
return Event(
|
||||||
f"{uid}_{msg.Topic._value_1}_{source}",
|
f"{uid}_{msg.Topic._value_1}_{source}",
|
||||||
f"{source} Image Too Dark",
|
"Image Too Dark",
|
||||||
"binary_sensor",
|
"binary_sensor",
|
||||||
"problem",
|
"problem",
|
||||||
None,
|
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
|
source = msg.Message._value_1.Source.SimpleItem[0].Value
|
||||||
return Event(
|
return Event(
|
||||||
f"{uid}_{msg.Topic._value_1}_{source}",
|
f"{uid}_{msg.Topic._value_1}_{source}",
|
||||||
f"{source} Image Too Bright",
|
"Image Too Bright",
|
||||||
"binary_sensor",
|
"binary_sensor",
|
||||||
"problem",
|
"problem",
|
||||||
None,
|
None,
|
||||||
@ -130,7 +130,7 @@ async def async_parse_scene_change(uid: str, msg) -> Event:
|
|||||||
source = msg.Message._value_1.Source.SimpleItem[0].Value
|
source = msg.Message._value_1.Source.SimpleItem[0].Value
|
||||||
return Event(
|
return Event(
|
||||||
f"{uid}_{msg.Topic._value_1}_{source}",
|
f"{uid}_{msg.Topic._value_1}_{source}",
|
||||||
f"{source} Global Scene Change",
|
"Global Scene Change",
|
||||||
"binary_sensor",
|
"binary_sensor",
|
||||||
"problem",
|
"problem",
|
||||||
None,
|
None,
|
||||||
@ -161,7 +161,7 @@ async def async_parse_detected_sound(uid: str, msg) -> Event:
|
|||||||
|
|
||||||
return Event(
|
return Event(
|
||||||
f"{uid}_{msg.Topic._value_1}_{audio_source}_{audio_analytics}_{rule}",
|
f"{uid}_{msg.Topic._value_1}_{audio_source}_{audio_analytics}_{rule}",
|
||||||
f"{rule} Detected Sound",
|
"Detected Sound",
|
||||||
"binary_sensor",
|
"binary_sensor",
|
||||||
"sound",
|
"sound",
|
||||||
None,
|
None,
|
||||||
@ -192,7 +192,7 @@ async def async_parse_field_detector(uid: str, msg) -> Event:
|
|||||||
|
|
||||||
evt = Event(
|
evt = Event(
|
||||||
f"{uid}_{msg.Topic._value_1}_{video_source}_{video_analytics}_{rule}",
|
f"{uid}_{msg.Topic._value_1}_{video_source}_{video_analytics}_{rule}",
|
||||||
f"{rule} Field Detection",
|
"Field Detection",
|
||||||
"binary_sensor",
|
"binary_sensor",
|
||||||
"motion",
|
"motion",
|
||||||
None,
|
None,
|
||||||
@ -224,7 +224,7 @@ async def async_parse_cell_motion_detector(uid: str, msg) -> Event:
|
|||||||
|
|
||||||
return Event(
|
return Event(
|
||||||
f"{uid}_{msg.Topic._value_1}_{video_source}_{video_analytics}_{rule}",
|
f"{uid}_{msg.Topic._value_1}_{video_source}_{video_analytics}_{rule}",
|
||||||
f"{rule} Cell Motion Detection",
|
"Cell Motion Detection",
|
||||||
"binary_sensor",
|
"binary_sensor",
|
||||||
"motion",
|
"motion",
|
||||||
None,
|
None,
|
||||||
@ -255,7 +255,7 @@ async def async_parse_motion_region_detector(uid: str, msg) -> Event:
|
|||||||
|
|
||||||
return Event(
|
return Event(
|
||||||
f"{uid}_{msg.Topic._value_1}_{video_source}_{video_analytics}_{rule}",
|
f"{uid}_{msg.Topic._value_1}_{video_source}_{video_analytics}_{rule}",
|
||||||
f"{rule} Motion Region Detection",
|
"Motion Region Detection",
|
||||||
"binary_sensor",
|
"binary_sensor",
|
||||||
"motion",
|
"motion",
|
||||||
None,
|
None,
|
||||||
@ -286,7 +286,7 @@ async def async_parse_tamper_detector(uid: str, msg) -> Event:
|
|||||||
|
|
||||||
return Event(
|
return Event(
|
||||||
f"{uid}_{msg.Topic._value_1}_{video_source}_{video_analytics}_{rule}",
|
f"{uid}_{msg.Topic._value_1}_{video_source}_{video_analytics}_{rule}",
|
||||||
f"{rule} Tamper Detection",
|
"Tamper Detection",
|
||||||
"binary_sensor",
|
"binary_sensor",
|
||||||
"problem",
|
"problem",
|
||||||
None,
|
None,
|
||||||
@ -297,6 +297,48 @@ async def async_parse_tamper_detector(uid: str, msg) -> Event:
|
|||||||
return None
|
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")
|
@PARSERS.register("tns1:Device/HardwareFailure/StorageFailure")
|
||||||
# pylint: disable=protected-access
|
# pylint: disable=protected-access
|
||||||
async def async_parse_storage_failure(uid: str, msg) -> Event:
|
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:
|
async def async_parse_jobstate(uid: str, msg) -> Event:
|
||||||
"""Handle parsing event message.
|
"""Handle parsing event message.
|
||||||
|
|
||||||
Topic: tns1:RecordingConfig/JobState*
|
Topic: tns1:RecordingConfig/JobState
|
||||||
"""
|
"""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
source = msg.Message._value_1.Source.SimpleItem[0].Value
|
source = msg.Message._value_1.Source.SimpleItem[0].Value
|
||||||
return Event(
|
return Event(
|
||||||
f"{uid}_{msg.Topic._value_1}_{source}",
|
f"{uid}_{msg.Topic._value_1}_{source}",
|
||||||
f"{source} JobState",
|
"Recording Job State",
|
||||||
"binary_sensor",
|
"binary_sensor",
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user