#Simple script

1 messages · Page 1 of 1 (latest)

worldly sail
#

Trying to make a script i can call in an automation and not sure what im doing wrong

- if:
    - condition: state
      entity_id: light.sw2_b_new_light_1
      state: "on"
  then:
    - service: light.turn_off
      target:
        entity_id: light.sw2_b_new_light_1
    - delay:
        seconds: 2
  else:
    - service: light.turn_on
      target:
        entity_id: light.sw2_b_new_light_1
    - delay:
        seconds: 1
    - service: light.turn_off
      target:
        entity_id: light.sw2_b_new_light_1
    - delay:
        seconds: 2

- service: light.turn_on
  target:
    entity_id: light.sw2_b_new_light_1
  data:
    brightness_pct: 100```

says "extra keys not allowed at data[0] ive messed with this for a few hours now and am just tired at this point please help me
celest arch
#

Where are you putting that? It's just a fragment of a script

worldly sail
#

where am i supposed to put it?

celest arch
#

You should build it in the UI script editor if not you're familiar with YAML

worldly sail
#

i just want to run a sequence of actions based on conditions when i press a button or use an automation

#

the script editor thing isnt letting me add conditions and what not

#

idk if im even in the right spot

#

i need to start by seeing if the light is already on or not

celest arch
worldly sail
#

this is even more confusing lol

#

where is the condition for is device on/off lol

#

ah it has other stuff to the right i see it now

worldly sail
#

got it working now thanks

#

I lied 1 condition is failing the brightness check