mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Add rule parser for onvif LineDetector and CountAggregation (#91885)
This commit is contained in:
parent
e25885b943
commit
c3262ebdb3
@ -611,3 +611,67 @@ async def async_parse_jobstate(uid: str, msg) -> Event | None:
|
|||||||
)
|
)
|
||||||
except (AttributeError, KeyError):
|
except (AttributeError, KeyError):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
@PARSERS.register("tns1:RuleEngine/LineDetector/Crossed")
|
||||||
|
# pylint: disable=protected-access
|
||||||
|
async def async_parse_linedetector_crossed(uid: str, msg) -> Event | None:
|
||||||
|
"""Handle parsing event message.
|
||||||
|
|
||||||
|
Topic: tns1:RuleEngine/LineDetector/Crossed
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
video_source = ""
|
||||||
|
video_analytics = ""
|
||||||
|
rule = ""
|
||||||
|
for source in msg.Message._value_1.Source.SimpleItem:
|
||||||
|
if source.Name == "VideoSourceConfigurationToken":
|
||||||
|
video_source = source.Value
|
||||||
|
if source.Name == "VideoAnalyticsConfigurationToken":
|
||||||
|
video_analytics = source.Value
|
||||||
|
if source.Name == "Rule":
|
||||||
|
rule = source.Value
|
||||||
|
|
||||||
|
return Event(
|
||||||
|
f"{uid}_{msg.Topic._value_1}_{video_source}_{video_analytics}_{rule}",
|
||||||
|
"Line Detector Crossed",
|
||||||
|
"sensor",
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
msg.Message._value_1.Data.SimpleItem[0].Value,
|
||||||
|
EntityCategory.DIAGNOSTIC,
|
||||||
|
)
|
||||||
|
except (AttributeError, KeyError):
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
@PARSERS.register("tns1:RuleEngine/CountAggregation/Counter")
|
||||||
|
# pylint: disable=protected-access
|
||||||
|
async def async_parse_count_aggregation_counter(uid: str, msg) -> Event | None:
|
||||||
|
"""Handle parsing event message.
|
||||||
|
|
||||||
|
Topic: tns1:RuleEngine/CountAggregation/Counter
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
video_source = ""
|
||||||
|
video_analytics = ""
|
||||||
|
rule = ""
|
||||||
|
for source in msg.Message._value_1.Source.SimpleItem:
|
||||||
|
if source.Name == "VideoSourceConfigurationToken":
|
||||||
|
video_source = source.Value
|
||||||
|
if source.Name == "VideoAnalyticsConfigurationToken":
|
||||||
|
video_analytics = source.Value
|
||||||
|
if source.Name == "Rule":
|
||||||
|
rule = source.Value
|
||||||
|
|
||||||
|
return Event(
|
||||||
|
f"{uid}_{msg.Topic._value_1}_{video_source}_{video_analytics}_{rule}",
|
||||||
|
"Count Aggregation Counter",
|
||||||
|
"sensor",
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
msg.Message._value_1.Data.SimpleItem[0].Value,
|
||||||
|
EntityCategory.DIAGNOSTIC,
|
||||||
|
)
|
||||||
|
except (AttributeError, KeyError):
|
||||||
|
return None
|
||||||
|
Loading…
x
Reference in New Issue
Block a user