Include last trigger in fsm_update messages

This commit is contained in:
Kristóf Tóth 2018-07-14 20:45:26 +02:00
parent 77f14df17b
commit 4236a17b69

View File

@ -28,7 +28,8 @@ class FSMManagingEventHandler(EventHandlerBase):
LOG.error('IGNORING MESSAGE: Invalid message received: %s', message) LOG.error('IGNORING MESSAGE: Invalid message received: %s', message)
def handle_trigger(self, data): def handle_trigger(self, data):
self.fsm.step(data['value']) trigger = data['value']
self.fsm.step(trigger)
return data return data
def handle_update(self, data): def handle_update(self, data):
@ -51,7 +52,9 @@ class FSMUpdater:
{'trigger': trigger} {'trigger': trigger}
for trigger in self.fsm.get_triggers(self.fsm.state) for trigger in self.fsm.get_triggers(self.fsm.state)
] ]
last_trigger = self.fsm.trigger_history[-1] if self.fsm.trigger_history else None
return { return {
'current_state': state, 'current_state': state,
'valid_transitions': valid_transitions 'valid_transitions': valid_transitions,
'last_trigger': last_trigger
} }