Automation not triggering checking battery

I’m trying to create an automation to run when the battery level changes.

{{ state_attr('lawn_mower.sileno', 'battery_level') }}

Gives me 100, 90 etc.

So I am trying this but the automation never seem to trigger.

alias: Notify if robot mower has low battery
description: ""
triggers:
  - entity_id:
      - lawn_mower.sileno
    for:
      hours: 0
      minutes: 0
      seconds: 0
    trigger: state
    attribute: battery_level
    to: "90"
    from: "100"
conditions: []
actions:

Why is it not executed?

Hello karl,

Are you certain it is able to jump from “100” to “90”? (exactly).
That is text and you are using a state trigger not a number trigger.

I would look at that entity in the developer console and figure out exactly what the value is and is not.

When you configure the State Trigger with this:

    to: "90"
    from: "100"

You are telling it to trigger when the value changes directly from 100 to 90. In other words, the battery level has to drop exactly that way in order to trigger. If it drops by 1 or 5 then that won’t fulfill the trigger’s requirement of “100 down directly to 90”.

Are you sure this is how you want it to work?

Use your template expression as the automation trigger.

Also try removing the quotes. Attributes can be real numbers.

Yeah I was realizing the value is a number and not a string. But string is only supported in the automation it seems. Can the number be parsed to a string?

Yes, the mower battery goes in 10% intervals, 100, 90, 80, 70 etc.

Use a numeric trigger instead.

  1. What is the current state value of lawn_mower.sileno? (You can check it in Developer tools → States)

  2. What does the recorded history of lawn_mower.sileno show? (In Developer tools → States, click the information icon displayed on the lower left of the lawn_mower.sileno entity)