Template Switch don´t turn ON entity

When I turn ON this switch from the UI it perform the action of the script of ON, but the switch don´t toggle ON and if I want to turn off I need to dcuble click the button fast to turn off before the entity turn off it self.

switch:
  - platform: template
    switches:
      generalcuartoluis:
        friendly_name: "C11"
        value_template: "{{ is_state('switch.generalcuartoluis', 'on') }}"
        icon_template: mdi:lightbulb
        turn_on:
          service: script.ongeneralcuartoluis
        turn_off:
          service: script.offgeneralcuartoluis

Someone know how fix it?

It behaves that way because the value_template is self-referential and that’s invalid. It should report the state of whatever device your script is controlling.

If my script is controlling 4-5 hue lights, I have to put like this?

cc1 is the name of the light

value_template: "{{ is_state('light.cc1', 'on') }}"

Have you considered using a Light Group?

Or, better yet, create a Hue group.

1 Like

Yes but I use the configuration UI in the script for the lights to select the light temperature and brigtness

A Light Group lets you control the brightness, color, color temperature, etc of all lights within the group (and so does a Hue group).

Ohh nice, thanks! I would try, I already have rooms in the hue app, but in hassio I only see the scene of the rooms in the developer tools page, do you know how can I use the rooms of the hue app in hassio?

That’s true, a Hue group will automatically appear in Developer Tools > States but not in the Lovelace UI. All you have to do is use an Entities card to add it to the UI.

mmm but I only see scenes, no a room or group

do I need to create a sceen and that will turn off and on the lights?

Maybe this will help?