wez3 / domoboard-plugins

A repository containing all Domoboard plugins
GNU General Public License v3.0
5 stars 3 forks source link

Local language support for wunderground plugin #40

Open dutchdevil83 opened 7 years ago

dutchdevil83 commented 7 years ago

Add local language support for the wunderground plugin. You can get country code from location tag and call the api in that language.

felix63 commented 7 years ago

Was easy to implement. However from the language codes mentioned on https://www.wunderground.com/weather/api/d/docs?d=language-support&MR=1 it seems that 'NL' is one that doesn't work. Others do seem to work without problem.

dutchdevil83 commented 7 years ago

Incorrect, NL is supported:

http://api.wunderground.com/api/Your_API/forecast/lang:NL/q/France/Paris.json

felix63 commented 7 years ago

Supported in WUnderground - Yes. Working in Domoboard with my modification - No.

felix63 commented 7 years ago

[2017-01-12 11:21:04,511] ERROR in app: Exception on /api [POST] Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/Flask-0.12-py2.7.egg/flask/app.py", line 1982, in wsgi_app response = self.full_dispatch_request() File "/usr/local/lib/python2.7/dist-packages/Flask-0.12-py2.7.egg/flask/app.py", line 1614, in full_dispatch_request rv = self.handle_user_exception(e) File "/usr/local/lib/python2.7/dist-packages/Flask-0.12-py2.7.egg/flask/app.py", line 1517, in handle_user_exception reraise(exc_type, exc_value, tb) File "/usr/local/lib/python2.7/dist-packages/Flask-0.12-py2.7.egg/flask/app.py", line 1612, in full_dispatch_request rv = self.dispatch_request() File "/usr/local/lib/python2.7/dist-packages/Flask-0.12-py2.7.egg/flask/app.py", line 1598, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/usr/local/lib/python2.7/dist-packages/Flask_Auth-0.85-py2.7.egg/flaskext/auth/auth.py", line 186, in decorator return func(*args, **kwargs) File "/home/pi/domoboard/modules/api.py", line 88, in gateway result = call(request.args) File "/home/pi/domoboard/plugins/wunderground.py", line 66, in getData data['forecastTxt'], data['forecastSimple'] = createForecast(requests.get(_url).text) File "/home/pi/domoboard/plugins/wunderground.py", line 48, in createForecast _simpleValues = _forecastSimple[next(index for (index, d) in enumerate(_forecastSimple) if d["date"]["weekday"] == _forecastTxt[idx]['weekday'])] StopIteration

squandor commented 7 years ago

its not working for dutch because python doesn't get the dutch weekday. Therefore the plugin breaks if you try to use it with nl