From de231cf9ab96344131ca3a4379b9b312707717d9 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Mon, 20 Mar 2017 08:54:51 -0700 Subject: [PATCH] restore_state: do not crash if domain not defined (#6714) --- homeassistant/helpers/state.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/homeassistant/helpers/state.py b/homeassistant/helpers/state.py index ea33d27a814..dbc32d1c37e 100644 --- a/homeassistant/helpers/state.py +++ b/homeassistant/helpers/state.py @@ -142,7 +142,12 @@ def async_reproduce_state(hass, states, blocking=False): else: service_domain = state.domain - domain_services = hass.services.async_services()[service_domain] + domain_services = hass.services.async_services().get(service_domain) + + if not domain_services: + _LOGGER.warning( + "reproduce_state: Unable to reproduce state %s (1)", state) + continue service = None for _service in domain_services.keys(): @@ -157,8 +162,8 @@ def async_reproduce_state(hass, states, blocking=False): break if not service: - _LOGGER.warning("reproduce_state: Unable to reproduce state %s", - state) + _LOGGER.warning( + "reproduce_state: Unable to reproduce state %s (2)", state) continue # We group service calls for entities by service call