Zwave Feature Needed : polling a zwave device from a rule

I was wondering the same. I tried this last night and it just threw an error on me. Here’s what I was doing:

sendCommand(Dimmer_Kitchen, RefreshType.REFRESH)

What was the error? Was it an exception from ZWave, or an error in the rule?

13:13:36.362 [ERROR] [org.quartz.core.JobRunShell         ] - Job DEFAULT.2016-03-06T13:13:36.333-05:00: Proxy for org.eclipse.xtext.xbase.lib.Procedures$Procedure0: [ | {
  logInfo(<XStringLiteralImpl>,<XBinaryOperationImplCustom>)
  var command
  sendCommand(<XFeatureCallImplCustom>,<XFeatureCallImplCustom>)
  logInfo(<XStringLiteralImpl>,<XBinaryOperationImplCustom>)
} ] threw an unhandled Exception: 
java.lang.RuntimeException: The name 'REFRESH' cannot be resolved to an item or type.
	at org.eclipse.smarthome.model.script.interpreter.ScriptInterpreter.invokeFeature(ScriptInterpreter.java:110)[114:org.eclipse.smarthome.model.script:0.8.0.201603021108]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._doEvaluate(XbaseInterpreter.java:900)[128:org.eclipse.xtext.xbase:2.6.2.v201407030533]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._doEvaluate(XbaseInterpreter.java:863)[128:org.eclipse.xtext.xbase:2.6.2.v201407030533]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.doEvaluate(XbaseInterpreter.java:222)[128:org.eclipse.xtext.xbase:2.6.2.v201407030533]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.internalEvaluate(XbaseInterpreter.java:202)[128:org.eclipse.xtext.xbase:2.6.2.v201407030533]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._doEvaluate(XbaseInterpreter.java:825)[128:org.eclipse.xtext.xbase:2.6.2.v201407030533]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.doEvaluate(XbaseInterpreter.java:262)[128:org.eclipse.xtext.xbase:2.6.2.v201407030533]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.internalEvaluate(XbaseInterpreter.java:202)[128:org.eclipse.xtext.xbase:2.6.2.v201407030533]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._doEvaluate(XbaseInterpreter.java:445)[128:org.eclipse.xtext.xbase:2.6.2.v201407030533]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.doEvaluate(XbaseInterpreter.java:226)[128:org.eclipse.xtext.xbase:2.6.2.v201407030533]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.internalEvaluate(XbaseInterpreter.java:202)[128:org.eclipse.xtext.xbase:2.6.2.v201407030533]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.evaluate(XbaseInterpreter.java:188)[128:org.eclipse.xtext.xbase:2.6.2.v201407030533]
	at org.eclipse.xtext.xbase.interpreter.impl.ClosureInvocationHandler.doInvoke(ClosureInvocationHandler.java:46)[128:org.eclipse.xtext.xbase:2.6.2.v201407030533]
	at org.eclipse.xtext.xbase.interpreter.impl.AbstractClosureInvocationHandler.invoke(AbstractClosureInvocationHandler.java:28)[128:org.eclipse.xtext.xbase:2.6.2.v201407030533]
	at com.sun.proxy.$Proxy117.apply(Unknown Source)[:]
	at org.eclipse.smarthome.model.script.internal.actions.TimerExecutionJob.execute(TimerExecutionJob.java:38)[114:org.eclipse.smarthome.model.script:0.8.0.201603021108]
	at org.quartz.core.JobRunShell.run(JobRunShell.java:202)[94:org.eclipse.smarthome.core.scheduler:0.8.0.201603021108]
	at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)[94:org.eclipse.smarthome.core.scheduler:0.8.0.201603021108]
