urllib2.urlopen Url based upon Indigo Variable

Posted on
Sun Jan 29, 2017 2:23 pm
Albatros offline
Posts: 132
Joined: Feb 07, 2015

urllib2.urlopen Url based upon Indigo Variable

Thanks to this forum I have been re-using and creating bits of Python Code to do various things.

For the next step in controling my Daikin Airco I want to create a Url for the urllib2.urlopen Python code.


Below is the action to put the airco on. I want to control the "f_rate" based upon an Indigo Variable. It could be 7 or A.

import urllib2
urllib2.urlopen("http://192.168.X.XX/aircon/set_control_info?pow=1&mode=4&stemp=21&shum=0&f_rate=A&f_dir=0")


==============================================================
import urllib2
urllib2.urlopen("http://192.168.X.XX/aircon/set_control_info?pow=1&mode=4&stemp=21&shum=0&f_rate=<INDIGO VARABLE>&f_dir=0")

How can I create this via python code

Posted on
Sun Jan 29, 2017 2:48 pm
FlyingDiver offline
Posts: 3581
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: urllib2.urlopen Url based upon Indigo Variable

First, I recommend using the requests library over the urllib2 library.

Code: Select all
import requests

f_rate = indigo.variables[12345678].value # "f_rate"

url = "http://192.168.X.XX/aircon/set_control_info?pow=1&mode=4&stemp=21&shum=0&f_rate=" + f_rate + "&f_dir=0"
requests.get(url)


joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Sun Jan 29, 2017 6:54 pm
jay (support) offline
Site Admin
User avatar
Posts: 15856
Joined: Mar 19, 2008
Location: Austin, Texas

Re: urllib2.urlopen Url based upon Indigo Variable

@FlyingDiver forgot to add .value to the variable reference. I fixed it in-line in his script.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Sun Jan 29, 2017 6:57 pm
FlyingDiver offline
Posts: 3581
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: urllib2.urlopen Url based upon Indigo Variable

Oh, yeah. I don't use variables in scripts much. ;)

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest