Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 95308

Trying to create a generalised light toggle script

$
0
0

@ianadd wrote:

Because light.toggle ignores color_name I can’t reset my coloured hue light with a toggle of my smart light switch. So, not wanting to produce a script for every switch, I’ve been trying to create a generalised script to do the job and am tearing my last remaining hair out. Can anyone see where I am going wrong, please. Or show me a better way !

test_toggle:
  alias: test light toggle
  sequence:
    - service: script.turn_on
      entity_id: script.light_toggle
      data:
        variables:
          lght: 'office'

light_toggle:
  alias: toggle light to white
  sequence:
    - service_template: script.light_toggle_{% if is_state("{{ 'light.' ~ lght }}" , 'off') %}on{% else %}off{% endif %}
      data_template:
        variables:
          thislight: "{{ lght }}"
      
light_toggle_on:
  alias: light_on
  sequence:
  - service: light.turn_on
    data_template:
      entity_id: "{{ 'light.' ~ thislight }}"
      color_name: white
      brightness: 255
light_toggle_off:
  alias: light_off
  sequence:
  - service: light.turn_off
    data_template:
      entity_id: "{{ 'light.' ~ thislight }}"

Posts: 3

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 95308

Trending Articles