Change state of member of group some time after it changed state

Maybe the title is not the best, but let me explain what I’m trying to achieve.

Let’s say I have a group with several devices on it, all of the same category, let’s say “lights”.

I want to create an automation that will turn off any light belonging to that group 1 hour after it has been turned on.

Another example: each time an Air Conditioner changes from Off to anything else (Heat, Cool, Dry, …) change it back to Off after 1 hour.

Is it possible to create an automation based on the device belonging to that group instead of having to create an automation for each device? This would helpful in the case I just want to add/remove devices from the group and have that automation apply (or not) to them.

You can make groups and define the group to be on when any lights is on.
Then it is just making an automation to turn the group off after one hour .