[SOLVED] Multiple send telegram message

I want the rule to send a single message only when it exceeds the indicated value, because now he is sending multiple

rule "assoribimento massimo  telegram"
when
	Item Watt changed 
then
if (Watt.state > 2700){	
sendTelegram("bot1", "ATTENZIONE assorbimento oltre i 2.7 Kw!")		
}        
end 

Thanks for your help
David

Try using == instead of > else you will get a message on every change when above 2700. If the change happens fast then you may want to use something like:

if (Watt.state > 2700 && Watt.state < 2705){

Adjust the numbers to fit your needs.

does not work

if (Watt.state > 2700 && Watt.state < 2705)

probably because the value changes quickly

var boolean wattTrigger = false // At the top of the rules file!!

rule "assoribimento massimo  telegram"
when
    Item Watt changed 
then
    if (Watt.state > 2700 && !wattTrigger) {
        sendTelegram("bot1", "ATTENZIONE assorbimento oltre i 2.7 Kw!")
        wattTrigger = true  //Sets the trigger that we are over 2700
    }
    if (Watt.state < 2700) wattTrigger = false // Resets the trigger
end 

right!
it’s the same logic of the flags on arduino … I had not thought about it.
Now it works, thanks

Davide

Please mark the thread as solved, thank you