Hi guys,
I need some help. I am making one plugin for wifi Aircon remote, but i cannot find one good way for sending request URL.
I explain :
I would like to send to the local network one hhtp look like : http://192.168.1.38//api_asrlite?action ... &onoff=OFF
I tried a lot of thing, but do not fin good one.
One idea of what i need after for example :
if Devices[1].sValue == "0": # Aircon is off
Thanks in advance !!!!!!!!!!!!!! I will turn crazy !!!!
Help : Python Plugin / Open Url / Request URL
Moderator: leecollings
- Dnpwwo
- Posts: 819
- Joined: Sunday 23 March 2014 9:00
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: Melbourne, Australia
- Contact:
Re: Help : Python Plugin / Open Url / Request URL
@Erwanweb,
We can't have you turning crazy so here are some suggestions.
Firstly I would execute the URL on a browser like FireFox and have a look at the actual request and response (to do this on FireFox see https://developer.mozilla.org/en-US/doc ... rk_Monitor or hit ctrl + shift + e)
That will show you what http verb to use (probably GET) and some useful headers that you probably need to send.
Have a look at the HTTP.py in the examples folder under plugins but the relevant code could be:
We can't have you turning crazy so here are some suggestions.
Firstly I would execute the URL on a browser like FireFox and have a look at the actual request and response (to do this on FireFox see https://developer.mozilla.org/en-US/doc ... rk_Monitor or hit ctrl + shift + e)
That will show you what http verb to use (probably GET) and some useful headers that you probably need to send.
Have a look at the HTTP.py in the examples folder under plugins but the relevant code could be:
Code: Select all
def onStart(self):
self.httpConn = Domoticz.Connection(Name="Heating Connection", Transport="TCP/IP", Protocol="HTTP", Address="192.168.1.38", Port="80")
self.httpConn.Connect()
def onConnect(self, Connection, Status, Description):
if (Status == 0):
sendData = { 'Verb' : 'GET',
'URL' : '/api_asrlite?action....&onoff=OFF',
'Headers' : { 'Content-Type': 'text/xml; charset=utf-8', \
'Connection': 'keep-alive', \
'Accept': 'Content-Type: text/html; charset=UTF-8', \
'Host': "192.168.1.38:80", \
'User-Agent':'Domoticz/1.0' }
}
Connection.Send(sendData)
The reasonable man adapts himself to the world; the unreasonable one persists to adapt the world to himself. Therefore all progress depends on the unreasonable man. George Bernard Shaw
-
- Posts: 10
- Joined: Monday 05 November 2018 9:16
- Target OS: Linux
- Domoticz version: lastest
- Location: Barcelona (Spain)
- Contact:
Re: Help : Python Plugin / Open Url / Request URL
Hi &Dnpwwo !
Many Thanks, now all is ok and the plugin turning well. Just need to test it in time because it seem requesting to much of the rpi.
It is my first plugin that i make alone lol.
Thanks for your help.
Many Thanks, now all is ok and the plugin turning well. Just need to test it in time because it seem requesting to much of the rpi.
It is my first plugin that i make alone lol.
Thanks for your help.
Who is online
Users browsing this forum: Google [Bot] and 1 guest