The new Target ability of automations looks very promising. Currently I have my motion sensors in each area tied to a group, which is in turn tied to a template binary sensor (template below) to control lighting.
The update today released new functionality to target areas. With it, I can now target "Occupancy is detected in Basement". I'm thinking of migrating my current setup to the new paradigm so that I can get rid of a cascade of groups and helpers, but am curious if I am missing something and keeping groups around is a better solution than targets.
Current Template:
- name: "Basement Occupancy Sensor"
device_class: occupancy
# uniuqe_id allows editing from the UI
unique_id: "basement_occupancy_template_sensor"
state: "{{ is_state('binary_sensor.basement_motion_sensor_group', 'on') }}"
delay_off: >
{% set minutes = states('input_number.motion_sensor_timeout') | int %}
00:{{minutes}}:00
Potential replacement:
alias: Basement Motion Detection Automation
description: ""
triggers:
- trigger: binary_sensor.occupancy_detected
target:
floor_id: basement
options:
behavior: any
conditions: []
actions:
- if:
- condition: light.is_off
target:
device_id: f6ec471de8427d1c55ad4b3586141846
options:
behavior: any
then:
- action: light.turn_on
metadata: {}
target:
device_id: f6ec471de8427d1c55ad4b3586141846
data: {}
- delay:
hours: 0
minutes: 15
seconds: 0
milliseconds: 0
- action: light.turn_off
metadata: {}
target:
device_id: f6ec471de8427d1c55ad4b3586141846
data: {}
mode: restart