Fix incorrectly setting can_cancel on scripts

This commit is contained in:
Paulus Schoutsen 2016-02-27 22:30:24 -08:00
parent f5dd41e019
commit f623a332cf
2 changed files with 8 additions and 11 deletions

View file

@ -131,8 +131,8 @@ class Script(ToggleEntity):
self._cur = -1
self._last_action = None
self._listener = None
self._can_cancel = not any(CONF_DELAY in action for action
in self.sequence)
self._can_cancel = any(CONF_DELAY in action for action
in self.sequence)
@property
def should_poll(self):
@ -146,13 +146,11 @@ class Script(ToggleEntity):
@property
def state_attributes(self):
""" Returns the state attributes. """
attrs = {
ATTR_CAN_CANCEL: self._can_cancel
}
attrs = {}
if self._can_cancel:
attrs[ATTR_CAN_CANCEL] = self._can_cancel
if self._last_action:
attrs[ATTR_LAST_ACTION] = self._last_action
return attrs
@property