Page 1 of 1

custom domoticz page cannot control device from outside wlan

Posted: Saturday 24 September 2022 13:02
by paede
Hi
I made a custom html to show and control a webcam.
The camera is a esp32-cam.
Pan and tilt is working via mySensors. In domoticz pan and tilt are dimmers.
I can access the page from wlan and it works perfect.
when I connect from outside wlan (mobile data), i can access the page and the camerapicture works flawless.
Unfortunately the dimmers (pan and tilt) do not respond to the sliders I used in the webpage.
Can someone please have a quick look on the html
turret.zip
html-file
(1.6 KiB) Downloaded 49 times
and tell me what i need to change.
greets paede

Re: custom domoticz page cannot control device from outside wlan

Posted: Sunday 25 September 2022 10:51
by paede
Mabe I need to be more precise. I use the following code to change values on the dimmer devices.

Code: Select all

function dim(devicecode,dimlevel){
 execute('PUT', '../json.htm?type=command&param=switchlight&idx='+devicecode+'&switchcmd=Set%20Level&level='+dimlevel, '');
}

function execute($method,$url,$message){
xmlhttp=new XMLHttpRequest();
xmlhttp.open($method,$url,true)
xmlhttp.send($message);
}
<input type="range" min="5" max="100" value="50" onmouseup="dim(286,this.value);;">
idx 286 is the dimmer for pan.
This works on the same network as domoticz, but it doesn't work from outside this network. All other functions of domoticz work from outside this network.
What do I need to change to have functionality from outside lan

Re: custom domoticz page cannot control device from outside wlan

Posted: Monday 26 September 2022 8:17
by kiddigital
Why do you use a ‘PUT’ request? I am not sure if Domoticz handles that correctly.

Try a ‘GET’ request as all data is contained in the URL. No need for a ‘POST’.

Make sure that you have given access to the right IP addresses in Domoticz (remote networks) so it accepts incoming requests.

Re: custom domoticz page cannot control device from outside wlan

Posted: Monday 26 September 2022 21:41
by paede
Why do you use a ‘PUT’ request? I am not sure if Domoticz handles that correctly.
I copied this from someone else.
So I just change 'PUT' to 'GET' ?
My knowledge in html and javascript is very basic. I usually copy code and change that to my needs.

domoticz works from remote networks. Only the dimmers on my custom page do not work. when i change those in "normal" devices tab they work.

Thanks
paede

Re: custom domoticz page cannot control device from outside wlan

Posted: Tuesday 27 September 2022 7:45
by kiddigital
Yes, just change PUT to GET.

Re: custom domoticz page cannot control device from outside wlan

Posted: Tuesday 27 September 2022 15:05
by paede
ok I changed the PUT to GET.
But that did not make any change.

Controlling of pan and tilt works fine on the custom html in local network, but in remote network it does not work.

Re: custom domoticz page cannot control device from outside wlan

Posted: Wednesday 28 September 2022 10:47
by waltervl
If you use user/password to access domoticz, you have to add that to the json statement in custom page as it is not integrated in Domoticz.

Re: custom domoticz page cannot control device from outside wlan

Posted: Wednesday 28 September 2022 11:03
by waltervl
And additional perhaps add the IP of your domoticz server to the url variable too
see https://github.com/domoticz/domoticz/bl ... om.example