Message if a statistic value is above a Value

Hello,
I have a pelet heater who send me the pelet consommation.
I use a utilitimeter entite who is reseted to zero avery day.
I have made a dashbord with information of consomation over the day,the week , the month… and since last time I refill the buffer, works as espected.
Look like this :


all card are statistics card.
I fill my buffer one time per year so I use long therm statistics.

My question is how can I have a notification (mail or telegram (alredy setups)) when the value since las refill fromm the buffer is over a value (2000 kg for ex)

If its possible I woul like to use node red for that but I m open for all solution

thank you for your help
regads
Yogui

For the utility meter that contains the value since you last refilled the buffer: that should be configured without a reset cycle. And whenever you refill the buffer, you should have a way to manually reset that to zero (for example with a button on your dashboard).

Triggering a notification would be as simple as making an automation that triggers when the utility meter goes above 2000kg. I don’t use node red but I assume that it is trivial to do. In HA it’s just an automation with a numeric_state trigger.

thanks for you answer,
the utilimeter is configurate wirh a daly reset,

conso_pellets:
source: sensor.chaudiere_consommation_pellets
unique_id: “conso_pellets”
name: Consommation pellets
delta_values: false
cycle: daily
always_available: true

and the statistic card is configurat so :

type: statistic
entity: sensor.consommation_pellets
period:
fixed_period:
start: “2024-03-18T00:00:00.000Z”
stat_type: change
name: Recharge

in this case a need to make a second utilimeter only for that

Is that the only way ? I previously used Jeedom and for this kind a feature it was possible to maque a php script to make a history request for long time

The only way to query the history is to create an SQL sensor. So in this case, creating a utility meter is the much better option.

thanks for your answere

I just try with the second tulity meter only for that, the value only take the pellet consuption since a create the utility meter tha mean until I refill the buffer I will not have a realistic value, I will chec the documentation from the sql sensor

You can set the value of the utility meter sensor using the utility_meter.calibrate action (link)

hello
in the meantime I studied SQL integration
thanks to the documentation , the forum, my new best freind, in those cases, chat_gpt :wink: and my basic knowlage from SQL query , I create a SQL query for the complet calculation. one of the avantage from the query il also that I can use an input_datetime entity for select the refill date from the buffer (more flexible in case of mistake)

her the SQL query configuration

and the query

SELECT 
    (last_value.sum - first_value.sum) AS difference
FROM 
    (
        SELECT 
            sum
        FROM statistics
        WHERE 
            metadata_id = (
                SELECT id FROM statistics_meta WHERE statistic_id = 'sensor.consommation_pellets'
            )
            AND start_ts >= strftime('%s', (
                SELECT states.state 
                FROM states 
                WHERE metadata_id = (
                    SELECT metadata_id
                    FROM states_meta 
                    WHERE entity_id = 'input_datetime.remplissage_silot_pellet'
                )
                ORDER BY state_id DESC LIMIT 1
            ))
        ORDER BY start_ts ASC
        LIMIT 1
    ) AS first_value,
    (
        SELECT 
            sum
        FROM statistics_short_term
        WHERE 
            metadata_id = (
                SELECT id FROM statistics_meta WHERE statistic_id = 'sensor.consommation_pellets'
            )
            AND start_ts <= strftime('%s', 'now')
        ORDER BY start_ts DESC
        LIMIT 1
    ) AS last_value
LIMIT 1;

the message generation inside node red is yet not an issue for me

thank you @mekaneck for your help/ideas