[SOLVED] Zwave rules do not trigger

I am using OH1 and am having trouble getting my rules to trigger on the changes of states for different zwave sensor readings. I get the sensor readings but no rules are triggered, I know this because my log comments in each rule are not outputted.

Openhab Log:
2015-12-01 20:36:33.360 [INFO ] [runtime.busevents ] - Motion state updated to CLOSED
2015-12-01 20:36:34.760 [INFO ] [runtime.busevents ] - Temperature state updated to 25.4
2015-12-01 20:36:42.278 [INFO ] [runtime.busevents ] - Luminance state updated to 0
2015-12-01 20:36:44.897 [INFO ] [runtime.busevents ] - Humidity state updated to 50
2015-12-01 20:36:46.336 [INFO ] [runtime.busevents ] - Battery state updated to 100
2015-12-01 20:36:57.338 [INFO ] [runtime.busevents ] - Motion state updated to OPEN
2015-12-01 20:37:04.779 [INFO ] [runtime.busevents ] - Temperature state updated to 25.4

Items:
Number Temperature “Temperature [%.1f °F]” (multi,multiGraph) {zwave=“2:command=SENSOR_MULTILEVEL,sensor_type=1,refresh_interval=30”}
Number Humidity “Humidity [%.0f %%]” (multi,multiGraph) {zwave=“2:command=SENSOR_MULTILEVEL,sensor_type=5,refresh_interval=60”}
Number Luminance “Luminance [%.0f Lux]” (multi) {zwave=“2:command=SENSOR_MULTILEVEL,sensor_type=3,refresh_interval=60”}
Contact Motion “Motion [MAP(motion.map):%s]” (multi,motion) {zwave=“2:command=SENSOR_BINARY,respond_to_basic=true”}
Number Battery “Battery [%d %%]” (multi,battery) {zwave=“2:command=BATTERY,refresh_interval=120”}

Rules:
**************************************************************************************************
* Motion detected so gradually fade on lights in baby bedroom
**************************************************************************************************
rule “Motion detected in the evening”
when
Item Motion received update OPEN
then

logInfo("Aeotect6in1", "******* Motion detected *****")
if(Twilight.state == ON){

// TODO - Write/Paste command to gradually turn on lights under cot and bloom
  logInfo("Aeotect6in1", "******* Its evening  *****")
}
end


//************************************************************************************************
//* Act on the chnage of temperature - Turn off or on the wemo heater
//************************************************************************************************
rule "temperature in"
when

Item Temperature received update
then
temperatureIn = temperature.state

logInfo(“Temperature”, “******* Temperature change ")
if (temperatureIn < 21)
{
// Turn on wemo portable heater
logInfo(“Heater”, "
** Turn ON portable heater ")
SendCommand(PortableHeater,ON);
}
else
{
// Turn off wemo portable heater
logInfo(“Heater”, "
** Turn OFF portable heater *****”)
SendCommand(PortableHeater,OFF);
}

end

What you pasted in above is the events.log, not the openhab.log. There are two log files, one that just logs the events on the event bus (events.log which you pasted above) and openhab.log which has everything else, including your logInfos. Check there to see if your rules are being executed. I think you will find that they are.

1 Like

Will do, many thanks

Hi, Could anyone help

I am not getting any sign of my rules being triggered even simple rules like the temperature changing

When I updated my rule to the below I dont even get the log message I added.

Item:
Number Temperature “Temperature [%.1f °F]” (multi,multiGraph) {zwave=“2:command=SENSOR_MULTILEVEL,sensor_type=1,refresh_interval=30”}

Rule:
rule “temperature in”
when
Item Temperature changed
then
temperatureIn = temperature.state

logInfo(“Temperature”, “******* Temperature change ")
if (temperatureIn < 21)
{
// Turn on wemo portable heater
logInfo(“Heater”, "
** Turn ON portable heater ")
SendCommand(PortableHeater,ON);
}
else
{
// Turn off wemo portable heater
logInfo(“Heater”, "
** Turn OFF portable heater *****”)
SendCommand(PortableHeater,OFF);
}
End

I don’t see any messages in openhab.log though but i see them on the main openhab console:

Openhab main console
2015-12-05 17:53:00.774 [INFO ] [runtime.busevents ] - Temperature state updated to 25.3
2015-12-05 17:53:01.149 [INFO ] [runtime.busevents ] - PortableHeater state updated to ON
2015-12-05 17:53:30.773 [INFO ] [runtime.busevents ] - Temperature state updated to 25.3
2015-12-05 17:53:38.289 [INFO ] [runtime.busevents ] - Luminance state updated to 0
2015-12-05 17:53:40.908 [INFO ] [runtime.busevents ] - Humidity state updated to 47
2015-12-05 17:53:46.688 [INFO ] [runtime.busevents ] - Battery state updated to 100
2015-12-05 17:54:00.768 [INFO ] [runtime.busevents ] - Temperature state updated to 25.3

What you quote here looks like the events.log, not openhab.log. A default openhab.log looks more like this (the last few lines of my current log.

 2015-12-05 10:07:24.365 [INFO ] [.openhab.model.script.Presence] - No one is home after five minutes
 2015-12-05 10:07:24.398 [INFO ] [org.openhab.model.script.Nest ] - Setting Nest to AWAY
 2015-12-05 10:07:25.502 [WARN ] [nhab.model.script.Notification] - You left N_D_GarageDoor1 open!
 2015-12-05 10:07:25.505 [WARN ] [nhab.model.script.Notification] - You left N_D_GarageDoor2 open!
 2015-12-05 10:13:28.542 [INFO ] [.openhab.model.script.Presence] - Someone is home
 2015-12-05 10:13:28.567 [INFO ] [.openhab.model.script.Presence] - Someone is home
 2015-12-05 10:13:28.595 [INFO ] [org.openhab.model.script.Nest ] - Setting Nest to HOME
 2015-12-05 10:30:00.106 [WARN ] [nhab.model.script.Notification] - N_D_GarageDoor1 is still open after an hour!
 2015-12-05 10:45:00.123 [WARN ] [nhab.model.script.Notification] - N_D_GarageDoor1 is still open after an hour!

Notice how there are statements from more than just runtime.busevents.

In my events.log i just see the following:

2015-12-05 18:08:38 - Luminance state updated to 0
2015-12-05 18:08:41 - Humidity state updated to 46
2015-12-05 18:08:49 - PortableHeater state updated to ON
2015-12-05 18:09:00 - Temperature state updated to 25.3
2015-12-05 18:09:30 - Temperature state updated to 25.3
2015-12-05 18:09:38 - Luminance state updated to 0
2015-12-05 18:09:41 - Humidity state updated to 46
2015-12-05 18:09:46 - Battery state updated to 100
2015-12-05 18:09:55 - PortableHeater state updated to ON
2015-12-05 18:10:00 - Temperature state updated to 25.3

Is my rule incorrect?

rule "temperature in"
when
Item Temperature changed
then
temperatureIn = temperature.state

logInfo("Temperature", "******* Temperature change *****")
if (temperatureIn < 21)
{
// Turn on wemo portable heater
logInfo("Heater", "******* Turn ON portable heater *****")
SendCommand(PortableHeater,ON);
} 
else
{
// Turn off wemo portable heater
logInfo("Heater", "******* Turn OFF portable heater *****")
SendCommand(PortableHeater,OFF);
}
End

Weird. Have you made any changes to logback.xml? Try using the debug logback.xml so we can rule out that the problem isn;t just that your logInfos are being suppressed.

Maybe move your logInfo Temperature change to be the first line of the rule to make sure that it isn’t silently failing when you get the state.

Also, you probably want Temperature.state instead of temperature.state. Item names are case sensitive.

I assume temperatureIn is defined somewhere with a val (e.g.val Number temperatureIn).

I didnt even know logback.xml even existed until you mentioned it.

Ill try making your suggested changes

Many Thanks

@rlkoshak I have found out that I did not set the associations so i have done that but no luck.

My rule is as follows:

//************************************************************************************************
//* Act on the chnage of temperature - Turn off or on the wemo heater
//************************************************************************************************

rule “temperature in”
when

  Item Temperature changed

then
logInfo(“Temperature”, “******* Temperature change *****”)

temperatureIn = Temperature.state

if (temperatureIn < 21)
{

// Turn on wemo portable heater
logInfo(“Heater”, “******* Turn ON portable heater ")
SendCommand(PortableHeater,ON);
}
else
{
// Turn off wemo portable heater
logInfo(“Heater”, "
** Turn OFF portable heater *****”)
SendCommand(PortableHeater,OFF);
}

 end

logInfo(“Temperature”, “******* Temperature change *****”) - This doesn’t even get displayed

Any ideas?

Assuming this is your entier rules file (i.e. you are not referring to any vars or vals globally defined I see the following:

  • Its a good idea to log the state of everything you use when trying to debug a rule

  • As I previous mentioned, you never define temperatureIn. Therefore temperatureIn = Temperature.state should generate an error. Are you using Designer? It will tell you about these sorts of syntax errors as you type.

  • We may need to cast Temperature’s state to a DecimalType

  • It is a style thing but I prefer to call the sendCommand on the Item rather than calling sendCommand(Item, State). Designer is a lot better at catching errors when I code it that way.

  • The command is “sendCommand”, not “SendCommand”. The programming language is case sensitive

  • Do not use “;”

  • You can’t have anything after the “end” part of a rule. “end” means just that, the end of code for the rule.

    //************************************************************************************************
    //* Act on the chnage of temperature - Turn off or on the wemo heater
    //************************************************************************************************
    rule “temperature in”
    when
    Item Temperature changed
    then

        logInfo("Temperature", "**** Temperature changed to " + Temperature.state + "****")
    
        val Number temperatureIn = (Temperature.state as DecimalType)
     
         if(temperatureIn < 21) {
             logInfo("Temperature", "**** Turning ON portable heater ****")
             PortableHeater.sendCommand(ON) 
         }
         else {
             logInfo("Temperature", "**** Turning OFF portable heater ****")
         }
    
         logInfo("Temperature", "**** Temperature Change Rule Completed Execution ****")
     end
    

*GRRRR Why is the formatting feature all of a suddenly broken! Sorry for the mixed indentation.

Hi,

@rlkoshak Thank you for your comment. I had temperature declared as global variable as type Number.

I see the benefit of your suggested changes so I will implement them this evening and see how I get on.

Its frustrating because I have been working with mqtt and everything works perfectly and not I am onto zwave similar rules are not being triggered.

Anyway i’m sure this is a good learning curve.

Many Thanks again.

@rlkoshak Im sorry but I am not getting any zwave related messages in the openhab.log even though in the main console I am getting messages.

In the openhab.log I get the following (please ignore the xbmc error messages I have not got my xbmc set to the correct ip address)

Openhab.log ------------- below ---------------

2015-12-08 19:57:30.626 [INFO ] [.o.core.internal.CoreActivator] - openHAB runtime has been started (v1.7.1).
2015-12-08 19:57:35.691 [INFO ] [o.o.i.s.i.DiscoveryServiceImpl] - mDNS service has been started
2015-12-08 19:57:40.332 [INFO ] [o.o.i.s.i.DiscoveryServiceImpl] - Service Discovery initialization completed.
2015-12-08 19:57:43.877 [INFO ] [c.internal.ModelRepositoryImpl] - Loading model 'default.items'
2015-12-08 19:57:45.755 [INFO ] [penhab.io.rest.RESTApplication] - Started REST API at /rest
2015-12-08 19:57:51.345 [INFO ] [.o.u.w.i.servlet.WebAppServlet] - Started Classic UI at /openhab.app
2015-12-08 19:57:54.870 [INFO ] [c.internal.ModelRepositoryImpl] - Loading model 'default.rules'
2015-12-08 19:57:58.493 [INFO ] [.o.io.habmin.HABminApplication] - Started HABmin REST API at /services/habmin
2015-12-08 19:58:03.873 [INFO ] [.z.internal.ZWaveActiveBinding] - Update config, port = /dev/ttyACM0
2015-12-08 19:58:03.882 [INFO ] [.service.AbstractActiveService] - ZWave Refresh Service has been started
2015-12-08 19:58:03.971 [INFO ] [b.z.i.protocol.ZWaveController] - Starting Z-Wave controller
2015-12-08 19:58:03.973 [INFO ] [b.z.i.protocol.ZWaveController] - Z-Wave timeout is set to 5000ms. Soft reset is false.
2015-12-08 19:58:03.974 [INFO ] [b.z.i.protocol.ZWaveController] - Connecting to serial port /dev/ttyACM0
2015-12-08 19:58:04.124 [INFO ] [.service.AbstractActiveService] - XBMC Refresh Service has been started
2015-12-08 19:58:04.134 [INFO ] [b.z.i.protocol.ZWaveController] - Serial port is initialized
2015-12-08 19:58:06.305 [ERROR] [b.x.internal.XbmcActiveBinding] - Connection failed for '#htpc' on 192.168.1.5
2015-12-08 19:58:07.023 [ERROR] [enhab.binding.xbmc.rpc.RpcCall] - Error handling POST response from XBMC
java.net.ConnectException: Connection refused: /192.168.1.5:80 to http://192.168.1.5:80/jsonrpc
at com.ning.http.client.providers.netty.NettyConnectListener.operationComplete(NettyConnectListener.java:103) ~[async-ht$
at org.jboss.netty.channel.DefaultChannelFuture.notifyListener(DefaultChannelFuture.java:427) [netty-3.9.0.Final.jar:na]
at org.jboss.netty.channel.DefaultChannelFuture.notifyListeners(DefaultChannelFuture.java:418) [netty-3.9.0.Final.jar:na]
at org.jboss.netty.channel.DefaultChannelFuture.setFailure(DefaultChannelFuture.java:380) [netty-3.9.0.Final.jar:na]
at org.jboss.netty.channel.socket.nio.NioClientBoss.processSelectedKeys(NioClientBoss.java:109) [netty-3.9.0.Final.jar:n$
at org.jboss.netty.channel.socket.nio.NioClientBoss.process(NioClientBoss.java:79) [netty-3.9.0.Final.jar:na]
at org.jboss.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:318) [netty-3.9.0.Final.jar:na]
at org.jboss.netty.channel.socket.nio.NioClientBoss.run(NioClientBoss.java:42) [netty-3.9.0.Final.jar:na]
at org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108) [netty-3.9.0.Final.jar:na]
at org.jboss.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42) [netty-3.9.0.Final.jar:na]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0]
at java.lang.Thread.run(Thread.java:744) [na:1.8.0]
Caused by: java.net.ConnectException: Connection refused: /192.168.1.5:80
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) ~[na:1.8.0]
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:712) ~[na:1.8.0]
at org.jboss.netty.channel.socket.nio.NioClientBoss.connect(NioClientBoss.java:150) [netty-3.9.0.Final.jar:na]
at org.jboss.netty.channel.socket.nio.NioClientBoss.processSelectedKeys(NioClientBoss.java:105) [netty-3.9.0.Final.jar:n$
... 8 common frames omitted
2015-12-08 19:58:07.055 [WARN ] [b.x.internal.XbmcActiveBinding] - Received update (0) for item htpc_volume but the connection t$
2015-12-08 19:58:08.062 [INFO ] [rialApiGetInitDataMessageClass] - NODE 1: Node found
2015-12-08 19:58:08.064 [INFO ] [rialApiGetInitDataMessageClass] - NODE 2: Node found
2015-12-08 19:58:08.066 [INFO ] [rialApiGetInitDataMessageClass] - ZWave Controller using Controller API
2015-12-08 19:58:08.068 [INFO ] [rialApiGetInitDataMessageClass] - ZWave Controller is Primary Controller
2015-12-08 19:58:08.070 [INFO ] [rialApiGetInitDataMessageClass] - ------------Number of Nodes Found Registered to ZWave Control$
2015-12-08 19:58:08.071 [INFO ] [rialApiGetInitDataMessageClass] - # Nodes = 2
2015-12-08 19:58:08.073 [INFO ] [rialApiGetInitDataMessageClass] - -------------------------------------------------------------$
2015-12-08 19:58:08.910 [INFO ] [.h.internal.hardware.HueBridge] - Hue bridge not paired.
2015-12-08 19:58:08.916 [INFO ] [.h.internal.hardware.HueBridge] - Please press the connect button on the Hue bridge. Waiting fo$
2015-12-08 19:58:09.953 [INFO ] [.h.internal.hardware.HueBridge] - Please press the connect button on the Hue bridge. Waiting fo$
2015-12-08 19:58:26.387 [INFO ] [.h.internal.hardware.HueBridge] - Hue bridge successfully paired!

----- Main console window -------------
2 015-12-08 19:58:26.387 [INFO ] [.h.internal.hardware.HueBridge] - Hue bridge successfully paired!
2015-12-08 19:58:26.890 [INFO ] [runtime.busevents ] - Luminance state updated to 0
2015-12-08 19:58:29.527 [INFO ] [runtime.busevents ] - Humidity state updated to 52
2015-12-08 19:58:35.306 [INFO ] [runtime.busevents ] - Battery state updated to 100
2015-12-08 19:58:49.390 [INFO ] [runtime.busevents ] - Temperature state updated to 24.3
2015-12-08 19:59:19.387 [INFO ] [runtime.busevents ] - Temperature state updated to 24.3
2015-12-08 19:59:26.905 [INFO ] [runtime.busevents ] - Luminance state updated to 0
2015-12-08 19:59:29.545 [INFO ] [runtime.busevents ] - Humidity state updated to 51
2015-12-08 19:59:54.405 [INFO ] [runtime.busevents ] - Temperature state updated to 24.3
2015-12-08 20:00:24.407 [INFO ] [runtime.busevents ] - Temperature state updated to 24.3

I am so confused…

I have updated my rule to be as you described
//************************************************************************************************
//* Act on the chnage of temperature - Turn off or on the wemo heater
//************************************************************************************************
rule “temperature in”
when
Item Temperature changed
then
logInfo(“Temperature”, "**** Temperature changed to " + Temperature.state + “****”)

   val Number temperatureIn = (Temperature.state as DecimalType)

if(temperatureIn < 21) {
logInfo(“Temperature”, “**** Turning ON portable heater ")
PortableHeater.sendCommand(ON)
}
else {
logInfo(“Temperature”, "
Turning OFF portable heater ****”)
}

logInfo(“Temperature”, “**** Temperature Change Rule Completed Execution ****”)
end

Item file:
// Aeotec Multi Sensor 6 ******************************************************/
Number Temperature “Temperature [%.1f °F]” (multi,multiGraph) {zwave="2:command=SENSOR_MULTILEVEL,sensor_type=1,refresh_i$
Number Humidity “Humidity [%.0f %%]” (multi,multiGraph) {zwave="2:command=SENSOR_MULTILEVEL,sensor_type=5,refresh_in$
Number Luminance “Luminance [%.0f Lux]” (multi) {zwave="2:command=SENSOR_MULTILEVEL,sensor_type=3,refresh_in$
Contact Motion “Motion [MAP(motion.map):%s]” (multi,motion) {zwave="2:command=SENSOR_BINARY,respond_to_basic$
Number Battery “Battery [%d %%]” (multi,battery) {zwave=“2:command=BATTERY,refresh_interval=120”}

Could it be the name of my rules and items file being incorrect or not configured correctly?
default.items
default.rules

Well, from the logs you have posted so far, the Temperature has not actually changed values so the rule will not trigger.

Watch it and you should see the rule trigger when the temp changes from 24.3 to any other value.

If you want to trigger the rule for any update whether or not the temperature has changed you need to use as your trigger:

"Item Temperature received update"

@rlkoshak ok so I have done a test using a simple mqtt publish to topic home/temperature and my rule did not trigger. So I think it is an issue with any rules not being triggered.

Is default.rules the correct name.

I can see in the log that this file is being loaded.

pi@raspberrypi ~ $ sudo /opt/openhab/start.sh
Launching the openHAB runtime...
osgi> 2015-12-08 20:24:28.189 [INFO ] [.o.core.internal.CoreActivator] - openHAB runtime has been started (v1.7.1).
2015-12-08 20:24:32.913 [INFO ] [o.o.i.s.i.DiscoveryServiceImpl] - mDNS service has been started
2015-12-08 20:24:37.646 [INFO ] [o.o.i.s.i.DiscoveryServiceImpl] - Service Discovery initialization completed.
2015-12-08 20:24:41.108 [INFO ] [c.internal.ModelRepositoryImpl] - Loading model 'default.items'
2015-12-08 20:24:42.419 [INFO ] [penhab.io.rest.RESTApplication] - Started REST API at /rest
2015-12-08 20:24:48.136 [INFO ] [.o.u.w.i.servlet.WebAppServlet] - Started Classic UI at /openhab.app
2015-12-08 20:24:52.079 [INFO ] [c.internal.ModelRepositoryImpl] - Loading model 'default.rules'
2015-12-08 20:24:56.377 [INFO ] [.o.io.habmin.HABminApplication] - Started HABmin REST API at /services/habmin

item:
/* 3. Temperature sensor*/
Number tempsensor {mqtt="<[home:home/temperature:state:default]"}

rule:
//************************************************************************************************
//* test
//************************************************************************************************
rule “start processing sensor”
when
Item tempsensor received update
then
logInfo(“Aeotect6in1”, “******* test *****”)
end

Oh that was because I did not configure openhab.cfg correctly for mqtt broker

That is a valid name and it is loading it so that is find.

Are you sure that the MQTT Item received the update? You should see a statement in events.log (or the console) along the lines of

2015-12-08 20:00:24.407 [INFO ] [runtime.busevents ] - tempsensor state updated to XX

Where XX is the value you sent.

@rlkoshak MQTT not recognised because I did not configure openhab.cfg correctly for mqtt broker

The mqtt works now but now zwave, is there any settings in habmin that i need to do?