MQTT triggering scripts - YAML errors?

I’m trying to trigger a script when a specific MQTT message arrives, from the reading I’ve done, I think I’ve got the right information in the configuration file, I think I’ve just not worked out how to write it in YAML…

Here’s my automation section:

79 automation:
80   - alias 'Study Lights On'
81     trigger:
82       - platform: mqtt
83         topic: lightswitch/study
84         payload: 'on'
85     action:
86       service: shell_command.switch_lights_on
87   - alias 'Study Lights Off'
88     trigger:
89     - platform: mqtt
90       topic: lightswitch/study
91       payload: 'off'
92     action:
93       service: shell_command.switch_lights_off
94 
95 shell_command:
96   switch_lights_on: '/root/apc.py --on 3'
97   switch_lights_off: '/root/apc.py --off 3'

The errors I’m getting now are:
2017-09-09 19:52:33 ERROR (Thread-2) [homeassistant.util.yaml] mapping values are not allowed here
in "/root/.homeassistant/configuration.yaml", line 80, column 12
2017-09-09 19:52:33 ERROR (MainThread) [homeassistant.bootstrap] Error loading /root/.homeassistant/configuration.yaml: mapping values are not allowed here
in "/root/.homeassistant/configuration.yaml", line 80, column 12

I’ve had loads of different errors depending on how I format the text, but I can’t work out the right way.
Can anyone tell me what I’m doing wrong?

Well from the logs it seems that there is a syntax error in line 80…

What do you have in 79/89/90 ?

I’ve modified the code to add line numbers.
79 is the initial automation line.

Cheers :slight_smile:

You’re missing the colon after alias.
- alias: 'Study Lights On'
Also check the indentations of the second automation.

1 Like

It works!

I can now control my lights from MQTT, thanks :smiley: