[SOLVED] Rules more items in when get state from triggered item

I have a rule with two items with received update.
How can I get the current state of the triggered item or the triggered item itself in the “then”?

For example:
rule “test”
when
Item LivingRoom_CO2_Netatmo received update or
Item Office_CO2_Netatmo received update
then
get the state of the triggered item (LivingRoom_CO2_Netatmo or Office_CO2_Netatmo)

You’d look at the .state of the triggeringItem

1 Like

Hi

Just to be clear…

Can the triggeringItem.state be used when the trigger is a Channel instead of an Item?

For example, a button event of a Velbus Glass Panel Thing?

rule "map cooler channel"

when
Channel "velbus:vmbgp2:c5053467:1C:thermostat#COOLER" triggered

then

if (triggeringItem.state == "pressed") {

AirCon.sendCommand(ON)
}


if (triggeringItem.state == "released") {

AirCon.sendCommand(OFF)
}

end

Nope. The triggeringItem variable will not even exist.

:sob:

Oh well, better to know now, before worrying about why the rule doesn’t work.

I’ll stick with my previous 2 rules.
:slight_smile:

when
Channel "velbus:vmbgp2:c5053467:1C:thermostat#COOLER" triggered pressed

And

when
Channel "velbus:vmbgp2:c5053467:1C:thermostat#COOLER" triggered released

Perhaps you should look into receivedEvent

Thanks :slight_smile:

I’ll look into that tomorrow and see what I can come up with.
It certainly looks like it’s perfect.


This is what I love about openHAB2, there is always something extra to be discovered :slight_smile:

Hi,

This is the rule I’m going to try.

As Rich advises, it’s better to reduce the repeats.

rule "map cooler channel" when 
Channel "velbus:vmbgp2:c5053467:1C:thermostat#COOLER" triggered
then
if (receivedEvent.Event.toString == "pressed") { AirCon.sendCommand(ON) }

if (receivedEvent.Event.toString == "released") { AirCon.sendCommand(OFF) }

end

(I’ll amend this rule here as required)