"First Time" Rule

Hello,
I have a self-built Flood Sensor on ESP8266 basis via MQTT…so values like 978 mean dry floor…if its 700 it will start getting wet with arround 1mm flood.

So if I put a simple rule to send an email when a value comes in below 700…i will receive once per minute a mail - as a sample rate of 1min is set up.
I once did solve such problems via TIMER…my question if there is any more simple way to block the rule than via createtimer ?

Many Thanks Norbert

You could use a proxy item that is initialised to be false on system start.
Once your rule triggers determines that you have a flooding situation, it can check your proxy item and only send an email if the state is false; after sending the email it would change the state to true;
finally one the value sinks to safe levels (to avoid oscillation this value needs to be lower than the level that makes the rule send an email; you may need to play with the gap of those thresholds), your rule can set the state of the proxy item to false again and you are right where you started with only one email sent.

Maybe that would work better than pausing rules.

You may want to read these threads:


The two design patterns pointed to be lipp are applicable indeed. But 8 actually approach this from a different angle using

I create a Notified switch item that gets set to ON when the alert gets sent and OFF when the sense goes back to safe levels or at midnight. I check this flash before sending the alert.

Rich, do i get this right…

You have a dummy switch that is set ON when the trigger comes first time…and if it changed from OFF to ON it will send a message…afterwards its all the time ON until midnight when you reset the game to OFF and again you are ready for the next alarm…

How can you cover UNDEFINED/NULL state so from NULL to ON…in case it never was touched after reboot?

Not quite. Seeing the notification Switch isn’t what causes the alert to be sent. The Notification Switch is just a flag that gets checked before sending the alert.

I use restoreOnStartup so my items are almost never NULL. But in this case if I just check to see if the switch is ON, then the case where it is OFF or NULL is already covered.

if(alerting_condition) {
    if(Frontdoor_Notified.state != ON) {
        // Send alert
        Frontdoor_Notifief.sendCommand(ON)
    }
}
else {
    Frontdoor_Notified.sendCommand(OFF)
}

Obviously you need to replace the alerting_condition with what makes sense for your situation and use the Associated
Item DP to get the appropriate Notification Switch.