Measuring value condition

Hello
I would like to ask you how can i measure how much time on a day is a value (lets say the current consumption Watt) of my tp+link plug Hs100, is above of a value like 4 watts in a day,month,4 month.My purpose is not to see that the entity is on because it is all day but how much time consume more than 4 watts. This will help me to make a Tank oil meter only with one smart plug and calculate the remaining litres. I know it sounds crazy but i think it will work.

Doing this to the second would be kinda processor intensive.
How about if you test each minute and add 1 if the measured value is > limit
Then at 00:00 store the value, reset and start again ?

It sounds good but which component need to use for that. Iam knda new to HA. If u can do an example to start i would appreciate.

This is not an answer to your question, but maybe the statistics sensor or the history statistics sensor could be of use as it seems that you are trying to calculate a time derivative? https://www.home-assistant.io/integrations/statistics/ and https://www.home-assistant.io/integrations/history_stats/

Another approach could be to make a template sensor that is on when the value of your sensor is above 4 watts, and then use that sensor as input for the history statistics sensor.

It is also worth noting that the HS100 does not track power consumption, it only controls on/off, the HS110 tracks power usage.

Hs 110 is what i have . I write it wrong .sorry

Thomas is one of our statistics experts, and this is far more in his field than simple automations.
Follow his advice and if you run into difficulties he will assist (I’ve have seen him doing so in many threads)
Good luck

I finally i manage to make it work. i follow your suggestion but i made an input Boolean to change state when my watts is above. I make some other calculations and i manage to watch my Oil heating consumption in liters from just one smart electricity plug. I will test more this approach and i will publish my project to the project section when it is ready.

Thank you a lot

1 Like