Check the history of your entity. If it’s going unavailable when your automation fires, then the action will fail.
There are two other issues I can see with your automation:
First one is an inconsistency - you’re using toggle to switch on, but turn_off to switch off. Try using toggle for both (and have a condition to check the state), or else use turn_on for your first automation.
Second issue is your trigger in the second automation - you’re using a time_pattern trigger, but what you really want is a time trigger. Learn the difference between the two or it might cause you issues down the line.
Finally, if you’re just starting out, I suggest you read this Why and how to avoid device_ids in automations and scripts. Again, learning this at this stage while you’re just starting out will help you avoid issues down the line.