Hi guys,
While teaching myself to setup automations via examples here and elsewhere I noticed in the offset: part of sun triggers that sometimes authors used " " around the trigger offset time, and sometimes used ’ ', and other times nothing at all. Which is the correct way " or ’ or nothing ?
automation:
trigger:
platform: sun
event: sunset
offset: “-00:45:00”
Quotes are generally needed when enclosing spaces, or other characters that might be misinterpreted by the underlying software. In general they don’t do any harm, so people add them anyway. AFAIK, there is no difference between ’ and " in yaml.
However, there are some cases where enclosing in quotes actually means something different. For instance, in a json paylaod true is a boolean but “true” is a string.
Right OK thanks.
My automation to set a mqtt switch via event sunset is not working at all in either case, so my trouble is something else now I guess…
Hey if I might bug you for another tip, can you tell me if I need to restart HA when I add or modify an automation ?
I’ve now tried to get a an event: time to work on a working switch (i.e. that works fine via the HA GUI switch) and it’s not working either. I’m missing something fundamental I think and I can’t see it.
(PS. My HA is on Raspberry Pi).
Re sun trigger documentation, yes I’ve studied it as well as other examples. Actually I’m using the Automation GUI in HA and then checking what it’s done in the automation.yaml.
I’m afraid you do. That’s one of the main reasons I switched to using Appdaemon for my automations. But you need to learn some Python for that, so it might not be suitable for you.
I have never used the automation gui, so I can’t help there.
If you post what you have, and a description of what doesn’t work, someone here will certainly have some idea.
This is what the GUI builds in automations.yaml below, for my testing…
I’ll restart now though, that’s probably what is wrong, I must have missed that instruction someplace.
The syntax seems a bit backwards to my inexperienced eyes, with stuff like platform listed last…