Sorry for using "requests" but I found it much easier than using the modules that come with Indigo.
- Code: Select all
import requests
key = 'Bearer ' + (indigo.variables['rachioAPIKey'].value)
deviceID = (indigo.variables['rachioAPIDeviceID'].value)
personID = (indigo.variables['rachioAPIPersonID'].value)
post_url = 'https://api.rach.io/1/public/device/rain_delay'
head = {
'Content-Type' : 'application/json',
'Authorization' : key
}
payload = {
'id' : deviceID,
'duration' : 86400
}
r = requests.put(post_url, json=payload, headers=head)
if str(r.status_code) == '204':
indigo.server.log('Rachio Rain Delay Successful')
indigo.variable.updateValue('rachioRainDelayNotification', value=str('true'))
Here's the complete Rachio API: https://rachio.readme.io/v1.0/docs