mirror of
https://github.com/home-assistant/core.git
synced 2025-07-13 08:17:08 +00:00
Fix onvif creating a new entity for every new event (#101035)
Use topic value as topic
This commit is contained in:
parent
ffad30734b
commit
0147108b89
@ -48,15 +48,16 @@ async def async_parse_motion_alarm(uid: str, msg) -> Event | None:
|
|||||||
Topic: tns1:VideoSource/MotionAlarm
|
Topic: tns1:VideoSource/MotionAlarm
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
value_1 = msg.Message._value_1 # pylint: disable=protected-access
|
message_value = msg.Message._value_1 # pylint: disable=protected-access
|
||||||
source = value_1.Source.SimpleItem[0].Value
|
topic_value = msg.Topic._value_1 # pylint: disable=protected-access
|
||||||
|
source = message_value.Source.SimpleItem[0].Value
|
||||||
return Event(
|
return Event(
|
||||||
f"{uid}_{value_1}_{source}",
|
f"{uid}_{topic_value}_{source}",
|
||||||
"Motion Alarm",
|
"Motion Alarm",
|
||||||
"binary_sensor",
|
"binary_sensor",
|
||||||
"motion",
|
"motion",
|
||||||
None,
|
None,
|
||||||
value_1.Data.SimpleItem[0].Value == "true",
|
message_value.Data.SimpleItem[0].Value == "true",
|
||||||
)
|
)
|
||||||
except (AttributeError, KeyError):
|
except (AttributeError, KeyError):
|
||||||
return None
|
return None
|
||||||
@ -71,15 +72,16 @@ async def async_parse_image_too_blurry(uid: str, msg) -> Event | None:
|
|||||||
Topic: tns1:VideoSource/ImageTooBlurry/*
|
Topic: tns1:VideoSource/ImageTooBlurry/*
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
value_1 = msg.Message._value_1 # pylint: disable=protected-access
|
message_value = msg.Message._value_1 # pylint: disable=protected-access
|
||||||
source = value_1.Source.SimpleItem[0].Value
|
topic_value = msg.Topic._value_1 # pylint: disable=protected-access
|
||||||
|
source = message_value.Source.SimpleItem[0].Value
|
||||||
return Event(
|
return Event(
|
||||||
f"{uid}_{value_1}_{source}",
|
f"{uid}_{topic_value}_{source}",
|
||||||
"Image Too Blurry",
|
"Image Too Blurry",
|
||||||
"binary_sensor",
|
"binary_sensor",
|
||||||
"problem",
|
"problem",
|
||||||
None,
|
None,
|
||||||
value_1.Data.SimpleItem[0].Value == "true",
|
message_value.Data.SimpleItem[0].Value == "true",
|
||||||
EntityCategory.DIAGNOSTIC,
|
EntityCategory.DIAGNOSTIC,
|
||||||
)
|
)
|
||||||
except (AttributeError, KeyError):
|
except (AttributeError, KeyError):
|
||||||
@ -95,15 +97,16 @@ async def async_parse_image_too_dark(uid: str, msg) -> Event | None:
|
|||||||
Topic: tns1:VideoSource/ImageTooDark/*
|
Topic: tns1:VideoSource/ImageTooDark/*
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
value_1 = msg.Message._value_1 # pylint: disable=protected-access
|
message_value = msg.Message._value_1 # pylint: disable=protected-access
|
||||||
source = value_1.Source.SimpleItem[0].Value
|
topic_value = msg.Topic._value_1 # pylint: disable=protected-access
|
||||||
|
source = message_value.Source.SimpleItem[0].Value
|
||||||
return Event(
|
return Event(
|
||||||
f"{uid}_{value_1}_{source}",
|
f"{uid}_{topic_value}_{source}",
|
||||||
"Image Too Dark",
|
"Image Too Dark",
|
||||||
"binary_sensor",
|
"binary_sensor",
|
||||||
"problem",
|
"problem",
|
||||||
None,
|
None,
|
||||||
value_1.Data.SimpleItem[0].Value == "true",
|
message_value.Data.SimpleItem[0].Value == "true",
|
||||||
EntityCategory.DIAGNOSTIC,
|
EntityCategory.DIAGNOSTIC,
|
||||||
)
|
)
|
||||||
except (AttributeError, KeyError):
|
except (AttributeError, KeyError):
|
||||||
@ -119,15 +122,16 @@ async def async_parse_image_too_bright(uid: str, msg) -> Event | None:
|
|||||||
Topic: tns1:VideoSource/ImageTooBright/*
|
Topic: tns1:VideoSource/ImageTooBright/*
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
value_1 = msg.Message._value_1 # pylint: disable=protected-access
|
message_value = msg.Message._value_1 # pylint: disable=protected-access
|
||||||
source = value_1.Source.SimpleItem[0].Value
|
topic_value = msg.Topic._value_1 # pylint: disable=protected-access
|
||||||
|
source = message_value.Source.SimpleItem[0].Value
|
||||||
return Event(
|
return Event(
|
||||||
f"{uid}_{value_1}_{source}",
|
f"{uid}_{topic_value}_{source}",
|
||||||
"Image Too Bright",
|
"Image Too Bright",
|
||||||
"binary_sensor",
|
"binary_sensor",
|
||||||
"problem",
|
"problem",
|
||||||
None,
|
None,
|
||||||
value_1.Data.SimpleItem[0].Value == "true",
|
message_value.Data.SimpleItem[0].Value == "true",
|
||||||
EntityCategory.DIAGNOSTIC,
|
EntityCategory.DIAGNOSTIC,
|
||||||
)
|
)
|
||||||
except (AttributeError, KeyError):
|
except (AttributeError, KeyError):
|
||||||
@ -143,15 +147,16 @@ async def async_parse_scene_change(uid: str, msg) -> Event | None:
|
|||||||
Topic: tns1:VideoSource/GlobalSceneChange/*
|
Topic: tns1:VideoSource/GlobalSceneChange/*
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
value_1 = msg.Message._value_1 # pylint: disable=protected-access
|
message_value = msg.Message._value_1 # pylint: disable=protected-access
|
||||||
source = value_1.Source.SimpleItem[0].Value
|
topic_value = msg.Topic._value_1 # pylint: disable=protected-access
|
||||||
|
source = message_value.Source.SimpleItem[0].Value
|
||||||
return Event(
|
return Event(
|
||||||
f"{uid}_{value_1}_{source}",
|
f"{uid}_{topic_value}_{source}",
|
||||||
"Global Scene Change",
|
"Global Scene Change",
|
||||||
"binary_sensor",
|
"binary_sensor",
|
||||||
"problem",
|
"problem",
|
||||||
None,
|
None,
|
||||||
value_1.Data.SimpleItem[0].Value == "true",
|
message_value.Data.SimpleItem[0].Value == "true",
|
||||||
)
|
)
|
||||||
except (AttributeError, KeyError):
|
except (AttributeError, KeyError):
|
||||||
return None
|
return None
|
||||||
@ -167,8 +172,9 @@ async def async_parse_detected_sound(uid: str, msg) -> Event | None:
|
|||||||
audio_source = ""
|
audio_source = ""
|
||||||
audio_analytics = ""
|
audio_analytics = ""
|
||||||
rule = ""
|
rule = ""
|
||||||
value_1 = msg.Message._value_1 # pylint: disable=protected-access
|
message_value = msg.Message._value_1 # pylint: disable=protected-access
|
||||||
for source in value_1.Source.SimpleItem:
|
topic_value = msg.Topic._value_1 # pylint: disable=protected-access
|
||||||
|
for source in message_value.Source.SimpleItem:
|
||||||
if source.Name == "AudioSourceConfigurationToken":
|
if source.Name == "AudioSourceConfigurationToken":
|
||||||
audio_source = source.Value
|
audio_source = source.Value
|
||||||
if source.Name == "AudioAnalyticsConfigurationToken":
|
if source.Name == "AudioAnalyticsConfigurationToken":
|
||||||
@ -177,12 +183,12 @@ async def async_parse_detected_sound(uid: str, msg) -> Event | None:
|
|||||||
rule = source.Value
|
rule = source.Value
|
||||||
|
|
||||||
return Event(
|
return Event(
|
||||||
f"{uid}_{value_1}_{audio_source}_{audio_analytics}_{rule}",
|
f"{uid}_{topic_value}_{audio_source}_{audio_analytics}_{rule}",
|
||||||
"Detected Sound",
|
"Detected Sound",
|
||||||
"binary_sensor",
|
"binary_sensor",
|
||||||
"sound",
|
"sound",
|
||||||
None,
|
None,
|
||||||
value_1.Data.SimpleItem[0].Value == "true",
|
message_value.Data.SimpleItem[0].Value == "true",
|
||||||
)
|
)
|
||||||
except (AttributeError, KeyError):
|
except (AttributeError, KeyError):
|
||||||
return None
|
return None
|
||||||
@ -198,8 +204,9 @@ async def async_parse_field_detector(uid: str, msg) -> Event | None:
|
|||||||
video_source = ""
|
video_source = ""
|
||||||
video_analytics = ""
|
video_analytics = ""
|
||||||
rule = ""
|
rule = ""
|
||||||
value_1 = msg.Message._value_1 # pylint: disable=protected-access
|
message_value = msg.Message._value_1 # pylint: disable=protected-access
|
||||||
for source in value_1.Source.SimpleItem:
|
topic_value = msg.Topic._value_1 # pylint: disable=protected-access
|
||||||
|
for source in message_value.Source.SimpleItem:
|
||||||
if source.Name == "VideoSourceConfigurationToken":
|
if source.Name == "VideoSourceConfigurationToken":
|
||||||
video_source = _normalize_video_source(source.Value)
|
video_source = _normalize_video_source(source.Value)
|
||||||
if source.Name == "VideoAnalyticsConfigurationToken":
|
if source.Name == "VideoAnalyticsConfigurationToken":
|
||||||
@ -208,12 +215,12 @@ async def async_parse_field_detector(uid: str, msg) -> Event | None:
|
|||||||
rule = source.Value
|
rule = source.Value
|
||||||
|
|
||||||
evt = Event(
|
evt = Event(
|
||||||
f"{uid}_{value_1}_{video_source}_{video_analytics}_{rule}",
|
f"{uid}_{topic_value}_{video_source}_{video_analytics}_{rule}",
|
||||||
"Field Detection",
|
"Field Detection",
|
||||||
"binary_sensor",
|
"binary_sensor",
|
||||||
"motion",
|
"motion",
|
||||||
None,
|
None,
|
||||||
value_1.Data.SimpleItem[0].Value == "true",
|
message_value.Data.SimpleItem[0].Value == "true",
|
||||||
)
|
)
|
||||||
return evt
|
return evt
|
||||||
except (AttributeError, KeyError):
|
except (AttributeError, KeyError):
|
||||||
@ -230,8 +237,9 @@ async def async_parse_cell_motion_detector(uid: str, msg) -> Event | None:
|
|||||||
video_source = ""
|
video_source = ""
|
||||||
video_analytics = ""
|
video_analytics = ""
|
||||||
rule = ""
|
rule = ""
|
||||||
value_1 = msg.Message._value_1 # pylint: disable=protected-access
|
message_value = msg.Message._value_1 # pylint: disable=protected-access
|
||||||
for source in value_1.Source.SimpleItem:
|
topic_value = msg.Topic._value_1 # pylint: disable=protected-access
|
||||||
|
for source in message_value.Source.SimpleItem:
|
||||||
if source.Name == "VideoSourceConfigurationToken":
|
if source.Name == "VideoSourceConfigurationToken":
|
||||||
video_source = _normalize_video_source(source.Value)
|
video_source = _normalize_video_source(source.Value)
|
||||||
if source.Name == "VideoAnalyticsConfigurationToken":
|
if source.Name == "VideoAnalyticsConfigurationToken":
|
||||||
@ -240,12 +248,12 @@ async def async_parse_cell_motion_detector(uid: str, msg) -> Event | None:
|
|||||||
rule = source.Value
|
rule = source.Value
|
||||||
|
|
||||||
return Event(
|
return Event(
|
||||||
f"{uid}_{value_1}_{video_source}_{video_analytics}_{rule}",
|
f"{uid}_{topic_value}_{video_source}_{video_analytics}_{rule}",
|
||||||
"Cell Motion Detection",
|
"Cell Motion Detection",
|
||||||
"binary_sensor",
|
"binary_sensor",
|
||||||
"motion",
|
"motion",
|
||||||
None,
|
None,
|
||||||
value_1.Data.SimpleItem[0].Value == "true",
|
message_value.Data.SimpleItem[0].Value == "true",
|
||||||
)
|
)
|
||||||
except (AttributeError, KeyError):
|
except (AttributeError, KeyError):
|
||||||
return None
|
return None
|
||||||
@ -261,8 +269,9 @@ async def async_parse_motion_region_detector(uid: str, msg) -> Event | None:
|
|||||||
video_source = ""
|
video_source = ""
|
||||||
video_analytics = ""
|
video_analytics = ""
|
||||||
rule = ""
|
rule = ""
|
||||||
value_1 = msg.Message._value_1 # pylint: disable=protected-access
|
message_value = msg.Message._value_1 # pylint: disable=protected-access
|
||||||
for source in value_1.Source.SimpleItem:
|
topic_value = msg.Topic._value_1 # pylint: disable=protected-access
|
||||||
|
for source in message_value.Source.SimpleItem:
|
||||||
if source.Name == "VideoSourceConfigurationToken":
|
if source.Name == "VideoSourceConfigurationToken":
|
||||||
video_source = _normalize_video_source(source.Value)
|
video_source = _normalize_video_source(source.Value)
|
||||||
if source.Name == "VideoAnalyticsConfigurationToken":
|
if source.Name == "VideoAnalyticsConfigurationToken":
|
||||||
@ -271,12 +280,12 @@ async def async_parse_motion_region_detector(uid: str, msg) -> Event | None:
|
|||||||
rule = source.Value
|
rule = source.Value
|
||||||
|
|
||||||
return Event(
|
return Event(
|
||||||
f"{uid}_{value_1}_{video_source}_{video_analytics}_{rule}",
|
f"{uid}_{topic_value}_{video_source}_{video_analytics}_{rule}",
|
||||||
"Motion Region Detection",
|
"Motion Region Detection",
|
||||||
"binary_sensor",
|
"binary_sensor",
|
||||||
"motion",
|
"motion",
|
||||||
None,
|
None,
|
||||||
value_1.Data.SimpleItem[0].Value in ["1", "true"],
|
message_value.Data.SimpleItem[0].Value in ["1", "true"],
|
||||||
)
|
)
|
||||||
except (AttributeError, KeyError):
|
except (AttributeError, KeyError):
|
||||||
return None
|
return None
|
||||||
@ -292,8 +301,9 @@ async def async_parse_tamper_detector(uid: str, msg) -> Event | None:
|
|||||||
video_source = ""
|
video_source = ""
|
||||||
video_analytics = ""
|
video_analytics = ""
|
||||||
rule = ""
|
rule = ""
|
||||||
value_1 = msg.Message._value_1 # pylint: disable=protected-access
|
message_value = msg.Message._value_1 # pylint: disable=protected-access
|
||||||
for source in value_1.Source.SimpleItem:
|
topic_value = msg.Topic._value_1 # pylint: disable=protected-access
|
||||||
|
for source in message_value.Source.SimpleItem:
|
||||||
if source.Name == "VideoSourceConfigurationToken":
|
if source.Name == "VideoSourceConfigurationToken":
|
||||||
video_source = _normalize_video_source(source.Value)
|
video_source = _normalize_video_source(source.Value)
|
||||||
if source.Name == "VideoAnalyticsConfigurationToken":
|
if source.Name == "VideoAnalyticsConfigurationToken":
|
||||||
@ -302,12 +312,12 @@ async def async_parse_tamper_detector(uid: str, msg) -> Event | None:
|
|||||||
rule = source.Value
|
rule = source.Value
|
||||||
|
|
||||||
return Event(
|
return Event(
|
||||||
f"{uid}_{value_1}_{video_source}_{video_analytics}_{rule}",
|
f"{uid}_{topic_value}_{video_source}_{video_analytics}_{rule}",
|
||||||
"Tamper Detection",
|
"Tamper Detection",
|
||||||
"binary_sensor",
|
"binary_sensor",
|
||||||
"problem",
|
"problem",
|
||||||
None,
|
None,
|
||||||
value_1.Data.SimpleItem[0].Value == "true",
|
message_value.Data.SimpleItem[0].Value == "true",
|
||||||
EntityCategory.DIAGNOSTIC,
|
EntityCategory.DIAGNOSTIC,
|
||||||
)
|
)
|
||||||
except (AttributeError, KeyError):
|
except (AttributeError, KeyError):
|
||||||
@ -322,18 +332,19 @@ async def async_parse_dog_cat_detector(uid: str, msg) -> Event | None:
|
|||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
video_source = ""
|
video_source = ""
|
||||||
value_1 = msg.Message._value_1 # pylint: disable=protected-access
|
message_value = msg.Message._value_1 # pylint: disable=protected-access
|
||||||
for source in value_1.Source.SimpleItem:
|
topic_value = msg.Topic._value_1 # pylint: disable=protected-access
|
||||||
|
for source in message_value.Source.SimpleItem:
|
||||||
if source.Name == "Source":
|
if source.Name == "Source":
|
||||||
video_source = _normalize_video_source(source.Value)
|
video_source = _normalize_video_source(source.Value)
|
||||||
|
|
||||||
return Event(
|
return Event(
|
||||||
f"{uid}_{value_1}_{video_source}",
|
f"{uid}_{topic_value}_{video_source}",
|
||||||
"Pet Detection",
|
"Pet Detection",
|
||||||
"binary_sensor",
|
"binary_sensor",
|
||||||
"motion",
|
"motion",
|
||||||
None,
|
None,
|
||||||
value_1.Data.SimpleItem[0].Value == "true",
|
message_value.Data.SimpleItem[0].Value == "true",
|
||||||
)
|
)
|
||||||
except (AttributeError, KeyError):
|
except (AttributeError, KeyError):
|
||||||
return None
|
return None
|
||||||
@ -347,18 +358,19 @@ async def async_parse_vehicle_detector(uid: str, msg) -> Event | None:
|
|||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
video_source = ""
|
video_source = ""
|
||||||
value_1 = msg.Message._value_1 # pylint: disable=protected-access
|
message_value = msg.Message._value_1 # pylint: disable=protected-access
|
||||||
for source in value_1.Source.SimpleItem:
|
topic_value = msg.Topic._value_1 # pylint: disable=protected-access
|
||||||
|
for source in message_value.Source.SimpleItem:
|
||||||
if source.Name == "Source":
|
if source.Name == "Source":
|
||||||
video_source = _normalize_video_source(source.Value)
|
video_source = _normalize_video_source(source.Value)
|
||||||
|
|
||||||
return Event(
|
return Event(
|
||||||
f"{uid}_{value_1}_{video_source}",
|
f"{uid}_{topic_value}_{video_source}",
|
||||||
"Vehicle Detection",
|
"Vehicle Detection",
|
||||||
"binary_sensor",
|
"binary_sensor",
|
||||||
"motion",
|
"motion",
|
||||||
None,
|
None,
|
||||||
value_1.Data.SimpleItem[0].Value == "true",
|
message_value.Data.SimpleItem[0].Value == "true",
|
||||||
)
|
)
|
||||||
except (AttributeError, KeyError):
|
except (AttributeError, KeyError):
|
||||||
return None
|
return None
|
||||||
@ -372,18 +384,19 @@ async def async_parse_person_detector(uid: str, msg) -> Event | None:
|
|||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
video_source = ""
|
video_source = ""
|
||||||
value_1 = msg.Message._value_1 # pylint: disable=protected-access
|
message_value = msg.Message._value_1 # pylint: disable=protected-access
|
||||||
for source in value_1.Source.SimpleItem:
|
topic_value = msg.Topic._value_1 # pylint: disable=protected-access
|
||||||
|
for source in message_value.Source.SimpleItem:
|
||||||
if source.Name == "Source":
|
if source.Name == "Source":
|
||||||
video_source = _normalize_video_source(source.Value)
|
video_source = _normalize_video_source(source.Value)
|
||||||
|
|
||||||
return Event(
|
return Event(
|
||||||
f"{uid}_{value_1}_{video_source}",
|
f"{uid}_{topic_value}_{video_source}",
|
||||||
"Person Detection",
|
"Person Detection",
|
||||||
"binary_sensor",
|
"binary_sensor",
|
||||||
"motion",
|
"motion",
|
||||||
None,
|
None,
|
||||||
value_1.Data.SimpleItem[0].Value == "true",
|
message_value.Data.SimpleItem[0].Value == "true",
|
||||||
)
|
)
|
||||||
except (AttributeError, KeyError):
|
except (AttributeError, KeyError):
|
||||||
return None
|
return None
|
||||||
@ -397,18 +410,19 @@ async def async_parse_face_detector(uid: str, msg) -> Event | None:
|
|||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
video_source = ""
|
video_source = ""
|
||||||
value_1 = msg.Message._value_1 # pylint: disable=protected-access
|
message_value = msg.Message._value_1 # pylint: disable=protected-access
|
||||||
for source in value_1.Source.SimpleItem:
|
topic_value = msg.Topic._value_1 # pylint: disable=protected-access
|
||||||
|
for source in message_value.Source.SimpleItem:
|
||||||
if source.Name == "Source":
|
if source.Name == "Source":
|
||||||
video_source = _normalize_video_source(source.Value)
|
video_source = _normalize_video_source(source.Value)
|
||||||
|
|
||||||
return Event(
|
return Event(
|
||||||
f"{uid}_{value_1}_{video_source}",
|
f"{uid}_{topic_value}_{video_source}",
|
||||||
"Face Detection",
|
"Face Detection",
|
||||||
"binary_sensor",
|
"binary_sensor",
|
||||||
"motion",
|
"motion",
|
||||||
None,
|
None,
|
||||||
value_1.Data.SimpleItem[0].Value == "true",
|
message_value.Data.SimpleItem[0].Value == "true",
|
||||||
)
|
)
|
||||||
except (AttributeError, KeyError):
|
except (AttributeError, KeyError):
|
||||||
return None
|
return None
|
||||||
@ -422,18 +436,19 @@ async def async_parse_visitor_detector(uid: str, msg) -> Event | None:
|
|||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
video_source = ""
|
video_source = ""
|
||||||
value_1 = msg.Message._value_1 # pylint: disable=protected-access
|
message_value = msg.Message._value_1 # pylint: disable=protected-access
|
||||||
for source in value_1.Source.SimpleItem:
|
topic_value = msg.Topic._value_1 # pylint: disable=protected-access
|
||||||
|
for source in message_value.Source.SimpleItem:
|
||||||
if source.Name == "Source":
|
if source.Name == "Source":
|
||||||
video_source = _normalize_video_source(source.Value)
|
video_source = _normalize_video_source(source.Value)
|
||||||
|
|
||||||
return Event(
|
return Event(
|
||||||
f"{uid}_{value_1}_{video_source}",
|
f"{uid}_{topic_value}_{video_source}",
|
||||||
"Visitor Detection",
|
"Visitor Detection",
|
||||||
"binary_sensor",
|
"binary_sensor",
|
||||||
"occupancy",
|
"occupancy",
|
||||||
None,
|
None,
|
||||||
value_1.Data.SimpleItem[0].Value == "true",
|
message_value.Data.SimpleItem[0].Value == "true",
|
||||||
)
|
)
|
||||||
except (AttributeError, KeyError):
|
except (AttributeError, KeyError):
|
||||||
return None
|
return None
|
||||||
@ -446,15 +461,16 @@ async def async_parse_digital_input(uid: str, msg) -> Event | None:
|
|||||||
Topic: tns1:Device/Trigger/DigitalInput
|
Topic: tns1:Device/Trigger/DigitalInput
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
value_1 = msg.Message._value_1 # pylint: disable=protected-access
|
message_value = msg.Message._value_1 # pylint: disable=protected-access
|
||||||
source = value_1.Source.SimpleItem[0].Value
|
topic_value = msg.Topic._value_1 # pylint: disable=protected-access
|
||||||
|
source = message_value.Source.SimpleItem[0].Value
|
||||||
return Event(
|
return Event(
|
||||||
f"{uid}_{value_1}_{source}",
|
f"{uid}_{topic_value}_{source}",
|
||||||
"Digital Input",
|
"Digital Input",
|
||||||
"binary_sensor",
|
"binary_sensor",
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
value_1.Data.SimpleItem[0].Value == "true",
|
message_value.Data.SimpleItem[0].Value == "true",
|
||||||
)
|
)
|
||||||
except (AttributeError, KeyError):
|
except (AttributeError, KeyError):
|
||||||
return None
|
return None
|
||||||
@ -467,15 +483,16 @@ async def async_parse_relay(uid: str, msg) -> Event | None:
|
|||||||
Topic: tns1:Device/Trigger/Relay
|
Topic: tns1:Device/Trigger/Relay
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
value_1 = msg.Message._value_1 # pylint: disable=protected-access
|
message_value = msg.Message._value_1 # pylint: disable=protected-access
|
||||||
source = value_1.Source.SimpleItem[0].Value
|
topic_value = msg.Topic._value_1 # pylint: disable=protected-access
|
||||||
|
source = message_value.Source.SimpleItem[0].Value
|
||||||
return Event(
|
return Event(
|
||||||
f"{uid}_{value_1}_{source}",
|
f"{uid}_{topic_value}_{source}",
|
||||||
"Relay Triggered",
|
"Relay Triggered",
|
||||||
"binary_sensor",
|
"binary_sensor",
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
value_1.Data.SimpleItem[0].Value == "active",
|
message_value.Data.SimpleItem[0].Value == "active",
|
||||||
)
|
)
|
||||||
except (AttributeError, KeyError):
|
except (AttributeError, KeyError):
|
||||||
return None
|
return None
|
||||||
@ -488,15 +505,16 @@ async def async_parse_storage_failure(uid: str, msg) -> Event | None:
|
|||||||
Topic: tns1:Device/HardwareFailure/StorageFailure
|
Topic: tns1:Device/HardwareFailure/StorageFailure
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
value_1 = msg.Message._value_1 # pylint: disable=protected-access
|
message_value = msg.Message._value_1 # pylint: disable=protected-access
|
||||||
source = value_1.Source.SimpleItem[0].Value
|
topic_value = msg.Topic._value_1 # pylint: disable=protected-access
|
||||||
|
source = message_value.Source.SimpleItem[0].Value
|
||||||
return Event(
|
return Event(
|
||||||
f"{uid}_{value_1}_{source}",
|
f"{uid}_{topic_value}_{source}",
|
||||||
"Storage Failure",
|
"Storage Failure",
|
||||||
"binary_sensor",
|
"binary_sensor",
|
||||||
"problem",
|
"problem",
|
||||||
None,
|
None,
|
||||||
value_1.Data.SimpleItem[0].Value == "true",
|
message_value.Data.SimpleItem[0].Value == "true",
|
||||||
EntityCategory.DIAGNOSTIC,
|
EntityCategory.DIAGNOSTIC,
|
||||||
)
|
)
|
||||||
except (AttributeError, KeyError):
|
except (AttributeError, KeyError):
|
||||||
@ -510,13 +528,14 @@ async def async_parse_processor_usage(uid: str, msg) -> Event | None:
|
|||||||
Topic: tns1:Monitoring/ProcessorUsage
|
Topic: tns1:Monitoring/ProcessorUsage
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
value_1 = msg.Message._value_1 # pylint: disable=protected-access
|
message_value = msg.Message._value_1 # pylint: disable=protected-access
|
||||||
usage = float(value_1.Data.SimpleItem[0].Value)
|
topic_value = msg.Topic._value_1 # pylint: disable=protected-access
|
||||||
|
usage = float(message_value.Data.SimpleItem[0].Value)
|
||||||
if usage <= 1:
|
if usage <= 1:
|
||||||
usage *= 100
|
usage *= 100
|
||||||
|
|
||||||
return Event(
|
return Event(
|
||||||
f"{uid}_{value_1}",
|
f"{uid}_{topic_value}",
|
||||||
"Processor Usage",
|
"Processor Usage",
|
||||||
"sensor",
|
"sensor",
|
||||||
None,
|
None,
|
||||||
@ -535,10 +554,11 @@ async def async_parse_last_reboot(uid: str, msg) -> Event | None:
|
|||||||
Topic: tns1:Monitoring/OperatingTime/LastReboot
|
Topic: tns1:Monitoring/OperatingTime/LastReboot
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
value_1 = msg.Message._value_1 # pylint: disable=protected-access
|
message_value = msg.Message._value_1 # pylint: disable=protected-access
|
||||||
date_time = local_datetime_or_none(value_1.Data.SimpleItem[0].Value)
|
topic_value = msg.Topic._value_1 # pylint: disable=protected-access
|
||||||
|
date_time = local_datetime_or_none(message_value.Data.SimpleItem[0].Value)
|
||||||
return Event(
|
return Event(
|
||||||
f"{uid}_{value_1}",
|
f"{uid}_{topic_value}",
|
||||||
"Last Reboot",
|
"Last Reboot",
|
||||||
"sensor",
|
"sensor",
|
||||||
"timestamp",
|
"timestamp",
|
||||||
@ -557,10 +577,11 @@ async def async_parse_last_reset(uid: str, msg) -> Event | None:
|
|||||||
Topic: tns1:Monitoring/OperatingTime/LastReset
|
Topic: tns1:Monitoring/OperatingTime/LastReset
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
value_1 = msg.Message._value_1 # pylint: disable=protected-access
|
message_value = msg.Message._value_1 # pylint: disable=protected-access
|
||||||
date_time = local_datetime_or_none(value_1.Data.SimpleItem[0].Value)
|
topic_value = msg.Topic._value_1 # pylint: disable=protected-access
|
||||||
|
date_time = local_datetime_or_none(message_value.Data.SimpleItem[0].Value)
|
||||||
return Event(
|
return Event(
|
||||||
f"{uid}_{value_1}",
|
f"{uid}_{topic_value}",
|
||||||
"Last Reset",
|
"Last Reset",
|
||||||
"sensor",
|
"sensor",
|
||||||
"timestamp",
|
"timestamp",
|
||||||
@ -581,10 +602,11 @@ async def async_parse_backup_last(uid: str, msg) -> Event | None:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
value_1 = msg.Message._value_1 # pylint: disable=protected-access
|
message_value = msg.Message._value_1 # pylint: disable=protected-access
|
||||||
date_time = local_datetime_or_none(value_1.Data.SimpleItem[0].Value)
|
topic_value = msg.Topic._value_1 # pylint: disable=protected-access
|
||||||
|
date_time = local_datetime_or_none(message_value.Data.SimpleItem[0].Value)
|
||||||
return Event(
|
return Event(
|
||||||
f"{uid}_{value_1}",
|
f"{uid}_{topic_value}",
|
||||||
"Last Backup",
|
"Last Backup",
|
||||||
"sensor",
|
"sensor",
|
||||||
"timestamp",
|
"timestamp",
|
||||||
@ -604,10 +626,11 @@ async def async_parse_last_clock_sync(uid: str, msg) -> Event | None:
|
|||||||
Topic: tns1:Monitoring/OperatingTime/LastClockSynchronization
|
Topic: tns1:Monitoring/OperatingTime/LastClockSynchronization
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
value_1 = msg.Message._value_1 # pylint: disable=protected-access
|
message_value = msg.Message._value_1 # pylint: disable=protected-access
|
||||||
date_time = local_datetime_or_none(value_1.Data.SimpleItem[0].Value)
|
topic_value = msg.Topic._value_1 # pylint: disable=protected-access
|
||||||
|
date_time = local_datetime_or_none(message_value.Data.SimpleItem[0].Value)
|
||||||
return Event(
|
return Event(
|
||||||
f"{uid}_{value_1}",
|
f"{uid}_{topic_value}",
|
||||||
"Last Clock Synchronization",
|
"Last Clock Synchronization",
|
||||||
"sensor",
|
"sensor",
|
||||||
"timestamp",
|
"timestamp",
|
||||||
@ -628,15 +651,16 @@ async def async_parse_jobstate(uid: str, msg) -> Event | None:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
value_1 = msg.Message._value_1 # pylint: disable=protected-access
|
message_value = msg.Message._value_1 # pylint: disable=protected-access
|
||||||
source = value_1.Source.SimpleItem[0].Value
|
topic_value = msg.Topic._value_1 # pylint: disable=protected-access
|
||||||
|
source = message_value.Source.SimpleItem[0].Value
|
||||||
return Event(
|
return Event(
|
||||||
f"{uid}_{value_1}_{source}",
|
f"{uid}_{topic_value}_{source}",
|
||||||
"Recording Job State",
|
"Recording Job State",
|
||||||
"binary_sensor",
|
"binary_sensor",
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
value_1.Data.SimpleItem[0].Value == "Active",
|
message_value.Data.SimpleItem[0].Value == "Active",
|
||||||
EntityCategory.DIAGNOSTIC,
|
EntityCategory.DIAGNOSTIC,
|
||||||
)
|
)
|
||||||
except (AttributeError, KeyError):
|
except (AttributeError, KeyError):
|
||||||
@ -653,8 +677,9 @@ async def async_parse_linedetector_crossed(uid: str, msg) -> Event | None:
|
|||||||
video_source = ""
|
video_source = ""
|
||||||
video_analytics = ""
|
video_analytics = ""
|
||||||
rule = ""
|
rule = ""
|
||||||
value_1 = msg.Message._value_1 # pylint: disable=protected-access
|
message_value = msg.Message._value_1 # pylint: disable=protected-access
|
||||||
for source in value_1.Source.SimpleItem:
|
topic_value = msg.Topic._value_1 # pylint: disable=protected-access
|
||||||
|
for source in message_value.Source.SimpleItem:
|
||||||
if source.Name == "VideoSourceConfigurationToken":
|
if source.Name == "VideoSourceConfigurationToken":
|
||||||
video_source = source.Value
|
video_source = source.Value
|
||||||
if source.Name == "VideoAnalyticsConfigurationToken":
|
if source.Name == "VideoAnalyticsConfigurationToken":
|
||||||
@ -663,12 +688,12 @@ async def async_parse_linedetector_crossed(uid: str, msg) -> Event | None:
|
|||||||
rule = source.Value
|
rule = source.Value
|
||||||
|
|
||||||
return Event(
|
return Event(
|
||||||
f"{uid}_{value_1}_{video_source}_{video_analytics}_{rule}",
|
f"{uid}_{topic_value}_{video_source}_{video_analytics}_{rule}",
|
||||||
"Line Detector Crossed",
|
"Line Detector Crossed",
|
||||||
"sensor",
|
"sensor",
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
value_1.Data.SimpleItem[0].Value,
|
message_value.Data.SimpleItem[0].Value,
|
||||||
EntityCategory.DIAGNOSTIC,
|
EntityCategory.DIAGNOSTIC,
|
||||||
)
|
)
|
||||||
except (AttributeError, KeyError):
|
except (AttributeError, KeyError):
|
||||||
@ -685,8 +710,9 @@ async def async_parse_count_aggregation_counter(uid: str, msg) -> Event | None:
|
|||||||
video_source = ""
|
video_source = ""
|
||||||
video_analytics = ""
|
video_analytics = ""
|
||||||
rule = ""
|
rule = ""
|
||||||
value_1 = msg.Message._value_1 # pylint: disable=protected-access
|
message_value = msg.Message._value_1 # pylint: disable=protected-access
|
||||||
for source in value_1.Source.SimpleItem:
|
topic_value = msg.Topic._value_1 # pylint: disable=protected-access
|
||||||
|
for source in message_value.Source.SimpleItem:
|
||||||
if source.Name == "VideoSourceConfigurationToken":
|
if source.Name == "VideoSourceConfigurationToken":
|
||||||
video_source = _normalize_video_source(source.Value)
|
video_source = _normalize_video_source(source.Value)
|
||||||
if source.Name == "VideoAnalyticsConfigurationToken":
|
if source.Name == "VideoAnalyticsConfigurationToken":
|
||||||
@ -695,12 +721,12 @@ async def async_parse_count_aggregation_counter(uid: str, msg) -> Event | None:
|
|||||||
rule = source.Value
|
rule = source.Value
|
||||||
|
|
||||||
return Event(
|
return Event(
|
||||||
f"{uid}_{value_1}_{video_source}_{video_analytics}_{rule}",
|
f"{uid}_{topic_value}_{video_source}_{video_analytics}_{rule}",
|
||||||
"Count Aggregation Counter",
|
"Count Aggregation Counter",
|
||||||
"sensor",
|
"sensor",
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
value_1.Data.SimpleItem[0].Value,
|
message_value.Data.SimpleItem[0].Value,
|
||||||
EntityCategory.DIAGNOSTIC,
|
EntityCategory.DIAGNOSTIC,
|
||||||
)
|
)
|
||||||
except (AttributeError, KeyError):
|
except (AttributeError, KeyError):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user