I'm not sure that the fsm library used makes this easy as it collapses the notion of event and transition as the transition function for an event XXXX is onXXXX().

This implies to handle the different cases in the onXXXX() based on the from/to state while it should have been done declaratively in the events table of the fsm by explicitly associating different transition functions for the same event in the different states.