Hi
I am trying to write an automation with several nested IF statements. Since I am unsure of some syntax etc, I started in visual editor. But after a while, its easier to copy paste things in YAML. This prompted some questions:
1, to make things clear, I added #comments to some lines. I was hoping these would show up in the visual editor, but no. Is there a way to do this? even worse, the comments I add disappear as soon as I save and exit the automation (as next time it is opened in the visual editor). This is surely shouldnt happen? how do I preserve comments?
2, I sorta got around comments by renaming IF statements in the visual editor, it shows up as alias: in the yaml. Strangely, sometimes its put in the beginning, and mostly in the end:
action:
- alias: if its daytime
if:
- condition: sun
before: sunset
after: sunrise
then:
- if:
- condition: state
entity_id: input_select.nappali_state
state: normal
then:
- action: light.turn_on
metadata: {}
data:
brightness_pct: 66
target:
entity_id: light.tv_led
alias: if nappali_state is normal
if I try to do it this way, I get an error:
action:
- alias: if its daytime
if:
- condition: sun
before: sunset
after: sunrise
then:
- alias: if nappali_state is normal
if:
- condition: state
entity_id: input_select.nappali_state
state: normal
then:
- action: light.turn_on
metadata: {}
data:
brightness_pct: 66
target:
entity_id: light.tv_led
this would make more sense to me, as the alias is up front, not in the end
3, I am used (in Fibaro/LUA) to troubleshoot by adding small prints (like ‘print: sun is up, going with daytime lights’) in the automation, so I can follow what is happening. I know there are traces in HA, and it might actually be a better way, but is there a way to print results in a terminal or something?
thanks