OH2 , Rule action on received MQTT message

OpenHabianPI 2.1

im trying to get a rule to fire when receiving a specific keyword from MQTT , it works for ON/OFF but not for “other words”

I have a rule working as below - two rules one for ON and one for OFF - both work perfectly

rule "Switch Change ON"
when
Item TestZone1 received command ON
then
pushover("TestZone1 ON ")

BUT this one doesn’t work !!! , i have tried received update and Received Command … both don’t work

rule "Sensor Is Online"
when
Item TestZone1 received update HELLO
then
pushover(“Sensor Came Online”)
end

Any ideas ?

Move your word check out of the when statement (I would suggest using a case check), so it would look more like:

rule "Zone Status"
when
  item TestZone1 received command
then
  switch TestZone1.state {
    case "ON" : pushover("TestZone1 ON ")
    case "HELLO" : pushover(“Sensor Came Online”)
  }
end

Not working BUT i think my issue may lie with the ITEMS file ??

current item file has the “device” listed as a Contact

Contact testZone1 “Kitchen Door” { mqtt="<[broker:Greg-SmartHouse/garage/TestZone1:state:default]" }

if i read the docs it says that contact only supports OPEN/CLOSED

what do i use or add to get it to accept variables such as HELLO as well as OPEN / ClOSED ?

That would do it and explain why it only accepted on/off. Change it to a String type

String testZone1 “Kitchen Door” { mqtt="<[broker:Greg-SmartHouse/garage/TestZone1:state:default]" }

Magic ! it works , Thanks :slight_smile: