not hard to do…
I think you intended to say you know how to do the first part. could you post the automation that you did for the first part? it will be easiest for you if we edit that to achieve the second part.
take a look at the link @Stiltjack posted. that has the core info you need. but if you still need help, post the automation you have. it will be easiest to modify it. yes, i understand you wrote the turn on part. we’ll use that to do the second part too.