Why is my automation not saving what I type in?

So, I type this automation

alias: "Inactivity"
description: ""
trigger:
  - platform: state
    entity_id:
      - binary_sensor.upstairs_occupancy
    from: "on"
    to: "off"
condition: []
action:
  - service: notify.mobile_app_xxx_iphone_12
    data:
      message: "Clear"
mode: single

I save it. I re open it right away but now this is the new code:

alias: "Inactivity"
description: ""
trigger:
  - platform: state
    entity_id:
      - binary_sensor.upstairs_occupancy
    from: "on"
    to: "off"
condition: []
action:
  - data:
      message: Clear
    action: notify.mobile_app_xxx_iphone_12
mode: single

This code doesn’t work. Why does it edit what I wrote?

I assume you are using the automation editor UI, switching to YAML mode, and passing that text there?

If so, the UI will reformat your text based on its own preferences. If you need to keep your automations unmodified you have to place them in a text file and point to it with your config. Or place it in configuration.yaml

But, the changes made to the file are not affecting functionality. The order of items in a dictionary is irrelevant, and starting with 2024.8 all references to “services” are being replaced with “actions” (but using “services” in yaml will continue to be supported).

If your automation isn’t working, there is something else to blame. Check the logs for errors and check the trace also.

This is the error I get: The automation “Activity” (automation.upstairs_movement) has an unknown action: notify.mobile_app_xxx_iphone_12.

This error prevents the automation from running correctly. Maybe this action is no longer available, or perhaps a typo caused it.

So is it telling me I can’t use notify.mobile_app_xxx_iphone_12 as an action?

What I don’t understand is that it’s fine in other automations. The same exact calls to notify my iPhone.

So what is the proper way to use notify as an action in an automation?

Like this one works fine:

alias: "Dryer is done"
description: ""
trigger:
  - platform: state
    entity_id:
      - binary_sensor.dryer
    from: "on"
    to: "off"
    for:
      hours: 0
      minutes: 0
      seconds: 5
condition: []
action:
  - data:
      message: The Dryer is done
    action: notify.mobile_app_xxx_iphone_12
mode: single

K looks like my phone was switched to xxx_iphone_12_2.
I have no clue why. But this seems to be the problem. Then again, why would the Dryer automation work fine? Not very logical.

You’d have to look at the action your dryer automation is using. It’s not possible for the same action to cause an error in one automation but work fine in another.