How to edit a trigger condition for a numerical difference

**About automation edit for a numerical sensor **

I make a RESTful sensor to get my stock tading profit. and i need an [automation] to notify me when the profit rate change fast.

So how to edit a trigger condition for a numerical difference ?

Or how to compare the sensor state with the old state of it ?
I only know set a low or high limit for a numerial for the state of sensor . How can make it for the change of it?

Don’t put a condition for the state.

Then use trigger.to_state and trigger.from_state to compare what it was to what it’s changing to.

trigger:
  platform: state
  entity_id: sensor.stock_profits
conditions:
  condition: template
  valute_template: "{{ (trigger.to_state.state | float ) - (trigger.from_state.state | float) > 100.0 }}"
action:
  ...
  
1 Like

So fast and detailed help. i’ll try it.Thank you so much bro.

It works now wih @jocnnor 's code.

And this reference for green hand like me with similar need.

1 Like