I wanted to add an automation rule where if the front door was opened (contact sensor in place) that it would turn on hallway lights for 5 minutes only IF the lights were initially off AND at a certain time of day. However if they were already on, it would just stay on (nothing happens).
Rule Machine can do this. You'll want something like the following:
Required Expression: Time of Day
Trigger: Contact Sensor open
Actions: If light is off, turn on light
Wait for Event: Elapsed Time 5 minutes
Turn off light (assuming this is what you want to happen after 5 minutes)
End-If
Basically, this rule will only run during the time period. From there, when the contact sensor opens, it will check if the light is off. If it is on, it will do nothing. If it is off, then it will turn on the light, wait for 5 minutes, then turn off the light.
I would allow the rule to reset the five minute timer if the front door is reopened. Here's an option for RM
Required Expression
Time between Sunset and Sunrise AND
Light is off
Trigger Events
Front Door contact open
Actions to Run
On: Light
Wait for event: Front Door contact closed and stays that way for: 0:05:00
Off: Light