Multiply on/off switch change

Python and python framework

Moderator: leecollings

Post Reply
optiserw
Posts: 10
Joined: Thursday 03 May 2018 13:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Multiply on/off switch change

Post 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
User avatar
jvdz
Posts: 2334
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Multiply on/off switch change

Post 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
Last edited by jvdz on Sunday 06 May 2018 15:11, edited 1 time in total.
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
optiserw
Posts: 10
Joined: Thursday 03 May 2018 13:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Multiply on/off switch change

Post 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...
User avatar
jvdz
Posts: 2334
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Multiply on/off switch change

Post by jvdz »

See my edit!

.. and I don't see why that takes long.
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
optiserw
Posts: 10
Joined: Thursday 03 May 2018 13:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Multiply on/off switch change

Post 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.
User avatar
jvdz
Posts: 2334
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Multiply on/off switch change

Post 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
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Multiply on/off switch change

Post 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.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
optiserw
Posts: 10
Joined: Thursday 03 May 2018 13:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Multiply on/off switch change

Post 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
User avatar
jvdz
Posts: 2334
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Multiply on/off switch change

Post 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
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
optiserw
Posts: 10
Joined: Thursday 03 May 2018 13:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Multiply on/off switch change

Post 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
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest