Automation of Camera power

I have a camera plugged into an insteon plug in module and having an issue thinking straight on how to accomplish the automations I need and was wondering if someone could give me a shove in the right logical direction. Here is what I need:

  1. Camera OFF if Any Light is on and someone is home (we’re up and around the house)
  2. Camera ON if All Lights are off and someone is home (We’re sleeping)
  3. Camera ON if Light(s) are one but everyone is gone (Worker in house alone, nanny)
  4. Camera ON if All Lights are off and everyone is gone (No one in the house)

I have something, but it’s not a 100% and I’m also not sure how to tell if ANY one of the lights turn on without checking each light (very tedious).

Any help would be greatly appreciated.

This template can be used to determine if any light (i.e., in the light domain) is on:

{{ states.light|selectattr('state','eq','on')|list|count > 0 }}

If you have lights that show up as switch entities, that can also be added but may depend on what all the switch entities are (i.e., do they just control lights???)

To determine if anyone is home depends on how you detect that. Assuming you are using device_trackers, then you can just use the state of group.all_devices. It will be ‘home’ if anyone is home, and will be ‘not_home’ if everyone is gone.

Thanks for the input, now to go figure out templates. Tried in the past (spent 10 mins) and failed, but this time I’ll actually spend the time to actually try to make it work.

I’m using the not_home already for when people leave, but didn’t realize home would work for the group as well, so I can reduce my individual devices now and only have the one, great as it’s less maintenance, and eventually we’ll be adding more devices.