Page 1 of 1

debug dzVents scripts - where is the syntax check?

Posted: Wednesday 26 July 2017 0:14
by renerene
Hello,

After writing my first dzVent scripts I notice that the Domoticz log does not inform you about (syntax) errors, the way I am used from Lua.
Do I need to look in another log system? Or is there no feedback at all?

gr,
rene

Re: debug dzVents scripts - where is the syntax check?

Posted: Wednesday 26 July 2017 1:54
by randytsuch
I get errors ALL the time, just looking at the domoticz log.

This is the only lua compiler/system I've ever used, so I have nothing to compare it to though.

It tells you what it doesn't like, and what line the error is on. I can usually figure out what's wrong based on the error message.
Between the error messages, and adding a lot of print statements to see what's really happening, I've been able to get my scripts working.
The print statements will also show up in the log.

I'm not sure if its really checking for syntax, but I only know enough SW to be dangerous.

Randy

Re: debug dzVents scripts - where is the syntax check?

Posted: Wednesday 26 July 2017 8:37
by renerene
thanks, but the question regarded dzVents, not LUA

Re: debug dzVents scripts - where is the syntax check?

Posted: Wednesday 26 July 2017 9:01
by dannybloe
It's the same. dzVents is Lua and doesn't swallow any Lua errors (or at least shouldn't). It is like randytsuch said above. I see all syntax errors and runtime errors in the domoticz log.

Re: debug dzVents scripts - where is the syntax check?

Posted: Wednesday 26 July 2017 9:44
by renerene
I did some testing.

You are correct regarding the 'execute' part. Errors in that part result in log messages, as soon as the function is triggered. When you make a mistake in the header, there is no feedback. (and the function is not triggered)

Code: Select all

return {
	active = true,
	on = {
		deices = {'dummy'}  <--- typo, not in log
	},
	execute = function(domoticz, switch)
	    domoticz.log ('Hello???')
    	if (switch.state == 'On') then
            domotic.log ('On') <-- typo, in log when triggered
    	else
    	    domoticz.log('Off')
    	end
    end
}

Re: debug dzVents scripts - where is the syntax check?

Posted: Wednesday 26 July 2017 9:52
by dannybloe
Yes, but that's not a lua or syntax error. What you can do is turn on debug logging for dzvents in domoticz settings. That can give you more information about preprocessing your scripts. I will see if I can build in more warnings about missing parts in the on-section.

Re: debug dzVents scripts - where is the syntax check?

Posted: Wednesday 26 July 2017 9:57
by snuiter
Bear in mind that when writing scripts in the domoticz/events option there is a simple syntax check. If I make a basic typo there is a red cross in the beginning of the line. Hope this helps a bit
Schermafbeelding 2017-07-26 om 09.57.06.png
Schermafbeelding 2017-07-26 om 09.57.06.png (10.06 KiB) Viewed 1438 times