Status change

Hello everyone. I am doing an automation so that when the printer changes color it sends me a message. When I run the automation the message arrives but it seems to ignore the status that goes from true to false. Does anyone see any errors? What I am doing is asking that they all go from true to false or that when one of the four sensors changes state, does it send the message? Thank you so much

alias: Cambio filamento AMS
description: ""
trigger:
  - platform: state
    entity_id:
      - sensor.ams_1_tray_1
    attribute: active
    from: "true"
    to: "false"
  - platform: state
    entity_id:
      - sensor.ams_1_tray_2
    attribute: active
    from: "true"
    to: "false"
  - platform: state
    entity_id:
      - sensor.ams_1_tray_3
    attribute: active
    from: "true"
    to: "false"
  - platform: state
    entity_id:
      - sensor.ams_1_tray_4
    attribute: active
    from: "true"
    to: "false"
condition: []
action:
  - action: notify.mobile_app_pixel_7
    metadata: {}
    data:
      title: AtenciĂłn
      message: Cambio de color AMS
  - action: notify.alexa_media_echo_dot
    metadata: {}
    data:
      message: Cambio de color AMS
      title: Atencion
mode: single

Paste the automation trace here and the values from the attributes from the developer tools. We can not tell what the device does by just looking at the automation.

You are saying the state goes from true to false, but you are checking for attribute active, not the state. If the state is a binary sensor, on or off would be what is expected. Also you are testing the attribute for a string “true” or “false”. It depends what the type of the attribute you are testing for actually is, but these strings also seem unlikely.

In the developer tools you see that the active attribute goes from true to false
Is this what you need to see?


If it is the attribute you should be looking at then I believe you can remove to and from on all of the triggers.
You essentially trigger on all state changes anyways.

I did it but I think it sends me a message when the temperature changes because it sends the message several times

alias: Cambio filamento AMS
description: ""
trigger:
  - platform: state
    entity_id:
      - sensor.ams_1_tray_1
  - platform: state
    entity_id:
      - sensor.ams_1_tray_2
  - platform: state
    entity_id:
      - sensor.ams_1_tray_3
  - platform: state
    entity_id:
      - sensor.ams_1_tray_4
condition: []
action:
  - action: notify.mobile_app_pixel_7
    metadata: {}
    data:
      title: AtenciĂłn
      message: Cambio de color AMS
  - action: notify.alexa_media_echo_dot
    metadata: {}
    data:
      message: Cambio de color AMS
      title: Atencion
mode: single

Sorry. I think the only thing that should change is “active”
I think he sent me several messages for another reason.

You should have kept active as attribute.

Have a look at the triggering on attribute changes section of the docs.

I could be wrong, but I don’t think attribute changes support both from: and to:.

Go back to your original automation and remove every from: line you had. Hopefully that will fix your issue.

It does.
You can have both to and from.

1 Like

You can have both.

It shouldn’t matter, but I wonder what happens if you remove the quotes from true and false. You could also try if removing the from works, there might be a short moment in between that the value is something else. If it works, the trace would tell you what it was.

1 Like

It works without the quotes. If so, there may be a home assistant error. I did not write the automation but rather it was created from the visual environment

Thank you very much for help.

The automation editor assumes strings, so it adds the quotes. That is true for states, but not always for attributes, because those can have other types. What I do not understand is that if the attribute were a Boolean, the values would be True or False, not true and false. But anyway, maybe something strange happened where the quotes were considered part of the string, or something else. I’m just glad it worked.

Maybe. I will then try adding the quotes to yaml to see if it was an editor problem. But without the quotes with the attributes it works

I just saw yaml may use true and false for Booleans. So it may be the attribute really is a Boolean, and therefore does not equal a string.

Perfect. It has logic.