Hi!
I have been looking for attribute for ESPHome sensor which would give me e.g. in milliseconds the time how long sensor has been in current state.
Goal which I am trying to would be like this:
script:
- id: test
then:
- if:
condition:
for:
time: 10min
condition:
binary_sensor.is_on: my_sensor
then:
- logger.log: "Sensor has been on for 10 minutes now"
else:
- logger.log
format: "Sensor is now in state %.1 and has been for %.1f minutes"
args: [ 'id(my_sensor).state', 'id(my_sensor).current_state_age' ]
And the attribute / thing which i am looking for is that id(my_sensor).current_state_age
or similar.
Does anyone know how this could be achieved?