I have a autistic son who tends to sleep walk. I have found him a few times sound asleep in the bathtub with the shower running. I'm looking for some type of timer that limits the hours a shower can be used, like say between midnight and 5:30am.
You could plumb a 12 volt DC electric solenoid water valve on the hot and another one on the cold water line to the shower. Take a 120 volt AC to 12 volt DC transformer and wire it to them. Then put the 12 volt transformer on a 120 volt timer and have it power the solenoids when he is allowed to use it.
It's doable but it would likely be a pretty big job. If you fit the hot and cold supply lines with electric actuators - devices that open and shut valves -
and control those actuators with a timer
you could turn the water on and off on a schedule set on the timer.
This is simple enough but not easy, and there are a number of caveats that come to mind.
The devices involved are not small, certainly not stuff you can stuff inside the wall - depending how your plumbing runs, you may have to do extensive work to reroute the supply for the shower through a location where you can install these devices.
You'd need robust actuators - you'd have to use something with a duty cycle that will tolerate daily use, not something designed for occasional use or shutoff when a leak is detected.
You would want to make sure your water heater's temperature is set low enough that there is no chance of scalding with the hot water all the way on, and no cold water. (This is a good idea even independent of this project.) It's possible that the system could malfunction and leave the hot supply open and the cold supply shut, and someone gets full blast hot water in the shower. You could make the system more reliable with redundant actuators on the hot supply, etc., but you can never make anything 100% reliable.
If you are just trying to schedule when the water will run, go to an irrigation supply store, and get a simple 1 zone water valve kit. (You can also do this from Home Depot stuff. You need a valve, and a 1 station timer, and the handfull of adapters to go from (usually) 3/4" female ports on the valve to your household water system.
Done this way, it would only shut off one line. You may want to use a valve on both the hot water and cold water lines to the shower. Check with the specs on the zone controller as to whether it can control more than one valve on a single zone output. Usually not a problem.
Edit: Any system that can leave the hot water running, but not the cold is dangerous. Valves can fail: stuck on or stuck off. Interrupt the hot water only. full cold water is unlikely to be harmful.
Valves run 15-30 bucks each. a 1 station controller is between 50 and 100. Since you don't need rain sensors, remote programming, etc, a cheaper controller should work.
Do this in a way that it is easier to undo it. The next house owner probably won't need this feature.
You might want to consider some form of child safety lock instead; either on the bathroom door, or on the shower if it has a door as opposed to a curtain. (Obviously more difficult if your kid needs to use the bathroom in the middle of the night, and you don't want him to wake you.) I don't know your exact circumstances, but in general securing access to the room might be easier than securing access to water. For example, the answers to Where can I find a Time Restricted Keypad Lock? may prove useful.
You can use solenoid valves. They are a much less expensive option then a valve actuator. Valve actuators are a good option but a little bit more expensive and potentially more complicated to install. Solenoid valves are available in many different voltages, sizes, flow rates and suitable for many different applications.