Webinfo to Variable with Python

Posted on
Sat Aug 04, 2018 4:39 am
DeltaMike1200 offline
Posts: 11
Joined: Jun 02, 2014

Webinfo to Variable with Python

I have a Pentair Intellipool installation. The Pentair company has made a webinterface to interact with the pool.
Now I like to use this info with my indigo home system, the Pentair company has recently made a API available to do this kind of interfacing.
I can call this API with my webbrowser :

https://api.domotique-piscine.eu/api/in ... APIKEYHERE

the return is : +28.7°c

In the Indigo software I like to add an action with a Python script to call this API and put the the return value into a Indigo Variable

Can anybody help me to get started ?

[MODERATOR NOTE] - removed the API key from the URL and replaced it with APIKEYHERE in an effort to avoid hacking.

Posted on
Sat Aug 04, 2018 4:58 am
DaveL17 offline
User avatar
Posts: 6753
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Webinfo to Variable with Python

DeltaMike1200 wrote:
I have a Pentair Intellipool installation. The Pentair company has made a webinterface to interact with the pool.
Now I like to use this info with my indigo home system, the Pentair company has recently made a API available to do this kind of interfacing.
I can call this API with my webbrowser :

https://api.domotique-piscine.eu/api/in ... mp?key=KEY

the return is : +28.7°c

In the Indigo software I like to add an action with a Python script to call this API and put the the return value into a Indigo Variable

Can anybody help me to get started ?

I think this is the simplest way to do what you need. You will need to replace 'KEY' with your API key and the Indigo variable ID number with the ID of your variable.

A piece of friendly advice: you may wish to remove your API key from the forum post above as we are able to see (and use) it.

Cheers,
Dave

Code: Select all
import requests

# Get the value from the API
r = requests.get('https://api.domotique-piscine.eu/api/install/45383/probe/water-temp?key=KEY')

# Remove the units indicator
temp = r.text.strip(u' °C')

indigo.variable.updateValue(1928699259, temp)

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Sat Aug 04, 2018 5:18 am
DeltaMike1200 offline
Posts: 11
Joined: Jun 02, 2014

Re: Webinfo to Variable with Python

Hi Dave,

Thanks for your very quick response.

When the script is working I will change the API key, so for the time being the world can see my pool temperature :D

This is the response the script is giving me :

Script Error embedded script: [SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:590)
Script Error Exception Traceback (most recent call shown last):

embedded script, line 5, at top level
File "/Library/Application Support/Perceptive Automation/Indigo 7/IndigoPluginHost.app/Contents/PlugIns/requests/api.py", line 71, in get
return request('get', url, params=params, **kwargs)
File "/Library/Application Support/Perceptive Automation/Indigo 7/IndigoPluginHost.app/Contents/PlugIns/requests/api.py", line 57, in request
return session.request(method=method, url=url, **kwargs)
File "/Library/Application Support/Perceptive Automation/Indigo 7/IndigoPluginHost.app/Contents/PlugIns/requests/sessions.py", line 477, in request
resp = self.send(prep, **send_kwargs)
File "/Library/Application Support/Perceptive Automation/Indigo 7/IndigoPluginHost.app/Contents/PlugIns/requests/sessions.py", line 587, in send
r = adapter.send(request, **kwargs)
File "/Library/Application Support/Perceptive Automation/Indigo 7/IndigoPluginHost.app/Contents/PlugIns/requests/adapters.py", line 491, in send
raise SSLError(e, request=request)
SSLError: [SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:590)

Posted on
Sat Aug 04, 2018 5:38 am
DaveL17 offline
User avatar
Posts: 6753
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Webinfo to Variable with Python

OK, we can try to deal with that a slightly different way, then.

Code: Select all
import subprocess

# Get the value from the API
proc = subprocess.Popen(["curl", '-vs', 'https://api.domotique-piscine.eu/api/install/45383/probe/water-temp?key=KEY'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)

out, err = proc.communicate()

# Remove the units indicator
temp = out.strip(' °C')

indigo.variable.updateValue(1928699259, temp)

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Sat Aug 04, 2018 5:59 am
DeltaMike1200 offline
Posts: 11
Joined: Jun 02, 2014

Re: Webinfo to Variable with Python

Hi Dave

Many Many thanks,

The script works perfectly, you saved me a lot of time.

Have a nice weekend,

ps. We in Belgium have a nice blue sky hot saturday.

Posted on
Sat Aug 04, 2018 6:04 am
DaveL17 offline
User avatar
Posts: 6753
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Webinfo to Variable with Python

Glad to hear that's working for you.

We're expecting a hot, humid day here as well--with a high of 90ºF and lots of sun. A great day for the beach!

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest