cancel
Showing results for 
Search instead for 
Did you mean: 

WTF am i doing wrong?

GHScriptnewbe
Community Member

Trying to write my first script and everything looks good, but I have a **bleep** syntax error that i cant resolve.

what am I missing?

Capture.JPG

5 REPLIES 5

RemarkMedia
Community Member

hi! If I'm not mistaken, then you just need to remove the duplicated "action" function

devreserg
Community Member

I had the same issue earlier.  You can have multiple functions... that's not your problem.  The problem is your indentations don't take into account for multiple functions.  You have to tab indent your action block of code (actions, type, devices, on) one more indentation and you should be okay.  

 

You can reference the examples here to see the subtle differences with tab indentations: https://developers.home.google.com/automations/example-scripts

 

I was working on something similar to the following when I hit your exact issue: 

 
I hope this helps

Hollen_ar_mor
Community Member

For multiple starters - actions, I'd rather to use "name" for each :

Hollen_ar_mor_0-1696445790565.png

And yes, take very care of the indentation !

 

Elektrowolle
Community Member

Hi,

I hope you figured it out by now and the struggle paid out.
I see two mistakes in your YAML code:

  1. Your key and value for weekdays are not separated by a space.  You write "weekdays:[MON", it should be: "weekdays: [MON"
  2. The delimiter for lists in YAML is the comma"," not the semicolon ";". Instead of "[MON;TUE;WED" it should be  "[MON, TUE, WED" (Yes, I even put some spaces in between. It is not required, though)

Code for computers is always a compromise between readability for humans and non-ambiguous statements for machines.

It might help you next time to use a converter like https://jsonformatter.org/yaml-to-json to check if your YAML is interpreted in the way you expect it.

 

Cheers!

Okabe
Community Member

Did you work this out? I'm having a similar issue