Simultaneous connections

Python and python framework

Moderator: leecollings

Post Reply
meyland
Posts: 35
Joined: Wednesday 03 January 2018 16:39
Target OS: Linux
Domoticz version: 2020.2
Location: Denmark
Contact:

Simultaneous connections

Post by meyland »

I'm developing a plugin and I need to be able to make about 20-30 simultaneous connections to a website.

I don't know how to make all these connections by using the connection object. Can anyone give me a hint? :D
regards

Peter
pipiche
Posts: 2005
Joined: Monday 02 April 2018 20:33
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: France
Contact:

Re: Simultaneous connections

Post by pipiche »

meyland wrote: Monday 04 January 2021 20:17 I'm developing a plugin and I need to be able to make about 20-30 simultaneous connections to a website.

I don't know how to make all these connections by using the connection object. Can anyone give me a hint? :D
You should check the plugins/examples/HTTP.py
self.httpConn = Domoticz.Connection(Name=self.sProtocol+" Test", Transport="TCP/IP", Protocol=self.sProtocol, Address=Parameters["Address"], Port=Parameters["Mode1"])
And you do as many as you need.

Now if you don't want to use the Connection API you might go for a multi Thread opening their own connection via urlibrequest or other python3 module like that
Zigbee for Domoticz plugin / RPI3B+ / Electrolama ZZH-P / 45 devices

If the plugin provides you value, you can support me with a donation Paypal.

Wiki is available here.

Zigbee for Domoticz FAQ
User avatar
waltervl
Posts: 5715
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Simultaneous connections

Post by waltervl »

There is a Multi-Thread example https://github.com/domoticz/domoticz/bl ... hreaded.py

See also the Wiki for some remarks about this: https://www.domoticz.com/wiki/Developin ... rk_details:
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
meyland
Posts: 35
Joined: Wednesday 03 January 2018 16:39
Target OS: Linux
Domoticz version: 2020.2
Location: Denmark
Contact:

Re: Simultaneous connections

Post by meyland »

Many thanks, I will look at the examples to night
regards

Peter
meyland
Posts: 35
Joined: Wednesday 03 January 2018 16:39
Target OS: Linux
Domoticz version: 2020.2
Location: Denmark
Contact:

Re: Simultaneous connections

Post by meyland »

a thought: is it possible to use the asyncio module, ie async and await syntax in a plugin?
regards

Peter
pipiche
Posts: 2005
Joined: Monday 02 April 2018 20:33
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: France
Contact:

Re: Simultaneous connections

Post by pipiche »

yes you can use the async
Zigbee for Domoticz plugin / RPI3B+ / Electrolama ZZH-P / 45 devices

If the plugin provides you value, you can support me with a donation Paypal.

Wiki is available here.

Zigbee for Domoticz FAQ
meyland
Posts: 35
Joined: Wednesday 03 January 2018 16:39
Target OS: Linux
Domoticz version: 2020.2
Location: Denmark
Contact:

Re: Simultaneous connections

Post by meyland »

Sounds good. Are there any examples on how to use asyncio?
regards

Peter
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest