Please formatted your code blocks properly as outlined in Questions Guideline #11
You have a couple options…
Option 1: Modify the current automations to include time conditions and triggers.
Option 2: Combine your sensor and switch using the Generic hygrostat integration. Then your automation just needs to turn it on/off at the desired times.