Is Home Occupied Script Help

I have my ecobee sensors around the house that detect occupancy, I want to create a script that looks at all of them to determine if the house is occupied. How do I pull device_class: occupancy from all of the binary sensors, then cycle through them to determine if any are on? Then set a state for a new binary_sensor.home_occupancy to On or Off?

binary_sensor.kitchen_occupancy off
friendly_name: Kitchen Occupancy
device_class: occupancy

binary_sensor.master_bedroom_occupancy off
friendly_name: Master Bedroom Occupancy
device_class: occupancy

binary_sensor.office_occupancy off
friendly_name: Office Occupancy
device_class: occupancy

Your easiest option is to put them all in a single group, then the group will be on if any of the occupancy sensors detect occupancy and off if all sensors are unoccupied.

1 Like