Setup Notification Rule

Hi guys,

I´ve setup an arduino which senses if my laundry dryer has finished his job. If so, it sends a message to my.openhab and therefore to my openhab android app. I´ve set up the arduino so that after 90 seconds it senses again and if the dryer is still finished I receive another message. This goes infinite.

Because I am too lazy to change the code of my arduino I would like to know if there is an easy way to create a rule which defines that I only get noticed once when the dryer has finished his job.

Any idea?

Yes, make a variable as a flag that tells you that you’ve already send a notification.

var Integer Notification_Sent = 0

rule "something wicked this way comes"
when
    Item WICKED_THING received update ON
then
   {
       if (Notification_Sent == 1)
             {
                logInfo("openhab","Something wicked already came here, aborting rule.")
                return false
              }
       Notification_Sent = 1
       // (do your notification here)
   }
end

rule "something wicked this way went"
when
    Item WICKED_THING received update OFF
then
   {
      Notification_Sent = 0
   }
end

(I’m using received updates, but you should be able to twist this to fit your particular messages.)

Hi TheKorn,

sorry for the delay, I finally found time to test this, wil give you an update soon!! I can already inform you, that until now I received messages by using “gw.sendSketchInfo”…we´ll see if your rule works the way I would like to have it.

Hi @TheKorn ,

it works very well, thank you very much!!

One more thing: Is it possible to add a switch icon from which I can turn notification on and off? Right out of openhab…

Sure, that’s not a hard thing to do either. You just define a switch but don’t tie it to a binding:

Switch SHUT_UP  "Shut up switch"

and…

rule "something wicked this way comes"
when
    Item WICKED_THING received update ON
then
   {
       if (Notification_Sent == 1 || SHUT_UP.state == ON)
             {
                logInfo("openhab","Something wicked already came here or I was told to shut up.  Aborting rule.")
                return false
              }
       Notification_Sent = 1
       // (do your notification here)
   }
end

awesome, thank you!!!

@TheKorn

unfortunately it does not work using a switch :frowning:

I´ve set up the following code:

rule "AlarmWgTuer"
when
    Item TuereWg received update OPEN
then
   {
		if (SWAlarmWgTuer == ON)
			{
				sendNotification("ALARM") 
			}	
   }
end  

And this in my home.items:

Switch SWAlarmWgTuer "test" <siren>(FF_Wg) {"OFF, ON"}

Now I don´t receive a message no matter if switch is turned ON or OFF.

edit: got it, had to add .state, I just missed that for some reason…

if (SWAlarmWgTuer.state == ON)

works fine now, thank you again :slight_smile:

(chuckle) Yeah without the .state at the end, you’re comparing a thing (the switch) against a thing’s state (on/off). That no workie! :smiley: