When a subscribed topic is received from snips, the rules are not triggered. When a text thing is created linking to the item, the rules are triggered. Is this normal?

  • Platform information:
    • Hardware: CPUArchitecture/RAM/storage
      Raspberry Pi 3 +

    • OS: what OS is used and which version
      PRETTY_NAME=“Raspbian GNU/Linux 9 (stretch)”
      NAME=“Raspbian GNU/Linux”
      VERSION_ID=“9”
      VERSION=“9 (stretch)”
      ID=raspbian
      ID_LIKE=debian

    • Java Runtime Environment: which java platform is used and what version
      openjdk version “1.8.0_202”
      OpenJDK Runtime Environment (Zulu8.36.0.152-CA-linux_aarch32hf) (build 1.8.0_202-b152)
      OpenJDK Client VM (Zulu8.36.0.152-CA-linux_aarch32hf) (build 25.202-b152, mixed mode, Evaluation)

    • openHAB version:
      Repository Version


openhab-distro : 2.4.0
smarthome : 0.10.0.oh240
openhab-core : 2.4.0
openhab1-addons : 1.13.0
openhab2-addons : 2.4.0
karaf : 4.2.1

  • Issue of the topic: please be detailed explaining your issue

When a subscribed topic is received from snips, the rules are not triggered. When a text thing is created linking to the item, the rules are triggered.

  • Items configuration related to the issue
String snipsIntent "snipsIntent" { mqtt="<[127.0.0.1:1883:hermes/intent/steynaj:garageDoor:state:default]" }
Switch garageDoor "garageDoor" { mqtt=">[127.0.0.1:1883:home/garage/:command:OFF:default]" ,expire="1s,command=OFF",autoupdate="true" }
* Rules code related to the issue
rule "Snips"
when
     Item snipsIntent received update
then
    //logInfo("Snips Intent", Snips_Intent.toString)
    var String snipsInput    = transform("JSONPATH", "$.['input']", snipsIntent.state.toString)
    logInfo("snips.rule", "input: " + snipsInput) 
    var String Value = ("open garage door")
if 
   (Value == snipsInput) {
   logInfo("snips.rule", "correct: " + snipsInput) 
   garageDoor.postUpdate("ON")
}
else {
   logInfo("snips.rule", "wrong: " + snipsInput) 
}
end
  • If logs where generated please post these here using code fences:
    No logs as rules are not triggered except when using a text thing linked to the item:
2019-04-14 19:00:06.664 [vent.ItemStateChangedEvent] - snipsIntent changed from close garage door to open garage door

==> /var/log/openhab2/openhab.log <==

2019-04-14 19:00:06.724 [INFO ] [se.smarthome.model.script.snips.rule] - input: open garage door

2019-04-14 19:00:06.735 [INFO ] [se.smarthome.model.script.snips.rule] - correct: open garage door

==> /var/log/openhab2/events.log <==

2019-04-14 19:00:06.749 [vent.ItemStateChangedEvent] - garageDoor changed from OFF to ON

2019-04-14 19:00:07.944 [ome.event.ItemCommandEvent] - Item 'garageDoor' received command OFF

2019-04-14 19:00:07.968 [vent.ItemStateChangedEvent] - garageDoor changed from ON to OFF

2019-04-14 19:00:07.980 [ome.event.ItemCommandEvent] - Item 'garageDoor' received command OFF

Any assistance or comments will be very welcome.

Why are you using the expire option for this switch? This means the whenever the switch goes to ON it will go to OFF again after 1s, just like the log shows:

19:00:06.749 ... - garageDoor changed from OFF to ON
19:00:07.944 ... - Item 'garageDoor' received command OFF

Ron
That is correct. This will operate a garage door like when using a one button remote. One press and it opens and when opened one press will close it.

Andries

I don’t understand the problem. snipsIntent receives a message. It changes state from close to open.

Now there is a problem with the fact that you are naming a variable the same name as the Item which might cause some problems.

And as can be seen from the logs, the message is not JSON formatted so that could be causing problems too.

And yet, the logs are showing that the transform worked given the “correct:” log statement in openhab.log.

So what exactly is the problem?

Thank you for replying.
What I found was without a text thing created the rule wasn’t triggered and no logs were generated. Could that be a problem with my code ?

Andries

It’s still not clear what the problem is not is it clear whether you are using proper OH names. Things and Items have a very specific meaning in OH. If you literally mean a Generic MQTT Thing with a text Channel, than of course, you need that to trigger a Rule. That’s what makes OH subscribe for the messages in the first place.

Rich
Thanks for the reply.

That was what I did and that was what I wanted to know.
Thank you for your time.

Andries