set user variable fails when -webroot is used

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
janpascal
Posts: 2
Joined: Tuesday 12 December 2017 18:31
Target OS: Linux
Domoticz version:
Contact:

set user variable fails when -webroot is used

Post 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
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: set user variable fails when -webroot is used

Post 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.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: set user variable fails when -webroot is used

Post 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.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
mischa
Posts: 74
Joined: Tuesday 07 April 2015 20:32
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8872
Location: Heerhugowaard, The Netherlands
Contact:

Re: set user variable fails when -webroot is used

Post by mischa »

How can I update to version 2.3 without updating Domoticz?
running into the same issue

Thanks,

Mischa
Pi 2 - Pi 1 - Razzbery 2.0 - Fibaro FGD-211 - Fibaro FGD-212 - Fibaro FGRGBWM-441 (RGBW Module) - Fibaro FGBS321 (Universal Switch) - FGWPF-102 - TBK Home TZ67-G - Synology DS1515+ - Esp Easy (with wemos D1 mini)
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: set user variable fails when -webroot is used

Post by dannybloe »

You will have to wait for 2.4 to be merged in beta. DzVents is tightly locked to a Domoticz build.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
mischa
Posts: 74
Joined: Tuesday 07 April 2015 20:32
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8872
Location: Heerhugowaard, The Netherlands
Contact:

Re: set user variable fails when -webroot is used

Post 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
Pi 2 - Pi 1 - Razzbery 2.0 - Fibaro FGD-211 - Fibaro FGD-212 - Fibaro FGRGBWM-441 (RGBW Module) - Fibaro FGBS321 (Universal Switch) - FGWPF-102 - TBK Home TZ67-G - Synology DS1515+ - Esp Easy (with wemos D1 mini)
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest