From 53a9c117ee3d622ba9d75626381b088514cc813c Mon Sep 17 00:00:00 2001 From: MatsNl <37705266+MatsNl@users.noreply.github.com> Date: Mon, 22 Mar 2021 14:43:46 +0100 Subject: [PATCH] Add jobstate parser to Onvif integration (#46589) --- homeassistant/components/onvif/parsers.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/homeassistant/components/onvif/parsers.py b/homeassistant/components/onvif/parsers.py index cad2b3c8cab..9574d44edea 100644 --- a/homeassistant/components/onvif/parsers.py +++ b/homeassistant/components/onvif/parsers.py @@ -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