I have made a notification if the battery is more than 80% then send a message to the Iphone. But I keep getting this message if the battery is above this value. How can I ensure that this only happens once?
alias: Peugeot CAR Batt is > 80%
description: ""
triggers:
- trigger: numeric_state
entity_id:
- sensor.psa_battery_level
above: 80
conditions: []
actions:
- device_id: xxxxxxxxxxxxxxxxxxxxxxx
domain: mobile_app
type: notify
message: Peugeot batt is > 80 %
mode: single
I believe you should make an helper that changes state based on the battery value.
Here in this post there is a suggested solution:
Then you trigger the automation based on the binary sensor state, binary changes state from 0 to 1 (OFF to ON) message sent.
the state will be ON until the battery charge does not decrease so no other messages.
then the binary state will go OFF because the battery is discharged and the ON again when charge and so on.
At a guess, your sensor is going unavailable or giving spurious zero readings. Your automation should only run if the battery level changes from below 80 to above 80.
Have a look at the history for that sensor; and look at the automation traces. In particular, look at the from_state and to_state values.