From f3838dde3a6a582eb0d39372494d49442c74267a Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sun, 23 Apr 2023 22:02:08 -0500 Subject: [PATCH] Cleanup onvif topic before lookup (#91914) * Cleanup onvif topic before lookup Some devices will append . and / to the path. We need to strip it off to find the correct matcher fixes #51870 * Update homeassistant/components/onvif/event.py * Update homeassistant/components/onvif/event.py Co-authored-by: Paulus Schoutsen --------- Co-authored-by: Paulus Schoutsen --- homeassistant/components/onvif/event.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/onvif/event.py b/homeassistant/components/onvif/event.py index 57961548917..4abb7288052 100644 --- a/homeassistant/components/onvif/event.py +++ b/homeassistant/components/onvif/event.py @@ -158,7 +158,16 @@ class EventManager: if not msg.Topic: continue - topic = msg.Topic._value_1 + # Topic may look like the following + # + # tns1:RuleEngine/CellMotionDetector/Motion//. + # tns1:RuleEngine/CellMotionDetector/Motion + # tns1:RuleEngine/CellMotionDetector/Motion/ + # + # Our parser expects the topic to be + # tns1:RuleEngine/CellMotionDetector/Motion + topic = msg.Topic._value_1.rstrip("/.") + if not (parser := PARSERS.get(topic)): if topic not in UNHANDLED_TOPICS: LOGGER.info(