Return input select to previous state

In my automation i switch the input select to the “Kid’s radio”. What i what to do - after some time passes return the input select to the state which was before the “Kid’s radio”
One way i can see is make some intermediate sensor and set it to state of the radio name before kids and then read from template. But there dfinetly must be a way to do it easier way

With normal automations you will need to make a sensor that has the last selected input. Thats the only way to store a value. Otherwise you can use appdaemon and solve this pretty easily.