HI @Lorenzo_Mao and welcome to the InfluxDB forum.
Instead of the stateDuration function, use elapsed(). Have a look at this post. You should be able to modify for your purposes.
HI @Lorenzo_Mao and welcome to the InfluxDB forum.
Instead of the stateDuration function, use elapsed(). Have a look at this post. You should be able to modify for your purposes.