Add last triggered to script (#5261)

* Add last triggered to script

* Add tests for script last_triggered
This commit is contained in:
Daniel Høyer Iversen 2017-01-11 16:23:05 +01:00 committed by Paulus Schoutsen
parent 82d037a828
commit 467cb18625
3 changed files with 23 additions and 0 deletions

View file

@ -31,6 +31,7 @@ CONF_SEQUENCE = "sequence"
ATTR_VARIABLES = 'variables'
ATTR_LAST_ACTION = 'last_action'
ATTR_LAST_TRIGGERED = 'last_triggered'
ATTR_CAN_CANCEL = 'can_cancel'
_LOGGER = logging.getLogger(__name__)
@ -155,6 +156,7 @@ class ScriptEntity(ToggleEntity):
def state_attributes(self):
"""Return the state attributes."""
attrs = {}
attrs[ATTR_LAST_TRIGGERED] = self.script.last_triggered
if self.script.can_cancel:
attrs[ATTR_CAN_CANCEL] = self.script.can_cancel
if self.script.last_action: