Sum, average, calculations in scenes

Feature description
In a scene, allow calculations:

  • Average of values over a period
  • Sum of values over a period
  • Comparison of values (example 4)

Examples

1. Average humidity in the rooms of my home
« If the average humidity values are greater than 60% over 6 hours, then I trigger an action (or send a message) »

2. Average temperature over a period
« If my refrigerator has an average temperature greater than 6°C in 2 hours, then I warn that it is not cold enough »

3. Total door openings
« If my front door is opened more than 5 times in one hour, then… »

4. Overconsumption of an outlet
« If the total consumption of my outlet over 7 days is greater than 10kWh, then I warn ». But the outlet returns the instantaneous value (120W currently consumed) as well as an aggregated total value (300kWh consumed since the installation of the outlet). Therefore, it is logical to say: Day 1 = 200kWh, Day 7 = 205kWh, consumption over 7 days = 5kWh.

5. Motion detection over a period
If in case of movement a sensor returns « 1 », then summing these values over a period will allow defining if there has been movement!

Hello,

I am very interested in this feature :slight_smile:

Hi @prohand, what are you interested in?

As such, we already have certain forms of calculations in the scenes

Hi @pierre-gilles

I’m interested in points 1, 2 and 4 :wink:

I’d also like to be able to calculate the electricity cost of a device
So publish to MQTT the cost of my subscription per kWh and use it to calculate, for example, the cost over 1 day or 1 month of using a power outlet

I’d also like to be able to calculate the difference between two timestamps, for example that between 08/04/2024 10:00 and 08/04/2024 11:00 is equal to 1:00

for this I think you can already do something along those lines.

You create a virtual sensor in the MQTT integration that would be called « Total consumption »

Then you make a scene either on every consumption change, or hourly, depending on how your smart plug works, and you set the total as being the sum of itself + the new consumption value

that gives you a sum that is usable and displayable on the dashboard

You can reset it every month with a scene if you want :slight_smile:

I’ll try to see what I can do with this solution :slight_smile:

Do you have any ideas about the other points?

Thanks

For that, I’d like to understand concretely what you want to do?

Simply calculate the difference between these 2 dates :slight_smile: :
Don’t pay attention to the laundry duration ^^ I’m still getting the hang of the scenes ^^

Ah yes I understand :slight_smile:

One option would be to simply use an API or Node-RED.

Otherwise, to have that in Gladys natively, I’d say that’s a separate feature request :slight_smile:

Yes ok thanks ;)\nIt’s done for the feature request

Hello,

I would also have liked to be able to calculate an average over a given period.
For example, if a value is between 0 and 3 for a duration of 5 minutes, then we move on :wink: