From 4da4975646341a213636974b7545cc3c0a94b1a5 Mon Sep 17 00:00:00 2001 From: cdce8p <30130371+cdce8p@users.noreply.github.com> Date: Mon, 9 Apr 2018 16:22:07 +0200 Subject: [PATCH] Improved upgradeability --- .../homekit/type_security_systems.py | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/homeassistant/components/homekit/type_security_systems.py b/homeassistant/components/homekit/type_security_systems.py index 235a8b22e7c3bb..0c3c3e42d4b94b 100644 --- a/homeassistant/components/homekit/type_security_systems.py +++ b/homeassistant/components/homekit/type_security_systems.py @@ -67,15 +67,13 @@ def update_state(self, entity_id=None, old_state=None, new_state=None): return hass_state = new_state.state - if hass_state not in HASS_TO_HOMEKIT: - return - - current_security_state = HASS_TO_HOMEKIT[hass_state] - self.char_current_state.set_value(current_security_state) - _LOGGER.debug('%s: Updated current state to %s (%d)', - self.entity_id, hass_state, current_security_state) - - if not self.flag_target_state: - self.char_target_state.set_value(current_security_state) - if self.char_target_state.value == self.char_current_state.value: - self.flag_target_state = False + if hass_state in HASS_TO_HOMEKIT: + current_security_state = HASS_TO_HOMEKIT[hass_state] + self.char_current_state.set_value(current_security_state) + _LOGGER.debug('%s: Updated current state to %s (%d)', + self.entity_id, hass_state, current_security_state) + + if not self.flag_target_state: + self.char_target_state.set_value(current_security_state) + if self.char_target_state.value == self.char_current_state.value: + self.flag_target_state = False