openmotics / plugins

Repository containing the gateway plugins.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Astro plugin doesn't load because of failing API call

khenderick opened this issue · comments

...
2013-07-01 00:00:19,450 - openmotics - INFO - Setting the time on the master.
2013-07-01 00:03:39,979 - openmotics - ERROR - Plugin Astro: Could not initialize plugin (HTTPSConnectio
nPool(host='maps.googleapis.com', port=443): Max retries exceeded with url: /maps/api/geocode/json?addre
ss=Brussels,Belgium (Caused by <class 'socket.gaierror'>: [Errno -2] Name or service not known))
[01/Jul/2013:00:03:51] ENGINE Bus STARTING
...
2013-07-01 00:03:39 | Could not initialize plugin: HTTPSConnectionPool(host='maps.googleapis.com', port=443): Max retries exceeded with url: /maps/api/geocode/json?address=Brussels,Belgium (Caused by <class 'socket.gaierror'>: [Errno -2] Name or service not known)
| aceback (most recent call last):
| File "/opt/openmotics/python/plugins/base.py", line 268, in _gather_plugins
| plugins.append(plugin_class(self.__webinterface, self.get_logger(name)))
| File "/opt/openmotics/python/plugins/Astro/main.py", line 67, in __init__
| self._read_config()
| File "/opt/openmotics/python/plugins/Astro/main.py", line 97, in _read_config
| location = requests.get(api).json()
| File "/opt/openmotics/python/requests/api.py", line 55, in get
| return request('get', url, **kwargs)
| File "/opt/openmotics/python/requests/api.py", line 44, in request
| return session.request(method=method, url=url, **kwargs)
| File "/opt/openmotics/python/requests/sessions.py", line 346, in request
| resp = self.send(prep, **send_kwargs)
| File "/opt/openmotics/python/requests/sessions.py", line 449, in send
| r = adapter.send(request, **kwargs)
| File "/opt/openmotics/python/requests/adapters.py", line 318, in send
| raise ConnectionError(e)
| nnectionError: HTTPSConnectionPool(host='maps.googleapis.com', port=443): Max retries exceeded with url: /maps/api/geocode/json?address=Brussels,Belgium (Caused by <class 'socket.gaierror'>: [Errno -2] Name or service not known)
commented

Maybe a good idea to resolve address to coordinates in the module configuration screen and save the location as lat/long in the config file to reduce the numer of API calls (since most likely the gateway doesn't change location that frequently!)
(and maybe proxy these initial requests through the cloud.openmotics.com server and use an API key there (the 25k requests per day should be sufficient for quite some time I think))

Resolved this in Astro 0.6.2; it now handles exceptions correctly and will indeed cache/store the coordinates for future use.