Capture state of binary sensor into new sensor

There’s a nice solution to catch the history of state changes: