Is it possible to reverse the logic of the switch of a group of lights?

I have a set of lights grouped together. This grouping generates a switch for the group which is:

  • off when all the lights are off
  • on when any of the lights is on

Is it possible to reverse this logic so that the group switch is

  • off when any the lights is off
  • on when all the lights are on

The problem I want to solve (or at least change) is that I have a RF433 button which will toggle the state of that group switch. I would like to put a preference on “switch all the lights on, even when some are already on” rather than the default “switch off the lights off if any of them is on”.

Right now I have a workaround in AppDaemon where I keep the state of the button and manage the lights one by one (all of them change their state together, but they are called one by one and not though their group switch). reversing the logic of the switch would simplify that setup.

you could easily create a template switch doing what you want? Template Switch - Home Assistant

or are you talking about a sensor? Seems that s what you are describing and would make it even simpler :wink:

Thank you. That was indeed the solution.

Would you know how to combine several types of services (I was lucky to just have lights, so all went into
service: switch.turn_on and service: switch.turn_off but I do not know how to handle, say, two lights and one radio (they have their own service)

of course that is possible, nothing simpler :wink:

what do you have now, and what do you want to add?

If you want (might be best) you can add all services in a script, 1 for on, 1 for Off. and call the scripts in the template switch.

Only thing you have to think about is what template you use or the state of the template switch.

have a look at a few scripts and get the idea:

scene_home_theater:
  alias: Call Home theater scene
  sequence:
#    - service: scene.turn_on
#      entity_id: scene.home_theater_off
    - service: switch.turn_off
      entity_id:
        - switch.auditorium_motion_sensor_switch
        - switch.dining_table_motion_sensor_switch
#    - condition: template
#      value_template: >
#        {{ is_state('binary_sensor.home_theater_lux_input', 'on')}}
#    - service: scene.turn_on
#      entity_id: scene.home_theater_on
    - service: script.turn_on
      entity_id: script.lighting_home_theater

lighting_home_theater:
  alias: Lighting Hometheater
  sequence:
    - service: input_select.select_option
      data:
        entity_id: input_select.activity_lighting
        option: Home theater
    - service: scene.turn_on
      entity_id: scene.home_theater_off
    - condition: template
      value_template: >
        {{ is_state('binary_sensor.home_theater_lux_input', 'on')}}
    - service: scene.turn_on
      entity_id: scene.home_theater_on

you can call any service in a script, just check the dev-service page and see what you have available in your setup

2 Likes

Thanks - I did not know that one could chain the service/entity_id under sequence.