Remove unnecessary block use of pylint disable in onvif (#100194)
parent
c178388956
commit
d495208995
|
@ -142,7 +142,6 @@ class EventManager:
|
|||
for update_callback in self._listeners:
|
||||
update_callback()
|
||||
|
||||
# pylint: disable=protected-access
|
||||
async def async_parse_messages(self, messages) -> None:
|
||||
"""Parse notification message."""
|
||||
unique_id = self.unique_id
|
||||
|
@ -160,7 +159,7 @@ class EventManager:
|
|||
#
|
||||
# Our parser expects the topic to be
|
||||
# tns1:RuleEngine/CellMotionDetector/Motion
|
||||
topic = msg.Topic._value_1.rstrip("/.")
|
||||
topic = msg.Topic._value_1.rstrip("/.") # pylint: disable=protected-access
|
||||
|
||||
if not (parser := PARSERS.get(topic)):
|
||||
if topic not in UNHANDLED_TOPICS:
|
||||
|
|
|
@ -42,21 +42,21 @@ def local_datetime_or_none(value: str) -> datetime.datetime | None:
|
|||
|
||||
|
||||
@PARSERS.register("tns1:VideoSource/MotionAlarm")
|
||||
# pylint: disable=protected-access
|
||||
async def async_parse_motion_alarm(uid: str, msg) -> Event | None:
|
||||
"""Handle parsing event message.
|
||||
|
||||
Topic: tns1:VideoSource/MotionAlarm
|
||||
"""
|
||||
try:
|
||||
source = msg.Message._value_1.Source.SimpleItem[0].Value
|
||||
value_1 = msg.Message._value_1 # pylint: disable=protected-access
|
||||
source = value_1.Source.SimpleItem[0].Value
|
||||
return Event(
|
||||
f"{uid}_{msg.Topic._value_1}_{source}",
|
||||
f"{uid}_{value_1}_{source}",
|
||||
"Motion Alarm",
|
||||
"binary_sensor",
|
||||
"motion",
|
||||
None,
|
||||
msg.Message._value_1.Data.SimpleItem[0].Value == "true",
|
||||
value_1.Data.SimpleItem[0].Value == "true",
|
||||
)
|
||||
except (AttributeError, KeyError):
|
||||
return None
|
||||
|
@ -65,21 +65,21 @@ async def async_parse_motion_alarm(uid: str, msg) -> Event | None:
|
|||
@PARSERS.register("tns1:VideoSource/ImageTooBlurry/AnalyticsService")
|
||||
@PARSERS.register("tns1:VideoSource/ImageTooBlurry/ImagingService")
|
||||
@PARSERS.register("tns1:VideoSource/ImageTooBlurry/RecordingService")
|
||||
# pylint: disable=protected-access
|
||||
async def async_parse_image_too_blurry(uid: str, msg) -> Event | None:
|
||||
"""Handle parsing event message.
|
||||
|
||||
Topic: tns1:VideoSource/ImageTooBlurry/*
|
||||
"""
|
||||
try:
|
||||
source = msg.Message._value_1.Source.SimpleItem[0].Value
|
||||
value_1 = msg.Message._value_1 # pylint: disable=protected-access
|
||||
source = value_1.Source.SimpleItem[0].Value
|
||||
return Event(
|
||||
f"{uid}_{msg.Topic._value_1}_{source}",
|
||||
f"{uid}_{value_1}_{source}",
|
||||
"Image Too Blurry",
|
||||
"binary_sensor",
|
||||
"problem",
|
||||
None,
|
||||
msg.Message._value_1.Data.SimpleItem[0].Value == "true",
|
||||
value_1.Data.SimpleItem[0].Value == "true",
|
||||
EntityCategory.DIAGNOSTIC,
|
||||
)
|
||||
except (AttributeError, KeyError):
|
||||
|
@ -89,21 +89,21 @@ async def async_parse_image_too_blurry(uid: str, msg) -> Event | None:
|
|||
@PARSERS.register("tns1:VideoSource/ImageTooDark/AnalyticsService")
|
||||
@PARSERS.register("tns1:VideoSource/ImageTooDark/ImagingService")
|
||||
@PARSERS.register("tns1:VideoSource/ImageTooDark/RecordingService")
|
||||
# pylint: disable=protected-access
|
||||
async def async_parse_image_too_dark(uid: str, msg) -> Event | None:
|
||||
"""Handle parsing event message.
|
||||
|
||||
Topic: tns1:VideoSource/ImageTooDark/*
|
||||
"""
|
||||
try:
|
||||
source = msg.Message._value_1.Source.SimpleItem[0].Value
|
||||
value_1 = msg.Message._value_1 # pylint: disable=protected-access
|
||||
source = value_1.Source.SimpleItem[0].Value
|
||||
return Event(
|
||||
f"{uid}_{msg.Topic._value_1}_{source}",
|
||||
f"{uid}_{value_1}_{source}",
|
||||
"Image Too Dark",
|
||||
"binary_sensor",
|
||||
"problem",
|
||||
None,
|
||||
msg.Message._value_1.Data.SimpleItem[0].Value == "true",
|
||||
value_1.Data.SimpleItem[0].Value == "true",
|
||||
EntityCategory.DIAGNOSTIC,
|
||||
)
|
||||
except (AttributeError, KeyError):
|
||||
|
@ -113,21 +113,21 @@ async def async_parse_image_too_dark(uid: str, msg) -> Event | None:
|
|||
@PARSERS.register("tns1:VideoSource/ImageTooBright/AnalyticsService")
|
||||
@PARSERS.register("tns1:VideoSource/ImageTooBright/ImagingService")
|
||||
@PARSERS.register("tns1:VideoSource/ImageTooBright/RecordingService")
|
||||
# pylint: disable=protected-access
|
||||
async def async_parse_image_too_bright(uid: str, msg) -> Event | None:
|
||||
"""Handle parsing event message.
|
||||
|
||||
Topic: tns1:VideoSource/ImageTooBright/*
|
||||
"""
|
||||
try:
|
||||
source = msg.Message._value_1.Source.SimpleItem[0].Value
|
||||
value_1 = msg.Message._value_1 # pylint: disable=protected-access
|
||||
source = value_1.Source.SimpleItem[0].Value
|
||||
return Event(
|
||||
f"{uid}_{msg.Topic._value_1}_{source}",
|
||||
f"{uid}_{value_1}_{source}",
|
||||
"Image Too Bright",
|
||||
"binary_sensor",
|
||||
"problem",
|
||||
None,
|
||||
msg.Message._value_1.Data.SimpleItem[0].Value == "true",
|
||||
value_1.Data.SimpleItem[0].Value == "true",
|
||||
EntityCategory.DIAGNOSTIC,
|
||||
)
|
||||
except (AttributeError, KeyError):
|
||||
|
@ -137,28 +137,27 @@ async def async_parse_image_too_bright(uid: str, msg) -> Event | None:
|
|||
@PARSERS.register("tns1:VideoSource/GlobalSceneChange/AnalyticsService")
|
||||
@PARSERS.register("tns1:VideoSource/GlobalSceneChange/ImagingService")
|
||||
@PARSERS.register("tns1:VideoSource/GlobalSceneChange/RecordingService")
|
||||
# pylint: disable=protected-access
|
||||
async def async_parse_scene_change(uid: str, msg) -> Event | None:
|
||||
"""Handle parsing event message.
|
||||
|
||||
Topic: tns1:VideoSource/GlobalSceneChange/*
|
||||
"""
|
||||
try:
|
||||
source = msg.Message._value_1.Source.SimpleItem[0].Value
|
||||
value_1 = msg.Message._value_1 # pylint: disable=protected-access
|
||||
source = value_1.Source.SimpleItem[0].Value
|
||||
return Event(
|
||||
f"{uid}_{msg.Topic._value_1}_{source}",
|
||||
f"{uid}_{value_1}_{source}",
|
||||
"Global Scene Change",
|
||||
"binary_sensor",
|
||||
"problem",
|
||||
None,
|
||||
msg.Message._value_1.Data.SimpleItem[0].Value == "true",
|
||||
value_1.Data.SimpleItem[0].Value == "true",
|
||||
)
|
||||
except (AttributeError, KeyError):
|
||||
return None
|
||||
|
||||
|
||||
@PARSERS.register("tns1:AudioAnalytics/Audio/DetectedSound")
|
||||
# pylint: disable=protected-access
|
||||
async def async_parse_detected_sound(uid: str, msg) -> Event | None:
|
||||
"""Handle parsing event message.
|
||||
|
||||
|
@ -168,7 +167,8 @@ async def async_parse_detected_sound(uid: str, msg) -> Event | None:
|
|||
audio_source = ""
|
||||
audio_analytics = ""
|
||||
rule = ""
|
||||
for source in msg.Message._value_1.Source.SimpleItem:
|
||||
value_1 = msg.Message._value_1 # pylint: disable=protected-access
|
||||
for source in value_1.Source.SimpleItem:
|
||||
if source.Name == "AudioSourceConfigurationToken":
|
||||
audio_source = source.Value
|
||||
if source.Name == "AudioAnalyticsConfigurationToken":
|
||||
|
@ -177,19 +177,18 @@ async def async_parse_detected_sound(uid: str, msg) -> Event | None:
|
|||
rule = source.Value
|
||||
|
||||
return Event(
|
||||
f"{uid}_{msg.Topic._value_1}_{audio_source}_{audio_analytics}_{rule}",
|
||||
f"{uid}_{value_1}_{audio_source}_{audio_analytics}_{rule}",
|
||||
"Detected Sound",
|
||||
"binary_sensor",
|
||||
"sound",
|
||||
None,
|
||||
msg.Message._value_1.Data.SimpleItem[0].Value == "true",
|
||||
value_1.Data.SimpleItem[0].Value == "true",
|
||||
)
|
||||
except (AttributeError, KeyError):
|
||||
return None
|
||||
|
||||
|
||||
@PARSERS.register("tns1:RuleEngine/FieldDetector/ObjectsInside")
|
||||
# pylint: disable=protected-access
|
||||
async def async_parse_field_detector(uid: str, msg) -> Event | None:
|
||||
"""Handle parsing event message.
|
||||
|
||||
|
@ -199,7 +198,8 @@ async def async_parse_field_detector(uid: str, msg) -> Event | None:
|
|||
video_source = ""
|
||||
video_analytics = ""
|
||||
rule = ""
|
||||
for source in msg.Message._value_1.Source.SimpleItem:
|
||||
value_1 = msg.Message._value_1 # pylint: disable=protected-access
|
||||
for source in value_1.Source.SimpleItem:
|
||||
if source.Name == "VideoSourceConfigurationToken":
|
||||
video_source = _normalize_video_source(source.Value)
|
||||
if source.Name == "VideoAnalyticsConfigurationToken":
|
||||
|
@ -208,12 +208,12 @@ async def async_parse_field_detector(uid: str, msg) -> Event | None:
|
|||
rule = source.Value
|
||||
|
||||
evt = Event(
|
||||
f"{uid}_{msg.Topic._value_1}_{video_source}_{video_analytics}_{rule}",
|
||||
f"{uid}_{value_1}_{video_source}_{video_analytics}_{rule}",
|
||||
"Field Detection",
|
||||
"binary_sensor",
|
||||
"motion",
|
||||
None,
|
||||
msg.Message._value_1.Data.SimpleItem[0].Value == "true",
|
||||
value_1.Data.SimpleItem[0].Value == "true",
|
||||
)
|
||||
return evt
|
||||
except (AttributeError, KeyError):
|
||||
|
@ -221,7 +221,6 @@ async def async_parse_field_detector(uid: str, msg) -> Event | None:
|
|||
|
||||
|
||||
@PARSERS.register("tns1:RuleEngine/CellMotionDetector/Motion")
|
||||
# pylint: disable=protected-access
|
||||
async def async_parse_cell_motion_detector(uid: str, msg) -> Event | None:
|
||||
"""Handle parsing event message.
|
||||
|
||||
|
@ -231,7 +230,8 @@ async def async_parse_cell_motion_detector(uid: str, msg) -> Event | None:
|
|||
video_source = ""
|
||||
video_analytics = ""
|
||||
rule = ""
|
||||
for source in msg.Message._value_1.Source.SimpleItem:
|
||||
value_1 = msg.Message._value_1 # pylint: disable=protected-access
|
||||
for source in value_1.Source.SimpleItem:
|
||||
if source.Name == "VideoSourceConfigurationToken":
|
||||
video_source = _normalize_video_source(source.Value)
|
||||
if source.Name == "VideoAnalyticsConfigurationToken":
|
||||
|
@ -240,19 +240,18 @@ async def async_parse_cell_motion_detector(uid: str, msg) -> Event | None:
|
|||
rule = source.Value
|
||||
|
||||
return Event(
|
||||
f"{uid}_{msg.Topic._value_1}_{video_source}_{video_analytics}_{rule}",
|
||||
f"{uid}_{value_1}_{video_source}_{video_analytics}_{rule}",
|
||||
"Cell Motion Detection",
|
||||
"binary_sensor",
|
||||
"motion",
|
||||
None,
|
||||
msg.Message._value_1.Data.SimpleItem[0].Value == "true",
|
||||
value_1.Data.SimpleItem[0].Value == "true",
|
||||
)
|
||||
except (AttributeError, KeyError):
|
||||
return None
|
||||
|
||||
|
||||
@PARSERS.register("tns1:RuleEngine/MotionRegionDetector/Motion")
|
||||
# pylint: disable=protected-access
|
||||
async def async_parse_motion_region_detector(uid: str, msg) -> Event | None:
|
||||
"""Handle parsing event message.
|
||||
|
||||
|
@ -262,7 +261,8 @@ async def async_parse_motion_region_detector(uid: str, msg) -> Event | None:
|
|||
video_source = ""
|
||||
video_analytics = ""
|
||||
rule = ""
|
||||
for source in msg.Message._value_1.Source.SimpleItem:
|
||||
value_1 = msg.Message._value_1 # pylint: disable=protected-access
|
||||
for source in value_1.Source.SimpleItem:
|
||||
if source.Name == "VideoSourceConfigurationToken":
|
||||
video_source = _normalize_video_source(source.Value)
|
||||
if source.Name == "VideoAnalyticsConfigurationToken":
|
||||
|
@ -271,19 +271,18 @@ async def async_parse_motion_region_detector(uid: str, msg) -> Event | None:
|
|||
rule = source.Value
|
||||
|
||||
return Event(
|
||||
f"{uid}_{msg.Topic._value_1}_{video_source}_{video_analytics}_{rule}",
|
||||
f"{uid}_{value_1}_{video_source}_{video_analytics}_{rule}",
|
||||
"Motion Region Detection",
|
||||
"binary_sensor",
|
||||
"motion",
|
||||
None,
|
||||
msg.Message._value_1.Data.SimpleItem[0].Value in ["1", "true"],
|
||||
value_1.Data.SimpleItem[0].Value in ["1", "true"],
|
||||
)
|
||||
except (AttributeError, KeyError):
|
||||
return None
|
||||
|
||||
|
||||
@PARSERS.register("tns1:RuleEngine/TamperDetector/Tamper")
|
||||
# pylint: disable=protected-access
|
||||
async def async_parse_tamper_detector(uid: str, msg) -> Event | None:
|
||||
"""Handle parsing event message.
|
||||
|
||||
|
@ -293,7 +292,8 @@ async def async_parse_tamper_detector(uid: str, msg) -> Event | None:
|
|||
video_source = ""
|
||||
video_analytics = ""
|
||||
rule = ""
|
||||
for source in msg.Message._value_1.Source.SimpleItem:
|
||||
value_1 = msg.Message._value_1 # pylint: disable=protected-access
|
||||
for source in value_1.Source.SimpleItem:
|
||||
if source.Name == "VideoSourceConfigurationToken":
|
||||
video_source = _normalize_video_source(source.Value)
|
||||
if source.Name == "VideoAnalyticsConfigurationToken":
|
||||
|
@ -302,12 +302,12 @@ async def async_parse_tamper_detector(uid: str, msg) -> Event | None:
|
|||
rule = source.Value
|
||||
|
||||
return Event(
|
||||
f"{uid}_{msg.Topic._value_1}_{video_source}_{video_analytics}_{rule}",
|
||||
f"{uid}_{value_1}_{video_source}_{video_analytics}_{rule}",
|
||||
"Tamper Detection",
|
||||
"binary_sensor",
|
||||
"problem",
|
||||
None,
|
||||
msg.Message._value_1.Data.SimpleItem[0].Value == "true",
|
||||
value_1.Data.SimpleItem[0].Value == "true",
|
||||
EntityCategory.DIAGNOSTIC,
|
||||
)
|
||||
except (AttributeError, KeyError):
|
||||
|
@ -315,7 +315,6 @@ async def async_parse_tamper_detector(uid: str, msg) -> Event | None:
|
|||
|
||||
|
||||
@PARSERS.register("tns1:RuleEngine/MyRuleDetector/DogCatDetect")
|
||||
# pylint: disable=protected-access
|
||||
async def async_parse_dog_cat_detector(uid: str, msg) -> Event | None:
|
||||
"""Handle parsing event message.
|
||||
|
||||
|
@ -323,24 +322,24 @@ async def async_parse_dog_cat_detector(uid: str, msg) -> Event | None:
|
|||
"""
|
||||
try:
|
||||
video_source = ""
|
||||
for source in msg.Message._value_1.Source.SimpleItem:
|
||||
value_1 = msg.Message._value_1 # pylint: disable=protected-access
|
||||
for source in value_1.Source.SimpleItem:
|
||||
if source.Name == "Source":
|
||||
video_source = _normalize_video_source(source.Value)
|
||||
|
||||
return Event(
|
||||
f"{uid}_{msg.Topic._value_1}_{video_source}",
|
||||
f"{uid}_{value_1}_{video_source}",
|
||||
"Pet Detection",
|
||||
"binary_sensor",
|
||||
"motion",
|
||||
None,
|
||||
msg.Message._value_1.Data.SimpleItem[0].Value == "true",
|
||||
value_1.Data.SimpleItem[0].Value == "true",
|
||||
)
|
||||
except (AttributeError, KeyError):
|
||||
return None
|
||||
|
||||
|
||||
@PARSERS.register("tns1:RuleEngine/MyRuleDetector/VehicleDetect")
|
||||
# pylint: disable=protected-access
|
||||
async def async_parse_vehicle_detector(uid: str, msg) -> Event | None:
|
||||
"""Handle parsing event message.
|
||||
|
||||
|
@ -348,24 +347,24 @@ async def async_parse_vehicle_detector(uid: str, msg) -> Event | None:
|
|||
"""
|
||||
try:
|
||||
video_source = ""
|
||||
for source in msg.Message._value_1.Source.SimpleItem:
|
||||
value_1 = msg.Message._value_1 # pylint: disable=protected-access
|
||||
for source in value_1.Source.SimpleItem:
|
||||
if source.Name == "Source":
|
||||
video_source = _normalize_video_source(source.Value)
|
||||
|
||||
return Event(
|
||||
f"{uid}_{msg.Topic._value_1}_{video_source}",
|
||||
f"{uid}_{value_1}_{video_source}",
|
||||
"Vehicle Detection",
|
||||
"binary_sensor",
|
||||
"motion",
|
||||
None,
|
||||
msg.Message._value_1.Data.SimpleItem[0].Value == "true",
|
||||
value_1.Data.SimpleItem[0].Value == "true",
|
||||
)
|
||||
except (AttributeError, KeyError):
|
||||
return None
|
||||
|
||||
|
||||
@PARSERS.register("tns1:RuleEngine/MyRuleDetector/PeopleDetect")
|
||||
# pylint: disable=protected-access
|
||||
async def async_parse_person_detector(uid: str, msg) -> Event | None:
|
||||
"""Handle parsing event message.
|
||||
|
||||
|
@ -373,24 +372,24 @@ async def async_parse_person_detector(uid: str, msg) -> Event | None:
|
|||
"""
|
||||
try:
|
||||
video_source = ""
|
||||
for source in msg.Message._value_1.Source.SimpleItem:
|
||||
value_1 = msg.Message._value_1 # pylint: disable=protected-access
|
||||
for source in value_1.Source.SimpleItem:
|
||||
if source.Name == "Source":
|
||||
video_source = _normalize_video_source(source.Value)
|
||||
|
||||
return Event(
|
||||
f"{uid}_{msg.Topic._value_1}_{video_source}",
|
||||
f"{uid}_{value_1}_{video_source}",
|
||||
"Person Detection",
|
||||
"binary_sensor",
|
||||
"motion",
|
||||
None,
|
||||
msg.Message._value_1.Data.SimpleItem[0].Value == "true",
|
||||
value_1.Data.SimpleItem[0].Value == "true",
|
||||
)
|
||||
except (AttributeError, KeyError):
|
||||
return None
|
||||
|
||||
|
||||
@PARSERS.register("tns1:RuleEngine/MyRuleDetector/FaceDetect")
|
||||
# pylint: disable=protected-access
|
||||
async def async_parse_face_detector(uid: str, msg) -> Event | None:
|
||||
"""Handle parsing event message.
|
||||
|
||||
|
@ -398,24 +397,24 @@ async def async_parse_face_detector(uid: str, msg) -> Event | None:
|
|||
"""
|
||||
try:
|
||||
video_source = ""
|
||||
for source in msg.Message._value_1.Source.SimpleItem:
|
||||
value_1 = msg.Message._value_1 # pylint: disable=protected-access
|
||||
for source in value_1.Source.SimpleItem:
|
||||
if source.Name == "Source":
|
||||
video_source = _normalize_video_source(source.Value)
|
||||
|
||||
return Event(
|
||||
f"{uid}_{msg.Topic._value_1}_{video_source}",
|
||||
f"{uid}_{value_1}_{video_source}",
|
||||
"Face Detection",
|
||||
"binary_sensor",
|
||||
"motion",
|
||||
None,
|
||||
msg.Message._value_1.Data.SimpleItem[0].Value == "true",
|
||||
value_1.Data.SimpleItem[0].Value == "true",
|
||||
)
|
||||
except (AttributeError, KeyError):
|
||||
return None
|
||||
|
||||
|
||||
@PARSERS.register("tns1:RuleEngine/MyRuleDetector/Visitor")
|
||||
# pylint: disable=protected-access
|
||||
async def async_parse_visitor_detector(uid: str, msg) -> Event | None:
|
||||
"""Handle parsing event message.
|
||||
|
||||
|
@ -423,80 +422,81 @@ async def async_parse_visitor_detector(uid: str, msg) -> Event | None:
|
|||
"""
|
||||
try:
|
||||
video_source = ""
|
||||
for source in msg.Message._value_1.Source.SimpleItem:
|
||||
value_1 = msg.Message._value_1 # pylint: disable=protected-access
|
||||
for source in value_1.Source.SimpleItem:
|
||||
if source.Name == "Source":
|
||||
video_source = _normalize_video_source(source.Value)
|
||||
|
||||
return Event(
|
||||
f"{uid}_{msg.Topic._value_1}_{video_source}",
|
||||
f"{uid}_{value_1}_{video_source}",
|
||||
"Visitor Detection",
|
||||
"binary_sensor",
|
||||
"occupancy",
|
||||
None,
|
||||
msg.Message._value_1.Data.SimpleItem[0].Value == "true",
|
||||
value_1.Data.SimpleItem[0].Value == "true",
|
||||
)
|
||||
except (AttributeError, KeyError):
|
||||
return None
|
||||
|
||||
|
||||
@PARSERS.register("tns1:Device/Trigger/DigitalInput")
|
||||
# pylint: disable=protected-access
|
||||
async def async_parse_digital_input(uid: str, msg) -> Event | None:
|
||||
"""Handle parsing event message.
|
||||
|
||||
Topic: tns1:Device/Trigger/DigitalInput
|
||||
"""
|
||||
try:
|
||||
source = msg.Message._value_1.Source.SimpleItem[0].Value
|
||||
value_1 = msg.Message._value_1 # pylint: disable=protected-access
|
||||
source = value_1.Source.SimpleItem[0].Value
|
||||
return Event(
|
||||
f"{uid}_{msg.Topic._value_1}_{source}",
|
||||
f"{uid}_{value_1}_{source}",
|
||||
"Digital Input",
|
||||
"binary_sensor",
|
||||
None,
|
||||
None,
|
||||
msg.Message._value_1.Data.SimpleItem[0].Value == "true",
|
||||
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 | None:
|
||||
"""Handle parsing event message.
|
||||
|
||||
Topic: tns1:Device/Trigger/Relay
|
||||
"""
|
||||
try:
|
||||
source = msg.Message._value_1.Source.SimpleItem[0].Value
|
||||
value_1 = msg.Message._value_1 # pylint: disable=protected-access
|
||||
source = value_1.Source.SimpleItem[0].Value
|
||||
return Event(
|
||||
f"{uid}_{msg.Topic._value_1}_{source}",
|
||||
f"{uid}_{value_1}_{source}",
|
||||
"Relay Triggered",
|
||||
"binary_sensor",
|
||||
None,
|
||||
None,
|
||||
msg.Message._value_1.Data.SimpleItem[0].Value == "active",
|
||||
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 | None:
|
||||
"""Handle parsing event message.
|
||||
|
||||
Topic: tns1:Device/HardwareFailure/StorageFailure
|
||||
"""
|
||||
try:
|
||||
source = msg.Message._value_1.Source.SimpleItem[0].Value
|
||||
value_1 = msg.Message._value_1 # pylint: disable=protected-access
|
||||
source = value_1.Source.SimpleItem[0].Value
|
||||
return Event(
|
||||
f"{uid}_{msg.Topic._value_1}_{source}",
|
||||
f"{uid}_{value_1}_{source}",
|
||||
"Storage Failure",
|
||||
"binary_sensor",
|
||||
"problem",
|
||||
None,
|
||||
msg.Message._value_1.Data.SimpleItem[0].Value == "true",
|
||||
value_1.Data.SimpleItem[0].Value == "true",
|
||||
EntityCategory.DIAGNOSTIC,
|
||||
)
|
||||
except (AttributeError, KeyError):
|
||||
|
@ -504,19 +504,19 @@ async def async_parse_storage_failure(uid: str, msg) -> Event | None:
|
|||
|
||||
|
||||
@PARSERS.register("tns1:Monitoring/ProcessorUsage")
|
||||
# pylint: disable=protected-access
|
||||
async def async_parse_processor_usage(uid: str, msg) -> Event | None:
|
||||
"""Handle parsing event message.
|
||||
|
||||
Topic: tns1:Monitoring/ProcessorUsage
|
||||
"""
|
||||
try:
|
||||
usage = float(msg.Message._value_1.Data.SimpleItem[0].Value)
|
||||
value_1 = msg.Message._value_1 # pylint: disable=protected-access
|
||||
usage = float(value_1.Data.SimpleItem[0].Value)
|
||||
if usage <= 1:
|
||||
usage *= 100
|
||||
|
||||
return Event(
|
||||
f"{uid}_{msg.Topic._value_1}",
|
||||
f"{uid}_{value_1}",
|
||||
"Processor Usage",
|
||||
"sensor",
|
||||
None,
|
||||
|
@ -529,18 +529,16 @@ async def async_parse_processor_usage(uid: str, msg) -> Event | None:
|
|||
|
||||
|
||||
@PARSERS.register("tns1:Monitoring/OperatingTime/LastReboot")
|
||||
# pylint: disable=protected-access
|
||||
async def async_parse_last_reboot(uid: str, msg) -> Event | None:
|
||||
"""Handle parsing event message.
|
||||
|
||||
Topic: tns1:Monitoring/OperatingTime/LastReboot
|
||||
"""
|
||||
try:
|
||||
date_time = local_datetime_or_none(
|
||||
msg.Message._value_1.Data.SimpleItem[0].Value
|
||||
)
|
||||
value_1 = msg.Message._value_1 # pylint: disable=protected-access
|
||||
date_time = local_datetime_or_none(value_1.Data.SimpleItem[0].Value)
|
||||
return Event(
|
||||
f"{uid}_{msg.Topic._value_1}",
|
||||
f"{uid}_{value_1}",
|
||||
"Last Reboot",
|
||||
"sensor",
|
||||
"timestamp",
|
||||
|
@ -553,18 +551,16 @@ async def async_parse_last_reboot(uid: str, msg) -> Event | None:
|
|||
|
||||
|
||||
@PARSERS.register("tns1:Monitoring/OperatingTime/LastReset")
|
||||
# pylint: disable=protected-access
|
||||
async def async_parse_last_reset(uid: str, msg) -> Event | None:
|
||||
"""Handle parsing event message.
|
||||
|
||||
Topic: tns1:Monitoring/OperatingTime/LastReset
|
||||
"""
|
||||
try:
|
||||
date_time = local_datetime_or_none(
|
||||
msg.Message._value_1.Data.SimpleItem[0].Value
|
||||
)
|
||||
value_1 = msg.Message._value_1 # pylint: disable=protected-access
|
||||
date_time = local_datetime_or_none(value_1.Data.SimpleItem[0].Value)
|
||||
return Event(
|
||||
f"{uid}_{msg.Topic._value_1}",
|
||||
f"{uid}_{value_1}",
|
||||
"Last Reset",
|
||||
"sensor",
|
||||
"timestamp",
|
||||
|
@ -578,7 +574,6 @@ async def async_parse_last_reset(uid: str, msg) -> Event | None:
|
|||
|
||||
|
||||
@PARSERS.register("tns1:Monitoring/Backup/Last")
|
||||
# pylint: disable=protected-access
|
||||
async def async_parse_backup_last(uid: str, msg) -> Event | None:
|
||||
"""Handle parsing event message.
|
||||
|
||||
|
@ -586,11 +581,10 @@ async def async_parse_backup_last(uid: str, msg) -> Event | None:
|
|||
"""
|
||||
|
||||
try:
|
||||
date_time = local_datetime_or_none(
|
||||
msg.Message._value_1.Data.SimpleItem[0].Value
|
||||
)
|
||||
value_1 = msg.Message._value_1 # pylint: disable=protected-access
|
||||
date_time = local_datetime_or_none(value_1.Data.SimpleItem[0].Value)
|
||||
return Event(
|
||||
f"{uid}_{msg.Topic._value_1}",
|
||||
f"{uid}_{value_1}",
|
||||
"Last Backup",
|
||||
"sensor",
|
||||
"timestamp",
|
||||
|
@ -604,18 +598,16 @@ async def async_parse_backup_last(uid: str, msg) -> Event | None:
|
|||
|
||||
|
||||
@PARSERS.register("tns1:Monitoring/OperatingTime/LastClockSynchronization")
|
||||
# pylint: disable=protected-access
|
||||
async def async_parse_last_clock_sync(uid: str, msg) -> Event | None:
|
||||
"""Handle parsing event message.
|
||||
|
||||
Topic: tns1:Monitoring/OperatingTime/LastClockSynchronization
|
||||
"""
|
||||
try:
|
||||
date_time = local_datetime_or_none(
|
||||
msg.Message._value_1.Data.SimpleItem[0].Value
|
||||
)
|
||||
value_1 = msg.Message._value_1 # pylint: disable=protected-access
|
||||
date_time = local_datetime_or_none(value_1.Data.SimpleItem[0].Value)
|
||||
return Event(
|
||||
f"{uid}_{msg.Topic._value_1}",
|
||||
f"{uid}_{value_1}",
|
||||
"Last Clock Synchronization",
|
||||
"sensor",
|
||||
"timestamp",
|
||||
|
@ -629,7 +621,6 @@ async def async_parse_last_clock_sync(uid: str, msg) -> Event | None:
|
|||
|
||||
|
||||
@PARSERS.register("tns1:RecordingConfig/JobState")
|
||||
# pylint: disable=protected-access
|
||||
async def async_parse_jobstate(uid: str, msg) -> Event | None:
|
||||
"""Handle parsing event message.
|
||||
|
||||
|
@ -637,14 +628,15 @@ async def async_parse_jobstate(uid: str, msg) -> Event | None:
|
|||
"""
|
||||
|
||||
try:
|
||||
source = msg.Message._value_1.Source.SimpleItem[0].Value
|
||||
value_1 = msg.Message._value_1 # pylint: disable=protected-access
|
||||
source = value_1.Source.SimpleItem[0].Value
|
||||
return Event(
|
||||
f"{uid}_{msg.Topic._value_1}_{source}",
|
||||
f"{uid}_{value_1}_{source}",
|
||||
"Recording Job State",
|
||||
"binary_sensor",
|
||||
None,
|
||||
None,
|
||||
msg.Message._value_1.Data.SimpleItem[0].Value == "Active",
|
||||
value_1.Data.SimpleItem[0].Value == "Active",
|
||||
EntityCategory.DIAGNOSTIC,
|
||||
)
|
||||
except (AttributeError, KeyError):
|
||||
|
@ -652,7 +644,6 @@ async def async_parse_jobstate(uid: str, msg) -> Event | 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.
|
||||
|
||||
|
@ -662,7 +653,8 @@ async def async_parse_linedetector_crossed(uid: str, msg) -> Event | None:
|
|||
video_source = ""
|
||||
video_analytics = ""
|
||||
rule = ""
|
||||
for source in msg.Message._value_1.Source.SimpleItem:
|
||||
value_1 = msg.Message._value_1 # pylint: disable=protected-access
|
||||
for source in value_1.Source.SimpleItem:
|
||||
if source.Name == "VideoSourceConfigurationToken":
|
||||
video_source = source.Value
|
||||
if source.Name == "VideoAnalyticsConfigurationToken":
|
||||
|
@ -671,12 +663,12 @@ async def async_parse_linedetector_crossed(uid: str, msg) -> Event | None:
|
|||
rule = source.Value
|
||||
|
||||
return Event(
|
||||
f"{uid}_{msg.Topic._value_1}_{video_source}_{video_analytics}_{rule}",
|
||||
f"{uid}_{value_1}_{video_source}_{video_analytics}_{rule}",
|
||||
"Line Detector Crossed",
|
||||
"sensor",
|
||||
None,
|
||||
None,
|
||||
msg.Message._value_1.Data.SimpleItem[0].Value,
|
||||
value_1.Data.SimpleItem[0].Value,
|
||||
EntityCategory.DIAGNOSTIC,
|
||||
)
|
||||
except (AttributeError, KeyError):
|
||||
|
@ -684,7 +676,6 @@ async def async_parse_linedetector_crossed(uid: str, msg) -> Event | 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.
|
||||
|
||||
|
@ -694,7 +685,8 @@ async def async_parse_count_aggregation_counter(uid: str, msg) -> Event | None:
|
|||
video_source = ""
|
||||
video_analytics = ""
|
||||
rule = ""
|
||||
for source in msg.Message._value_1.Source.SimpleItem:
|
||||
value_1 = msg.Message._value_1 # pylint: disable=protected-access
|
||||
for source in value_1.Source.SimpleItem:
|
||||
if source.Name == "VideoSourceConfigurationToken":
|
||||
video_source = _normalize_video_source(source.Value)
|
||||
if source.Name == "VideoAnalyticsConfigurationToken":
|
||||
|
@ -703,12 +695,12 @@ async def async_parse_count_aggregation_counter(uid: str, msg) -> Event | None:
|
|||
rule = source.Value
|
||||
|
||||
return Event(
|
||||
f"{uid}_{msg.Topic._value_1}_{video_source}_{video_analytics}_{rule}",
|
||||
f"{uid}_{value_1}_{video_source}_{video_analytics}_{rule}",
|
||||
"Count Aggregation Counter",
|
||||
"sensor",
|
||||
None,
|
||||
None,
|
||||
msg.Message._value_1.Data.SimpleItem[0].Value,
|
||||
value_1.Data.SimpleItem[0].Value,
|
||||
EntityCategory.DIAGNOSTIC,
|
||||
)
|
||||
except (AttributeError, KeyError):
|
||||
|
|
Loading…
Reference in New Issue