13:13:36.372 [ERROR] [org.quartz.core.ErrorLogger         ] - Job (DEFAULT.2016-03-06T13:13:36.333-05:00: Proxy for org.eclipse.xtext.xbase.lib.Procedures$Procedure0: [ | {
  logInfo(<XStringLiteralImpl>,<XBinaryOperationImplCustom>)
  var command
  sendCommand(<XFeatureCallImplCustom>,<XFeatureCallImplCustom>)
  logInfo(<XStringLiteralImpl>,<XBinaryOperationImplCustom>)
} ] threw an exception.
org.quartz.SchedulerException: Job threw an unhandled exception. [See nested exception: java.lang.RuntimeException: The name 'REFRESH' cannot be resolved to an item or type.]
	at org.quartz.core.JobRunShell.run(JobRunShell.java:213)[94:org.eclipse.smarthome.core.scheduler:0.8.0.201603021108]
	at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)[94:org.eclipse.smarthome.core.scheduler:0.8.0.201603021108]
Caused by: java.lang.RuntimeException: The name 'REFRESH' cannot be resolved to an item or type.
	at org.eclipse.smarthome.model.script.interpreter.ScriptInterpreter.invokeFeature(ScriptInterpreter.java:110)[114:org.eclipse.smarthome.model.script:0.8.0.201603021108]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._doEvaluate(XbaseInterpreter.java:900)[128:org.eclipse.xtext.xbase:2.6.2.v201407030533]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._doEvaluate(XbaseInterpreter.java:863)[128:org.eclipse.xtext.xbase:2.6.2.v201407030533]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.doEvaluate(XbaseInterpreter.java:222)[128:org.eclipse.xtext.xbase:2.6.2.v201407030533]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.internalEvaluate(XbaseInterpreter.java:202)[128:org.eclipse.xtext.xbase:2.6.2.v201407030533]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._doEvaluate(XbaseInterpreter.java:825)[128:org.eclipse.xtext.xbase:2.6.2.v201407030533]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.doEvaluate(XbaseInterpreter.java:262)[128:org.eclipse.xtext.xbase:2.6.2.v201407030533]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.internalEvaluate(XbaseInterpreter.java:202)[128:org.eclipse.xtext.xbase:2.6.2.v201407030533]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._doEvaluate(XbaseInterpreter.java:445)[128:org.eclipse.xtext.xbase:2.6.2.v201407030533]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.doEvaluate(XbaseInterpreter.java:226)[128:org.eclipse.xtext.xbase:2.6.2.v201407030533]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.internalEvaluate(XbaseInterpreter.java:202)[128:org.eclipse.xtext.xbase:2.6.2.v201407030533]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.evaluate(XbaseInterpreter.java:188)[128:org.eclipse.xtext.xbase:2.6.2.v201407030533]
	at org.eclipse.xtext.xbase.interpreter.impl.ClosureInvocationHandler.doInvoke(ClosureInvocationHandler.java:46)[128:org.eclipse.xtext.xbase:2.6.2.v201407030533]
	at org.eclipse.xtext.xbase.interpreter.impl.AbstractClosureInvocationHandler.invoke(AbstractClosureInvocationHandler.java:28)[128:org.eclipse.xtext.xbase:2.6.2.v201407030533]
	at com.sun.proxy.$Proxy117.apply(Unknown Source)[:]
	at org.eclipse.smarthome.model.script.internal.actions.TimerExecutionJob.execute(TimerExecutionJob.java:38)[114:org.eclipse.smarthome.model.script:0.8.0.201603021108]
	at org.quartz.core.JobRunShell.run(JobRunShell.java:202)[94:org.eclipse.smarthome.core.scheduler:0.8.0.201603021108]
	... 1 more

Well I didn’t get an exception, but I didn’t get a result, either.

Threw it in the middle of another simple rule I had handy. Both devices (BEDROOM_LAMP and BEDROOM_TV) are simple zwave smart switches.

rule "Bedroom lamp on scene"
when
	// only process on a switch on state
	Item BEDROOM_SCENE_LAMP_ON received update ON
