Page 1 of 1

set user variable fails when -webroot is used

Posted: Sunday 17 December 2017 21:59
by janpascal
Hi all,

I'm trying to set a user variable from a dzVents script (so that another script can trigger on it). I think it is failing because I start domoticz with the -webroot option:

Code: Select all

-daemon -www 8081 -sslwww 0 -log /var/log/domoticz/log.txt -webroot domoticz -verbose 2 -pidfile $PIDFILE -userdata /var/lib/domoticz/ -dbase /var/lib/domoticz/domoticz.db -loglevel 3
Then, when from a dzVents script I try to set a user variable:

Code: Select all

domoticz.variables('AlarmDetected').set(1)
This result in an error message in the domoticz log:

Code: Select all

Error opening url: http://127.0.0.1:8081/json.htm?type=command&param=updateuservariable&vname=AlarmDetected&vtype=0&vvalue=1&idx=1
... which is indeed incorrect because the webroot is missing in the url. It should start with http://127.0.0.1:8081/domoticz/json.html?...

It seems to me two things should be done to fix this. First, in main/EventSystem.cpp, in EventSystem::EvaluateLua(), the Lua global variable 'globalvariables' is set, including the domoticz_listening_port. Here domoticz_webroot should be added with code like this:

Code: Select all

                        lua_pushstring(lua_state, "domoticz_webroot");
                        lua_pushstring(lua_state, <SOMETHING>);
                        lua_rawset(lua_state, -3);
I'm not sure where the webroot is stored in domoticz.

Second, in dzVents/runtime/EventHelpers.lua the line

Code: Select all

['Domoticz url'] = 'http://127.0.0.1:' .. (tostring(globalvariables['domoticz_listening_port']) or "8080")
 
should be something like

Code: Select all

['Domoticz url'] = 'http://127.0.0.1:' .. (tostring(globalvariables['domoticz_listening_port']) or "8080") .. '/' ..(tostring(globalvariables['domoticz_webroot']) or ''')
 
(except that this add a superfluous / when the webroot is empty).

Am I thinking in the right direction? BTW, running Domoticz 3.8153 with the included dzVents 2.2.0.
Thanks for any help,

Jan-Pascal

Re: set user variable fails when -webroot is used

Posted: Tuesday 19 December 2017 7:22
by dannybloe
Ah, interesting. You learn something new every day. I'll add it to the todo list. In the mean time you can upgrade to 2.3 as that no longer uses http to update variables.

Re: set user variable fails when -webroot is used

Posted: Thursday 04 January 2018 14:30
by dannybloe
Ok, dzVents 2.4 will have support for this.
I tested this on my machine and I noticed that if you started domoticz with a webroot that you cannot save the settings in the GUI. Will give you bad request.

Re: set user variable fails when -webroot is used

Posted: Monday 22 January 2018 17:47
by mischa
How can I update to version 2.3 without updating Domoticz?
running into the same issue

Thanks,

Mischa

Re: set user variable fails when -webroot is used

Posted: Monday 22 January 2018 18:10
by dannybloe
You will have to wait for 2.4 to be merged in beta. DzVents is tightly locked to a Domoticz build.

Re: set user variable fails when -webroot is used

Posted: Monday 22 January 2018 18:15
by mischa
Is there a workaround for updating the variable?

I'm running stable on a Synology NAS, not sure if it is possible to update from stable to beta.
and probably going to take a while before jumbotroll makes another beta.

Mischa