The value of the local variable length is not used

I just started to get this error message when recompiling my Rule base and I can’t find anything on OH about it. The keywords to this is “variable length”. I understand when I get the local variable is not used but this is a different message.

Any ideas where to look?

2020-04-01 18:46:09.494 [INFO ] [el.core.internal.ModelRepositoryImpl] - Validation issues found in configuration model 'default.rules', using it anyway:
The value of the local variable length is not used
The value of the local variable length is not used
The value of the local variable length is not used

Best, Jay

That is an “Info” and not an error!
A wild guess: Do you happen to have a variable named “length” in that rules file?
.

1 Like

I wish it was an info error but the 3 rules that are basically all same except tied to different lamps are causing this error after I put this line in.

var String EchoThing = getThingStatusInfo(“amazonechocontrol:account:account1”).getStatus()

Could it be something specific to a CRON tasks and getting a getThingStatusInfo ?

BTW, the rule did not work this morning and it has worked for over a year now. That specific line is causing the issue for some reason and I use it in many other rules to check a Echo device status.

Yes, I do have a length variable also but that variable has been there for over a year working. I can rename it and give that a try.

rule "Guest Bedroom Echo Alarm controlling HUE bed side table light"
	when
		Time cron "45 0/1 4-7 * * ?"		// run every 45 secs between 4 - 7 am
	then
	
			if (systemStarted.state != ON && Home_Away.state == ON && gInternet.state == ON) {

				var String EchoThing  = getThingStatusInfo("amazonechocontrol:account:account1").getStatus()

    			if (systemStarted.state != ON && EchoThing == 'ONLINE' && gInternet.state == ON) {

					// read Alexa notifications - alarm, reminders, timers	
		        	var String json = sendHttpGetRequest("http://192.168.0.230:8080/amazonechocontrol/account1/PROXY/api/notifications")
		                
		        	// get number of notifications read
		        	var String length = transform("JSONPATH", "$.notifications.length()", json)
				} 

The message you get is labelled “Info”, additionally it states " using it anyway:", meaning your code is running.
The reason for this Info is the declared variable “length” which gets assigned a value but is not used elsewhere in the rule (at least in part you posted).
Does the code do what it is supposed to do?

The message you have shown is absolutely about that variable.
It might not be a bad idea to rename it - “length” is sounding like it could be a keyword / reserved word in some circumstances.
Like @opus says, review why you have it all if you don’t do anything with it.

Meantime, if you have some separate problem with ThingStatus, you will need to describe that problem.

The variable name confused the situation; I have change the code by removing the first IF block and putting the variables inside the second IF block. Not sure why the variables “length” was throwing the error but the variable “json” wasn’t.

It’s all good now.

			if (systemStarted.state != ON && Home_Away.state == ON && gInternet.state == ON) {

				var String EchoThing  = getThingStatusInfo("amazonechocontrol:account:account1").getStatus()

				if (systemStarted.state != ON && EchoThing == 'ONLINE' && Home_Away.state == ON && gInternet.state == ON) {

					// read Alexa notifications - alarm, reminders, timers	
		        	var String json = sendHttpGetRequest("http://192.168.0.230:8080/amazonechocontrol/account1/PROXY/api/notifications")
		                
		        	// get number of notifications read
		        	var String length = transform("JSONPATH", "$.notifications.length()", json)
	
		        	// logInfo("ECHO", json)
		        	// logInfo("ECHO", "Number of notifications found: " + length)
		                     
		        	var Number i = 0
		        	var String status
		        	var String deviceSerialNumber
		        	var String type
		        	var String alarmtime = "NULL"
		        	var String alarmdate = "NULL"
		        	var int count = Integer::parseInt(length)

Best, Jay

Without knowing the whole complete code, who should say.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.