Automation based on Group state

I have created a group to combine two PIRs I have at the top and bottom of my stairs :-

group:
  stairs:
    name: Stairs
    entities:
      - binary_sensor.pir_hall_downstairs
      - binary_sensor.presence_11

I then created an automation to turn on some LEDs when the state of this group changes to On :-

- id: '1616783822043'
  alias: 'PIR : Stairs On'
  description: ''
  trigger:
  - platform: state
    entity_id: group.stairs
    to: 'On'
  condition: []
  action:
  - service: light.turn_on
    data:
      effect: Colortwinkles
    target:
      entity_id: light.wled_stairs
  mode: single

I have added all 3 entities (2 x PIR sensors and 1 x group) to a dashboard, and I can confirm that when either of the PIRs go to Detected, the group changes to On.

However, the automation is not running, even though it turns the lights on fine if I click ‘Run Actions’ whilst editing the automation, which seems to suggest an issue with the Trigger.

I’ve tried putting ’ From : Off ’ and ’ To: On ', or just ’ To : On ’ but neither works.

What am I missing?

Hi,

Reading the documentation Group - Home Assistant

By default when any member of a group is on then the group will also be on

I’m also thinking about whether your trigger is right ?

I would probably add a condition like this

trigger:
  - platform: state
    entity_id: group.stairs
condition:
  - condition: state
    entity_id: group.stairs
    state: 'on'

Or it could be as simple as a case sensitive state ie ‘on’ instead of ‘On’ :blush:

1 Like

Do not capitalise the state on.

It was indeed because I was specifying On instead of on - all working now, so thanks :slight_smile: