Månedsarkiv: december 2017

triggeringItem is here !!!

Today I woke up to a new update of the openHAB system.

reading through the different replies, I found this post:

Reading a little more into it i found out that finally, maybe one of the most requested things to the rules engine is finally here!! And has been for quite a while.

triggeringItem

A very useful thing when creating rules within openhab, let me show you an example:

rule "thisisarule"
when
 Item item1 changed or
 Item item2 changed
then
 // to find out which of the two items changed you simply just use triggeringItem
if(triggeringItem == item1) {
 // code to execute with item1
}
// etc etc you get the idea?
end

within the triggeringItem there are following useful things you can pull out of it:

  • type (switch/contactitem)
  • state (on/off,open/closed)
  • label (the label you give the item in your .items file)
  • category (not sure about this one, mine just write out null)
  • groups (shows which groups/group the item is in)

This make writing rules in openhab so much easier, and saves you tons of time!

Enjoy!