First script, HA can't load script component

Hi guys,

At a loss here as HA dev panel doesn’t give me any errors to work back from.

Made my first script in scripts.yaml, set to !include this file. Script:

- door_bell_daytime_weekday:
  alias: Door bell daytime weekday
  sequence:
  - condition:
      condition: and
      conditions:
      - condition: sun
        after: sunset
        after_offset: "-01:00:00"
      - condition: time
        weekday:
          - mon
          - tue
          - wed
          - thu
          - fri  
  - service: switch.turn_on
    entity_id: switch.scrolling_lights
  - delay: 
    seconds: 5   
  - service: switch.turn_off 
    entity_id: switch.scrolling_lights     

HA gives me a notification window that the script component/platform couldn’t be loaded and to check my config but I don’t know where to start!

I think you can’t have conditions inside a script…

Indentation is wrong.

Remove the hyphen at the start.

You can have conditions in scripts FYI.

door_bell_daytime_weekday:
alias: Door bell daytime weekday
  sequence: # Everything below here needs to be 2 spaces farther out
  - condition:
      condition: and
      conditions:
      - condition: sun
        after: sunset
        after_offset: "-01:00:00"
      - condition: time
        weekday:
          - mon
          - tue
          - wed
          - thu
          - fri  
  - service: switch.turn_on
    entity_id: switch.scrolling_lights
  - delay: 
    seconds: 5   
  - service: switch.turn_off 
    entity_id: switch.scrolling_lights 

(I would’ve added the spaces but I’m on my phone :+1:)

also check all of your indenting. it looks like there are several places where the indentation is off.

door_bell_daytime_weekday:
  alias: Door bell daytime weekday
  sequence:
    - condition:
      condition: and
      conditions:
      - condition: sun
        after: sunset
        after_offset: "-01:00:00"
      - condition: time
        weekday:
          - mon
          - tue
          - wed
          - thu
          - fri  
    - service: switch.turn_on
      entity_id: switch.scrolling_lights
    - delay: 
      seconds: 5   
    - service: switch.turn_off 
      entity_id: switch.scrolling_lights 

I think the above is correct. double check me on it tho.

Thanks guys, it was partly the indenting and partly the first condition: line was un-needed, it starts on the condition: and line just fine.

I figured it was indent related, I actually fixed it before coming back to the forum by deleting all my indents and re-doing them after I’d written all the code, it seems easier in my brain that way!

I didn’t know that. Sorry…