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

Help needed with passing variable to script

$
0
0

@Jumperr wrote:

Hi, I am trying to pass a state value (on/off) of my yeelight lamp from an automation to a script. The script first changes the color of the lamp to yellow for 1s and then, based on previously passed state value either changes the color back to a previous one and leaves the lamp turned on (if the state before running the script was “off”) or turns off the lamp (if the state was “off”).

The problem is I do not know how to test the passed variable in a condition statement.
The automation.yaml part looks like:

action:
    service: script.blink_lamp
    data:
      lamp_state: >
                      {{ state_attr('light.lamp_bedroom) }}

The scripts.yaml part looks like:

'blink_lamp':
  sequence:
    - service: light.turn_on
      data:
        entity_id: light.lamp_bedroom
        RGBTransition: [255, 215, 0, 1000, 1] 
    - condition: template
       value_template: {{ lamp_state == 'on') }}
    - service: light.turn_on
      data:
        entity_id: light.lamp_bedroom
        RGBTransition: [255, 64, 0, 1000, 1] 

I am getting the parsing error:

Error loading /config/configuration.yaml: invalid key: "OrderedDict([("lamp_state == 'on')", None)])"
  in "/config/scripts.yaml", line 9, column 0

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 102441

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>