I've been attempting to add an action to the great Ecobee 3 plugin (https://github.com/jdhorne/indigo-ecobee-plugin), but as a Python/Indigo Plugin Dev. novice, I'm getting nowhere. Here's what I'm attempting to do:
Simply call the resume_program function in the pyecobee library via an Indigo action (in actions.xml). This function doesn't currently exist in the plugin.py file, but it does exist in pyecobee/__init__.py file in the plugin bundle:
- Code: Select all
def resume_program(self, index, resume_all="false"):
''' Resume currently scheduled program '''
url = 'https://api.ecobee.com/1/thermostat'
header = {'Content-Type': 'application/json;charset=UTF-8',
'Authorization': 'Bearer ' + self.access_token}
params = {'format': 'json'}
body = ('{"functions":[{"type":"resumeProgram","params":{"resumeAll"'
':"' + resume_all + '"}}],"selection":{"selectionType"'
':"thermostats","selectionMatch":"'
+ self.thermostats[index]['identifier'] + '"}}')
request = requests.post(url, headers=header, params=params, data=body)
if request.status_code == requests.codes.ok:
self._invalidate_cache()
return request
else:
log.warning("Error connecting to Ecobee while attempting to resume"
" program. Refreshing tokens...")
self.refresh_tokens()
This seems like it should be simple, but I get the error "plugin does not define method resume_program" every time! Where am I going wrong as I attempt to define resume_program in plugin.py and call it from actions.xml? Help!
Thanks in advance!
chobo997