Automation for all lights group helper + automation for remote switch

Hello All,

I’m new in HASS, and any help is welcome.

I am trying to make an lights automation, but hitting a loop.

I have a light group helper for all home lights and need to pair it with an remote blank swich (only powered and not connected to light) at the entrance.

The idea is:

  1. when a light group is on, to turn on remote blank swich on and not triger further action of the switch state on.
  2. when light group is off, to turn of remote blank swich off and not triger further action of the switch state off.

and opsite
3. when remote switch is on from the switch to power on all lights
4. when remote switch is off from the switch to power off all lights

So the hard part is that helper is on even with single light is on and all lights become on or in loop

Can i have all this in one automation or somehow split it to work properly.

Thank you in advance.

Original Response

You don’t actually need the group to control all light entities, there is a keyword all that will act on all of them…

action: light.turn_on
target:
  entity_id: all

It works for the light.turn_off action as well.

If, however, your group doesn’t actually contain all of your lights, you can use a template to retrieve all of the entities that belong to the group:

action: light.turn_on
target:
  entity_id: "{{ state_attr('light.YOUR_LIGHT_GROUP', 'entity_id') }}"

EDIT: After re-reading the OP, I think I missed the point in my original response…


If the state of the switch isn’t directly linked to the lights’ states, why force it? There’s no need to use it in the Dashboard since you can just use the light group…

So, just set up an automation that triggers on the state change of the switch to have it effect the light group in the desired way.

trigger:
  - platform: state
    entity_id: switch.YOUR_REMOTE_SWITCH
    to:
      - 'on'
      - 'off'
    from:
      - 'on'
      - 'off'
condition: []
action:
  - service: light.turn_{{ 'on' if is_state('light.YOUR_LIGHT_GROUP', 'off') else 'off' ) }}
    data: []
    target:
      entity_id: light.YOUR_LIGHT_GROUP
1 Like