Add jobstate parser to Onvif integration (#46589)

This commit is contained in:
MatsNl
2021-03-22 14:43:46 +01:00
committed by GitHub
parent a583f56bd8
commit 53a9c117ee

View File

@@ -387,3 +387,25 @@ async def async_parse_last_clock_sync(uid: str, msg) -> Event:
)
except (AttributeError, KeyError, ValueError):
return None
@PARSERS.register("tns1:RecordingConfig/JobState")
# pylint: disable=protected-access
async def async_parse_jobstate(uid: str, msg) -> Event:
"""Handle parsing event message.
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",
"binary_sensor",
None,
None,
msg.Message._value_1.Data.SimpleItem[0].Value == "Active",
)
except (AttributeError, KeyError):
return None