Need a circuit to detect if something has gone from off-on or on-off
Prelim schematic.  U1A is an inverting buffer to isolate the circuit from whatever is driving it.  It drives the R1-C1 network that creates a pulse out of the trailing (downward)  edge of the input waveform.  It also drives an inverter, so the R2-C2 network creates a pulse out of the upward (leading) edge.  The two pulses are wire-OR'ed into R4 through D1 and D2.
Either pulse triggers a monostable, U1C and U1D.  This makes a 5 second output pulse that drives Q1 and the motor.  Note that this is a true monostable. Once triggered, it makes its full pulse width no matter how short or long the triggering (input) pulse is.