Item changes too fast for rule?

Hi everyone,

i am using the telegram binding in my rules. Instead of using the telegram action in every rule I created one item and a rule is reacting when the item is changed.

In a rule I define the messages with theese items:

            BenachrichtigungTelegram.postUpdate("Die Waschmaschine ist fertig")
            BenachrichtigungTelegram.postUpdate("Maximaler Verbrauch: " + Waeschetrockner_Max_Verbrauch.state)

One other rule is reacting when this item is changed:

rule "Benachrichtigung Telegram"


    Item BenachrichtigungTelegram received update


    var nachricht = BenachrichtigungTelegram.state

    var telegramAction = getActions("telegram","telegram:telegramBot:FSS6")

    telegramAction.sendTelegram("benachrichtigung: "+ nachricht)


I would expect that I receive 2 messages, one with the message “Die Waschmaschine ist fertig” and one with “Maximaler Verbrauch xxx kw”

But instead I just receive the second message 2 times. The first message is ignored. I guess that is because the item is changed too fast, so the item has the 2. status before the messaging rule can send the first message.

Is there a way to prevent this and still keep my notification rule or do I need to move the notification back to every rule which is using telegram notifications?

Probably. By the time your rule has started and reads the Item state, the state has already changed to second message.

If you can change to use command instead, the rule can be triggered on command events and use the payload in receivedCommand.
Commands are events, not steady states, so you’ll get an automatic queue of however many you send.

Of course, then you’ll find out how good telegram is at handling rapid fire message bursts :wink:


Thank you, a first test looks pretty good. I will keep an eye on it.

Another option is to use newState for received update and changed triggered rules. That implicit variable will contain the state of the Item that caused the rule to trigger even if the Item has changes state since then.

I this particular case, since the rule is being asked to cause something to happen outside of openHAB itself, received command is the more appropriate trigger. But I wanted to make it clear that the problem can be managed even for received update and changed triggered rules.