then
	{
		logInfo("openhab","Bedroom lamp on scene activated.")		
		sendCommand("BEDROOM_LAMP","ON")

		logInfo("openhab","Sending REFRESH to bedroom tv")
		sendCommand("BEDROOM_TV","REFRESH")
		logInfo("openhab","Sending RefreshType.REFRESH to bedroom tv")
		sendCommand("BEDROOM_TV","RefreshType.REFRESH")


		BedroomLampOnTimer = createTimer(now.plusSeconds(1)) 
			[|
				logInfo("openhab","(Turning off bedroom lamp on switch)")
				sendCommand("BEDROOM_SCENE_LAMP_ON","OFF")
			]
	}	
end

Doesn’t generate an unhandled exception, just says that I’m whippin’ nulls…

2016-03-06 15:36:25.764 [INFO ] [g.openhab.model.script.openhab] - Bedroom lamp on scene activated.
2016-03-06 15:36:25.854 [INFO ] [g.openhab.model.script.openhab] - Sending REFRESH to bedroom tv
2016-03-06 15:36:25.896 [WARN ] [.c.i.events.EventPublisherImpl] - given command is NULL, couldn't send command to 'BEDROOM_TV'
2016-03-06 15:36:25.933 [INFO ] [g.openhab.model.script.openhab] - Sending RefreshType.REFRESH to bedroom tv
2016-03-06 15:36:25.975 [WARN ] [.c.i.events.EventPublisherImpl] - given command is NULL, couldn't send command to 'BEDROOM_TV'
2016-03-06 15:36:27.094 [INFO ] [g.openhab.model.script.openhab] - (Turning off bedroom lamp on switch)

From what I can tell, it shouldn’t be a string.

How about something like

var refresh as RefreshType
sendCommand("BEDROOM_TV", refresh.REFRESH)

It’s a complete guess, but the type needs to be RefreshType I think, so enforcing the type might help.

OH Designer really doesn’t like that. var refresh as RefreshType says it can’t derive what type refresh is. (“whazzat? dunno.”) Might be a case of not including the right libraries. Right now I’m including:

import org.openhab.core.library.types.*
import org.openhab.core.persistence.*
import org.openhab.model.script.actions.*

Yeah, if I wasn’t such a dingus I would have noticed you specifically called out OH2. I’m running OH1. Disregard me! :wink:

Just to note, I was having a problem with dimmers that didn’t have association groups messing up sliders. This fixes the problem, I have to items right now with this problem, assigned a rule with refresh to one of them, which fixes it, other one still showing symptoms. So without doubt this has fixed the problem here:

Good work Chris!

@chris here’s what I get now:

21:47:13.726 [WARN ] [ding.zwave.handler.ZWaveThingHandler] - NODE 2: Command received with no implementation (RefreshType).

To get it to this point I had to import the RefreshType at the top of my rule file.

Excellent - it seems you were successful… Unfortunately, I wasn’t…

I’ll make an update to the binding tonight to try and resolve this issue, but it looks like you’re close…

Hmmm. Ok I jumped the gun, my bad!
So I’m getting a crap load of errors on this, which I presume actually interrupts whatever it is that’s causing my problems, making me think it’s fixed! YEY.

I’ll update to the newest when it’s available and test again.

Any better luck with the most recent binding?

I did try it this morning after seeing the changes you’d committed. It’s not throwing an error, but doesn’t appear to be working either. It does show from the debug log that it’s polling, though I should note that the debug message seems to be incorrect: NODE 2: Polling intialised at 1800 seconds.…it does in fact poll after 50 seconds as it specifies in the code.

However, despite that, it doesn’t seem to actually poll, that is, the state doesn’t get updated.

Perhaps it’s my dimmers that are the issue though? The problem I have with them is that when I turn them on/off, they merely report the “instantaneous” dim level values, i.e.: changed from 8 to 14, (when in reality they’re going from 0 to 100 or 100 to 0). I know in v1.8 of the binding I had a low poll (i.e. 5 seconds) and that seemed to help, but I’d like to avoid polling every 5 seconds when all I really need is a quick updated.

I also noticed that the Switch item I associated with the channel never gets updated (it always shows OFF), likely associated with the polling issue, as this also used to work in v1.8

