Page 1 of 1

Multiply on/off switch change

Posted: Sunday 06 May 2018 15:07
by optiserw
Hi,

I have a few switches in my system.
I want to change the status of the switches at the same time using one API command.

I am thinking about somenthing like that:

Code: Select all

/json.htm?type=command&param=switchlight&idx=1&switchcmd=On&idx=2&switchcmd=Off&idx=3&switchcmd=Off&idx=4&switchcmd=On
How can I do that in Python?

Pawel

Re: Multiply on/off switch change

Posted: Sunday 06 May 2018 15:08
by jvdz
They each require an separate API call as far as I know.

EDIT -> Funny, you seem to have asked that question already and received answer.s... wasn't that enough for you?

Jos

Re: Multiply on/off switch change

Posted: Sunday 06 May 2018 15:10
by optiserw
jvdz wrote: Sunday 06 May 2018 15:08 They each require an separate API call as far as I know.

Jos
But it takes a long time...

Re: Multiply on/off switch change

Posted: Sunday 06 May 2018 15:12
by jvdz
See my edit!

.. and I don't see why that takes long.

Re: Multiply on/off switch change

Posted: Sunday 06 May 2018 19:49
by optiserw
jvdz wrote: Sunday 06 May 2018 15:12 See my edit!

.. and I don't see why that takes long.
This code takes about 25 second!
Why?

Code: Select all

urllib.urlopen("https://192.168.20.10/json.htm?type=command&param=switchlight&idx=192&switchcmd=On").read()
urllib.urlopen("https://192.168.20.10/json.htm?type=command&param=switchlight&idx=193&switchcmd=Off").read()
urllib.urlopen("https://192.168.20.10/json.htm?type=command&param=switchlight&idx=194&switchcmd=On").read()
It is only 3 dummy switches! I need to change 30 - 40 switches at the same time.

Re: Multiply on/off switch change

Posted: Sunday 06 May 2018 20:21
by jvdz
That should be done in milliseconds! How long does it take when you take one of these url's and put them in a browser?
Either way, you have been given a number of answers in the other thread so really don't understand why you started a new one in stead of following up on the posted suggestions.

Jos

Re: Multiply on/off switch change

Posted: Sunday 06 May 2018 20:35
by waaren
jvdz wrote: Sunday 06 May 2018 20:21 That should be done in milliseconds! How long does it take when you take one of these url's and put them in a browser?
Either way, you have been given a number of answers in the other thread so really don't understand why you started a new one in stead of following up on the posted suggestions.

Jos
@Jos,
probably my doing Jos. optiserw asked in the other thread if my proposed dzVents solution could be implemented in Python and I advised to ask the question in the Python subforum.
I am sorry if I advised optiserw to follow a wrong approach.

Re: Multiply on/off switch change

Posted: Sunday 06 May 2018 20:43
by optiserw
jvdz wrote: Sunday 06 May 2018 20:21 That should be done in milliseconds! How long does it take when you take one of these url's and put them in a browser?
Either way, you have been given a number of answers in the other thread so really don't understand why you started a new one in stead of following up on the posted suggestions.

Jos
If I take one of these url it takes about 7 seconds.
I ask on this sub-forum because I need do this is Python.

Pawel

Re: Multiply on/off switch change

Posted: Sunday 06 May 2018 21:42
by jvdz
optiserw wrote: Sunday 06 May 2018 20:43 If I take one of these url it takes about 7 seconds.
So it takes 7 seconds for domoticz to come back with OK when you use that URL in a regular browser like Chrome?

Jos

Re: Multiply on/off switch change

Posted: Sunday 06 May 2018 22:49
by optiserw
jvdz wrote: Sunday 06 May 2018 21:42
optiserw wrote: Sunday 06 May 2018 20:43 If I take one of these url it takes about 7 seconds.
So it takes 7 seconds for domoticz to come back with OK when you use that URL in a regular browser like Chrome?

Jos
If I use browser the time is very short.

Pawel