Newbie visual->yaml

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

That is the normal behavior when using the GUI Automation and Script Editors.

As far as the YAML interpreter is concerned, they are the same. But no matter which order you put them in, they will be rewritten in the default order if you are using the GUI Editors.

There are a number of notification integrations that can be used for that. Persistent notifications is probably the most commonly used, but you might also consider the File notification or the logbook.log action.

Hi rbhun,

You can put the alias: in by the condition or action sections like this:

  - if:
    - alias: turn the light & set brightness
      condition: template
      value_template: "{{ is_number(transition_var) }}"
    then:
      - alias: "Transition number IS available"
        action: light.turn_on
        data:
          entity_id: '{{ light }}'
          brightness_pct: '{{ bright_p }}'
          transition: '{{ transition_var }}'
    else:
      - alias: "NO transition number available"
        action: light.turn_on
        data:
          entity_id: '{{ light }}'
          brightness_pct: '{{ bright_p }}'