The debug message might need to be changed, but it is correct. When you send a refresh command, polling is actually restarted, but it also does an immediate poll (well - there’s a start delay). This delay should be in milliseconds, so the poll should be at 50ms - not 50s!

I’ll take a look at this as there seem to be a few reports about this…

The plan is to implement a delay where the device is polled after a command - the new polling scheme is the start of this…

I obviously don’t know the code very well, but I think there may be a bug based on what I’m seeing (in my logs and in the code). A couple of logs messages indicate that it is 50s before it polls, and I also noticed this line in the code in the startPolling method:

pollingJob = scheduler.scheduleAtFixedRate(pollingRunnable, initialPeriod, pollingPeriod, TimeUnit.SECONDS);

Here’s my logs to back it up:

2016-03-10 16:58:52.043 [DEBUG] [ding.zwave.handler.ZWaveThingHandler] - NODE 2: Command received zwave:ge_zw3003_00_000:1533f07f1de:node2:switch_dimmer --> REFRESH 2016-03-10 16:58:52.046 [DEBUG] [ding.zwave.handler.ZWaveThingHandler] - NODE 2: Polling intialised at 1800 seconds. 2016-03-10 16:59:42.045 [DEBUG] [ding.zwave.handler.ZWaveThingHandler] - NODE 2: Polling...

If you look at the timestamps, it’s 50 from the REFRESH request to the actual polling. (16:58:52 → 16:59:42).

Yes - that’s what I meant. The delay should be 50ms, but there’s a bug in the binding that makes it 50 seconds. I’ve fixed that already so it will be in tomorrows binding…

A great. I mis-understood your comment. I thought you were asserting that it was 50ms. I think once the polling actually works (as in updates the state properly) this will be golden.

I think I’ve just spotted the problem with polling as well, so I’ll put a fix in place for this as well - thanks :slight_smile:.

Hey All,

So I am basically doing this:

// zwave device status check
rule "CheckZwaveDevices"
when
    Item zw2Ping received update ON or
    Item zw3Ping received update ON or
    Item zw4Ping received update ON or
    Item zw5Ping received update ON or
    Item zw6Ping received update ON or
    Item zw7Ping received update ON or
    Item zw8Ping received update ON
then
        logInfo("Security", "SECURITY: zWave Device problem!")
        sendMail("alerts@cidcomm.com", "zWave Device Problem!", "zWave Device Problem!")
end



/*Zwave device check and alerting*/
Switch zw2Ping "Node2 Status: [MAP(nodeping.map):%s]" <sensor> (persist) { zwave="2:command=INFO, item=DEAD, refresh_interval=300" }
Switch zw3Ping "Node3 Status: [MAP(nodeping.map):%s]" <sensor> (persist) { zwave="3:command=INFO, item=DEAD, refresh_interval=300" }
Switch zw4Ping "Node4 Status: [MAP(nodeping.map):%s]" <sensor> (persist) { zwave="4:command=INFO, item=DEAD, refresh_interval=300" }
Switch zw5Ping "Node5 Status: [MAP(nodeping.map):%s]" <sensor> (persist) { zwave="5:command=INFO, item=DEAD, refresh_interval=300" }
Switch zw6Ping "Node6 Status: [MAP(nodeping.map):%s]" <sensor> (persist) { zwave="6:command=INFO, item=DEAD, refresh_interval=300" }
Switch zw7Ping "Node7 Status: [MAP(nodeping.map):%s]" <sensor> (persist) { zwave="7:command=INFO, item=DEAD, refresh_interval=300" }
Switch zw8Ping "Node8 Status: [MAP(nodeping.map):%s]" <sensor> (persist) { zwave="8:command=INFO, item=DEAD, refresh_interval=300" }

My logs show polling every 5 seconds. Binding version 1.9.

Questions:
1.Any way to change this to a higher value?
2. Is this talking to the binding and the binding is responding versus talking to the device every 5 seconds and killing the battery?

thanks!!

bueler? bueler? lol