From d6ad85bba7762b8d7bee96ecbcfa6c37d3ce0c94 Mon Sep 17 00:00:00 2001 From: Charles Garwood Date: Tue, 6 Oct 2020 09:54:46 -0400 Subject: [PATCH] Protect add/remove node services from invalid instance ID (#41334) --- homeassistant/components/ozw/services.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/homeassistant/components/ozw/services.py b/homeassistant/components/ozw/services.py index 9f66c3c33fd..e1f71e636b3 100644 --- a/homeassistant/components/ozw/services.py +++ b/homeassistant/components/ozw/services.py @@ -111,6 +111,8 @@ class ZWaveServices: instance_id = service.data[const.ATTR_INSTANCE_ID] secure = service.data[const.ATTR_SECURE] instance = self._manager.get_instance(instance_id) + if instance is None: + raise ValueError(f"No OpenZWave Instance with ID {instance_id}") instance.add_node(secure) @callback @@ -118,6 +120,8 @@ class ZWaveServices: """Enter exclusion mode on the controller.""" instance_id = service.data[const.ATTR_INSTANCE_ID] instance = self._manager.get_instance(instance_id) + if instance is None: + raise ValueError(f"No OpenZWave Instance with ID {instance_id}") instance.remove_node() @callback