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.
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.)
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.
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