Simple: How to turn off Switch only (not toggle) on button

This is probably stupidly simple but I’ve been bashing my head against a wall for ages.

Simply put, I want the HOLD action on a button to turn off all lights. I don’t want to toggle all lights on as there is never a use case for that.

Is there a simple way to do this? This does not seem to work in the Button Lovelace:

hold_action:
  action: call-service
  service: switch.turn_off
  entity_id: switch.all_lights

In my HA Config, I added the following to group my lights, however I don’t want the “turn on” service to work, so left it blank. The issue is when I set the button to just “toggle”, the screen flashes black for some reason when I turn off all the lights???

HA Config:

switch:
  - platform: template
    switches:
      all_lights:
        value_template: >-
          {{ is_state('light.1', 'on')
             or is_state('light.2', 'on')
             or is_state('light.3', 'on') }}
        turn_on:
#          service: "commented out line"
        turn_off:
          service: light.turn_off
          data:
            entity_id: all

Any help to go about this better? Don’t really want the screen to flash black everytime I turn off the lights…

Why are you using the toggle service if you only wan the light to turn off?

Toggle changes from off to on or on to off.

Try this:

Put the turn_on action back in your switch config.

Set the hold action of your button to switch.turn_off.

Set the tap action of your button to none.

Question: how are you going to turn your lights on?

I’ll keep this simple and make a new card for testing purposes, I find that the action: switch.turn_off does not work…:

type: button
tap_action:
  action: switch.turn_off
entity: switch.all_lights

*Nothing happens on button tap.

Answer: The button hold to turn off all will create a pop up on single tap, which has all lights listed to turn on individually. I have 0 use cases to turn on all lights, as they are all in different rooms. But would like a simple way to turn them all off.

type: button
tap_action:
  action: call-service
  service: switch.turn_off
  service_data:
    entity: switch.all_lights

I’ve tried that before, get the HA failed service popup (copied exactly what you have too):

Failed to call service switch/turn_off. extra keys not allowed @ data[‘entity’]

Trying every method I can.

Grouping lights won’t work.

Config:

light:
  - platform: group
    name: All Lights2
    entities:
      - light.1
      - light.2
      - light.3

Lovelace:

type: button
tap_action:
  action: call-service
  service: light.turn_off
  service_data:
    entity: light.all_lights2
entity: light.all_lights2

Returns:

Failed to call service light/turn_off. extra keys not allowed @ data[‘entity’]

Ah, that’s because it is supposed to be entity_id.

type: button
tap_action:
  action: call-service
  service: switch.turn_off
  service_data:
    entity_id: switch.all_lights

Confirmed this works, however my whole screen flashes black as mentioned in the original post, whereas this does not happen with “toggle”… WHYYYYyyyy sigh

EDIT: Doesn’t happen when I use the LIGHT group. Might be because of the code in the template I used for the Switch…

Thanks for the help!

You need to add this back, even if you are not using it:

        turn_on:
#          service: "commented out line"

Fun fact, even after adding the line in as suggested:

        turn_on:
          service: light.turn_on
          data:
            entity_id: all
        turn_off:
          service: light.turn_off
          data:
            entity_id: all

However, it still flashes black when I press the button. This blank screen can last up to 1-4 seconds, so I will obviously not use the switch method but stick to the “light: group” method (which does not flash my screen black).

Could be that I’m running it on a VM? Who knows?

Thanks for the help regardless!