MilhouseVH / autoaway.py

Improved auto-away monitoring for Nest Thermostats
15 stars 1 forks source link

Retry setting away/here status if exception is raised #3

Closed iwoloschin closed 7 years ago

iwoloschin commented 10 years ago

I've been using this for a few days now, and one thing I've noticed is that pynest occasionally fails to properly set the away status. I think the problem is a flaky internet connection on my end, though I haven't explored too much yet. How hard would it be to set autoaway to retry every X minutes if it catches an exception on changing the away status? Here's an example:

2014-02-04 07:22:18.479042: Property is vacant - occupied for 0d 11:09:44 (from 2014-02-03 19:51:03 - 2014-02-04 07:00:47) 2014-02-04 07:22:19.220358: #### BEGIN EXCEPTION ##### 2014-02-04 07:22:19.221428: Command '['./notifynest.sh', 'away', '40184', '0d 11:09:44']' returned non-zero exit status 1 2014-02-04 07:22:19.222317: Output from notify follows: Updating Nest with away status: away Property occupied for 0d 11:09:44 (40184 seconds) Traceback (most recent call last): File "/usr/local/bin/nest.py", line 323, in main() File "/usr/local/bin/nest.py", line 279, in main n.login() File "/usr/local/bin/nest.py", line 95, in login res = urllib2.urlopen(req).read() File "/usr/lib/python2.7/urllib2.py", line 127, in urlopen return _opener.open(url, data, timeout) File "/usr/lib/python2.7/urllib2.py", line 401, in open response = self._open(req, data) File "/usr/lib/python2.7/urllib2.py", line 419, in _open '_open', req) File "/usr/lib/python2.7/urllib2.py", line 379, in _call_chain result = func(*args) File "/usr/lib/python2.7/urllib2.py", line 1219, in https_open return self.do_open(httplib.HTTPSConnection, req) File "/usr/lib/python2.7/urllib2.py", line 1181, in do_open raise URLError(err) urllib2.URLError: <urlopen error [Errno -2] Name or service not known>

2014-02-04 07:22:19.227151: #### END EXCEPTION #####

MilhouseVH commented 10 years ago

Wouldn't it be better to catch the exception and retry within the notify script?

iwoloschin commented 10 years ago

Sure, that could work too.

On Tue, Feb 4, 2014 at 2:13 PM, MilhouseVH notifications@github.com wrote:

Wouldn't it be better to catch the exception and retry within the notify script?

Reply to this email directly or view it on GitHubhttps://github.com/MilhouseVH/autoaway.py/issues/3#issuecomment-34095516 .