Automation spacing issue perhaps?

I am new to HA and setup a basic automation from one of the tutuorials on the HA website. Basically it dims my bedroom light when i play a moving. This works perfect. However if i try adding some more automation, it breaks my automation. I believe it a spacing issue. You can see below ### Not working ###To edit my Yaml files i am on Ubuntu and use notepadqq. Do you see any issues below? Also can you recommend an editor that does a good job with Yaml for is notepadqq ok for this?

Working

  - platform: state
    entity_id: media_player.gbox
    from: 'playing'
condition:
  - condition: state
    entity_id: sun.sun
    state: 'below_horizon'
action:
    service: scene.turn_on
    entity_id: scene.Bedroom_normal
  • alias: “Media player playing”
    trigger:
    • platform: state
      entity_id: media_player.gbox
      to: ‘playing’
      condition:
    • condition: state
      entity_id: sun.sun
      state: ‘below_horizon’
      action:
      service: scene.turn_on
      entity_id: scene.Bedroom_dim

Not working

  • alias: Turn on kitchen lights when there is movement
    trigger:

    • platform: state
      entity_id: binary_sensor.ecolink_pir_motion_sensor_sensor_4_0
      to: ‘on’
      action:
      service: homeassistant.turn_on
      entity_id: script.timed_lamp

    script:
    timed_lamp:
    alias: “Turn on lamp and set timer”
    sequence:

    Cancel ev. old timers

    - service: script.turn_off
    data:
       entity_id: script.timer_off
    
    • service: light.turn_on
      data:
      entity_id: light.bathroom_light

    Set new timer

    • service: script.turn_on
      data:
      entity_id: script.timer_off

timer_off:
alias: “Turn off lamp after 10 minutes”
sequence:
- delay:
minutes: 10
- service: light.turn_off
data:
entity_id: light.bathroom_light

One of the most common problems with Home Assistant is an invalid configuration.yaml file.

You can test your configuration using the command line with: hass --script check_config
You can verify your configuration’s yaml structure using this online YAML parser or YAML Lint.
To learn more about the quirks of YAML, read YAML IDIOSYNCRASIES by SaltStack (the examples there are specific to SaltStack, but do explain YAML issues well).

I installed home assistant using the all in one. If i try to run hass --script check_config I get bash: hass: command not found. Do i need to run this from a specific directory?

This post can perhaps help.

Thank you, that worked!

And you have found what was wrong into your config?

Also, some Notepad++ tips:

2 Likes

Yes, i had a few issues with spaces in my automation file. Ive learned alot and am loving HA.