Simple script fails config check - please help

Hi All,

I am trying to write my first script but it fails the built-in config checker. Can someone please point out what I am doing wrong here? I have tried to use someones example on GitHub and it is so similar that I just dont see where the problem is.

bedtime.yaml

sequence:
  - service: homeassistant.turn_off
    data:
      entity_id: media_player.lounge_tv
  - service: switch.turn_off
    data:
      entity_id: switch.amp_power
  - service: homeassistant.turn_on
    data:    
      entity_id: light.bedroom_lamp
      brightness: 50

this is what i get in the log:

2018-01-08 08:32:38 ERROR (MainThread) [homeassistant.config] Invalid config for [script]: expected a dictionary for dictionary value @ data[‘script’]. Got [OrderedDict([(‘sequence’, [OrderedDict([(‘service’, ‘homeassistant.turn_off’), (‘data’, OrderedDict([(‘entity_id’, ‘media_player.lounge_tv’)]))]), OrderedDict([(‘service’, ‘switch.turn_off’), (‘data’, OrderedDict([(‘entity_id’, ‘switch.amp_power’)]))]), OrderedDict([(‘service’, ‘homeassistant.turn_on’), (‘data’, OrderedDict([(‘entity_id’, ‘light.bedroom_lamp’), (‘brightness’, 50)]))])])])]. (See ?, line ?). Please check the docs at Scripts - Home Assistant
2018-01-08 08:32:38 ERROR (MainThread) [homeassistant.setup] Setup failed for script: Invalid config.

I don’t think you need data: for the first two and the for last one try light.turn_on

I just tried it and it still fails…

2018-01-08 09:01:20 ERROR (MainThread) [homeassistant.config] Invalid config for [script]: expected a dictionary for dictionary value @ data[‘script’]. Got [OrderedDict([(‘sequence’, [OrderedDict([(‘service’, ‘homeassistant.turn_off’), (‘entity_id’, ‘media_player.lounge_tv’)]), OrderedDict([(‘service’, ‘switch.turn_off’), (‘entity_id’, ‘switch.amp_power’)]), OrderedDict([(‘service’, ‘light.turn_on’), (‘data’, OrderedDict([(‘entity_id’, ‘light.bedroom_lamp’), (‘brightness’, 50)]))])])])]. (See ?, line ?). Please check the docs at Scripts - Home Assistant
2018-01-08 09:01:20 ERROR (MainThread) [homeassistant.setup] Setup failed for script: Invalid config.

the reasoning behind having data: in there was simply because its what I have seen in the GitHub example I was referring to:

sequence:
  - service: input_boolean.turn_off
    data:
      entity_id: input_boolean.movie_mode_light
  - condition: state
    entity_id: switch.living_room_ceiling_light
    state: 'on'
  - service: input_boolean.turn_on
    data:
      entity_id: input_boolean.movie_mode_light
  - service: switch.turn_off
    data:
      entity_id: switch.switch.living_room_ceiling_light
  - service: light.turn_on
    data:
      entity_id: light.couch_lights

but also in the docs:

 service: switch.turn_on
          data:
            entity_id: switch.skylight_close

I think it’s because you haven’t given it a name…

as it’s complaining about sequnce by the looks of it…

  example_script: <----------------------try naming it 
    sequence:
      # This is written using the Script Syntax
      - service: light.turn_on
        entity_id: light.ceiling
      - service: notify.notify
        data:
          message: 'Turned on the ceiling light!'

Nope. That didn’t work either. I don’t believe it needs a name since it’s in it’s own yaml file.

From the ‘examples’ page on the HA website I worked from this:
image

Here there is no name and Teagan has used the data: line which is why I did too…

Maybe it’s something to do with the way you are loading the file?

I created it with the IDE addon in HassIO. The structure of the filing system is:

config folder> configuration.yaml

script: !include_dir_list scripts

config folder> scripts folder> bedtime.yaml

sequence:
  - service: homeassistant.turn_off
    data:
      entity_id: media_player.lounge_tv
  - service: switch.turn_off
    data:
      entity_id: switch.amp_power
  - service: light.turn_on
    data:    
      entity_id: light.bedroom_lamp
      brightness: 50

I haven’t tried to run the script reload function and test it out as it hasn’t passed the config validation

So I tried something else via the IDE editor by creating a scripts.yaml with pretty much the same code but adding in the name and alias and that passes the config check… what is going on here?

scripts.yaml

bedtime:
  alias: Turn TV and Amp off and turn on bedroom lamp
  sequence:
  - service: homeassistant.turn_off
    data:
      entity_id: media_player.lounge_tv
  - service: switch.turn_off
    data:
      entity_id: switch.amp_power
  - service: light.turn_on
    data:    
      entity_id: light.bedroom_lamp
      rgb_color: [226, 147, 36]
      brightness: 200
  - delay: '00:05:00'
  - service: light.turn_off
    data:
      entity_id: light.bedroom_lamp
      transition: 60

Why does the above pass but my previous code in it’s own yaml file fails?

Because you’re using merge_list when it should be merge_named :+1:

umm ok…? It’s the same way I have all my automations… I’ll give it a try. Thanks!

Automations are written in lists.

Scripts are written with names.

When you merge them with includes you must merge them in the correct format :+1:

ok, thanks for the clarification.