Automation Trigger with Counter higher then previous

Hey there.
I tried my best and got my first api integration running. I could only extract a numeric number from a total of calls (app used for emergency dispatch). Like: total number of calls „…“.
This will only go up with every new call.

The idea is to fire an automation, everytime there is a new call, so the number is grater then before.

For example:

Sensor value is set to 10

There is a new call, sensor will go to 11.

Then the automation would fire. (Maybe with the condition that I’m home…)

The new value would be 11 and it should fire when the new value of 12 comes up.

I can’t get my head around it.

I’m sorry for my bad English, I’m not a native speaker.

All the best and thanks in advance,

Angelo

trigger:
  - platform: state
    entity_id: sensor.example
condition:
  - condition: template
    value_template: '{{ trigger.to_state.state | int > trigger.from_state.state | int }}'
  - condition: state
    entity_id: person.angelo
    state: home
action:
....

PERFECT - Thank you so much, it works!
Would it be possible to like “turn on a virtual switch”? Or sensor? So that i could make a lovelace popup when there is an alarm for a certain time? Or any other idea to visualize the alarm? :slight_smile:

You can set the actions to do whatever you need them to do.

If your goal is to have it act more like a binary sensor, there are other ways to do it that are a little “cleaner” but they are a bit more complicated to explain.

Doesn’t have to be „clean“, just function :joy:

So I assume I could switch a virtual button for a amount of time to on an then back to off ? Or ist there a nicer way to do this ?
I’m willing to read, but I don’t know where to start.

Thanks in advance for your time and effort !

It would be easier to give you specific guidance if we knew what the end goal is…

Community Guidelines: How to Ask a good Question

The Goal is the following:
Our vouluntary EMS gets their (our) calls via an App. The App has an api which delivers Data from the call and a counter on how many calls you got in total. The Idea would be to get Alexa to announce if there is an Alarm. I did this via the Automation you wrote above.
I also wanted to have my tablets display that there is an alarm going on, so i thought it would be easier to have a boolean sensor which switches to on if the number goes up (like with your automation) and use this sensor for a card which only comes up when there is an active alarm for a couple of minutes and then dissapers.
I hope I got the Information you need

Nobody has an Idea? :frowning:

Have you chosen a method for notification or is that what you are asking for help with?

I did it trough notify aleaxa. But i want an conditional card which shows up for a certain amount of time on the tablets if there is an alarm

For a standard conditional card, one option would be to use a Timer helper. Once you have created the helper, set the condition in the card to be that the timer’s state is ‘active’. Then you would add a timer.start service to your original automation’s action section.