#Automation targets vs old group advice for sensors

1 messages · Page 1 of 1 (latest)

keen girder
#

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
half bay
#

I do not like to use the long delays in the automation, but at the same time I am not sure if new triggers support for option. I don't think so, or maybe it is only not exposed in the UI.

Second point, use of device_id should be discouranged as you have no portability if device fails.

I also don't understand the reason for your if statement. You can always turn on the light (if that's what you prefer) and done.

keen girder
#

The if statement minimizes network traffic if the lights are already on, but still allows the timer to reset.

I’m not sure if this really answers my question of “does the new functionality intend to supersede prior best practices where groups were standard”.

Group vs room triggers. The template sensor functionality is nice but hidden away in config files which isn’t nice.

half bay
#

For your current use case, a group might be better than template sensor. And then you do the group type when at least one is on, group is on, and then in the automation you can sue the for to say "when group is off for X amount of time"

keen girder
half bay
#

yes correct, the current target does not support delayed response yet.

keen girder