restore_state: do not crash if domain not defined (#6714)

This commit is contained in:
Paulus Schoutsen 2017-03-20 08:54:51 -07:00 committed by GitHub
parent 8325f9db8a
commit de231cf9ab

View File

@ -142,7 +142,12 @@ def async_reproduce_state(hass, states, blocking=False):
else: else:
service_domain = state.domain 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 service = None
for _service in domain_services.keys(): for _service in domain_services.keys():
@ -157,8 +162,8 @@ def async_reproduce_state(hass, states, blocking=False):
break break
if not service: if not service:
_LOGGER.warning("reproduce_state: Unable to reproduce state %s", _LOGGER.warning(
state) "reproduce_state: Unable to reproduce state %s (2)", state)
continue continue
# We group service calls for entities by service call # We group service calls for entities by service call