Feature description
Dans une scène, permettre les calculs :
- Moyenne des valeurs sur une période
- Somme des valeurs sur une période
- Comparaison de valeurs (exemple 4)
Exemples
1. Humidité moyenne dans les pièces de mon logement
« Si la moyenne des valeurs d’humidité est supérieur à 60% sur 6h, alors je déclenche une action (ou j’envoie un message) »
2. Température moyenne sur une période
« Si mon réfrigérateur a une température moyenne supérieur à 6°C en 2h, alors j’avertis qu’il est pas assez froid »
3. Total des ouvertures de la porte
« Si ma porte d’entrée est ouverte plus de 5 fois en une heure, alors… »
4. Surconsommation d’une prise
« Si la consommation totale de ma prise sur 7 jours est supérieur à 10kWh, alors j’averti ».
Mais prise me renvoie la valeur instantané (120W consommés actuellement) mais aussi une valeur totale agrégée (300kWh consommés depuis l’installation de la prise). Donc c’est logique de dire : J1 = 200kWh, J7 = 205kWh, consommation sur 7 jours = 5kWh.
5. Détection du mouvement sur une période
Si en cas de mouvement un capteur renvoie « 1 », alors faire la somme de ces valeurs sur une période permettra de définir s’il y a eu du mouvement !
Hello,
I am very interested in this feature 
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 
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 
1 Like
I’ll try to see what I can do with this solution 
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
:
Don’t pay attention to the laundry duration ^^ I’m still getting the hang of the scenes ^^
Ah yes I understand 
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 
1 Like
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 