Want on/off switch instead of toggle switch on lovelace entitycard

Is this possible? Sometimes I want to turn of the last three lamps in the livingroom by turning on the cardswitch on the lovelace card. The toggle button turns to on if at least one entity in the card is on. In that case I have to first turn off the toggle switch and then on again. Im guessing there is a oneliner in the lovelace editor that I can add to mage the togglebutton an on/off switch instead?

Or do I have to go the distance with this task and start creating entitygroups first?

No there is no setting to make the header toggle work that way.

You could add two buttons to the card. One that turns the group of lights on and one that turns them off.

The only other thing I can think of is using a tap_action and a hold_action.
Tab is on, hold is off or the other way around.

Or…, you could do some templating in a condition. If the lights are in a group, you can count the number of lights on. If that’s less than the group size, you turn all lights on, if all are on, you turn the lights off.

Bulbs in group: {{ expand('group.<name>') | map(attribute='entity_id') | list | count }}
Bulbs on in group: {{ expand('group.<name>')|list|selectattr('state','eq','on')|list|count }}

Condition: {{ expand('group.<name>') | map(attribute='entity_id') | list | count == expand('group.<name>')|list|selectattr('state','eq','on')|list|count }}

Edit: Put the template condition in.

If they are in a group, why not treat them as a group and turn them all on our or all off ?

Just to clarify, this is for a button, not for the entities card header toggle.

Check, then I think he could give the template condition a try.
You could use it in a CHOOSE action.

You could also try to toggle the group like @mutt suggests. The downside is that when one bulb is on, the group is on and thereby will probably go off where you want it to go on.

Yeah but that’s easily fixed with one tiny automation : -

  - alias: au_three_as_one
    trigger:
      - platform: state
        entity_id: light.light1, light.light2, light.light3
    action:
      - service_template: home_assistant.turn_{{trigger.to_state.state}}
        entity_id: group.light_group_in_question

Away From a workstation so unsure about the “entity_id: light.light1, light.light2, light.light3” syntax.

Edit: Actually given this, dispense with the group

  - alias: au_three_as_one
    trigger:
      - platform: state
        entity_id: light.light1, light.light2, light.light3
    action:
      - service_template: light.turn_{{trigger.to_state.state}}
        entity_id: light.light1, light.light2, light.light3

This will just follow whatever was last switched

I like your automation and will bookmark it myself. Looking at the request of @Mattie. I don’t exactly know what the reason is that not all lights are “always” on, but apparently it is a scenario.

So I assume that @Mattie doesn’t want to have all lights on at the same time. Perhaps an automation puts part of the lights on when not home and all when at home.

That’s the reason I suggested the template condition combined with a CHOOSE statement.

Anyway, I think @Mattie has multiple solutions to choose from right now :+1:

Thats exactly the reason, automations and specific scenarios and sometimes I just want to lighten up the room with the rest of the lamps without needing to switch everyone on. Thanks for all the tips, I got more than I could wish for :slight_smile: Really nice with this helpful community I really have to give you all some credit! And this is not the first time I’m asking for help.

The on/off-switch in a lovelace-entity-card could be very handy though, it would also avoid too much templating/automations. I like to keep my installation as clean as I can with a bit more basic or lets say impactful automations and templates, I don’t want to do an automation for every tiny thing I come up with, instead I think that those scenarios call for a feature request. But that’s just me as a person, the installation surely would be much “smarter” with all those small automations but I guess also pretty fragile.

Anyway, thanks again, I think I know what to do now!

You probably already know, that you can only mark one post as your solution, just checking that you didn’t try to select two or three as only the last one sticks