Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyError for certain locations #37

Closed
fabaff opened this issue Oct 15, 2018 · 2 comments
Closed

KeyError for certain locations #37

fabaff opened this issue Oct 15, 2018 · 2 comments

Comments

@fabaff
Copy link

fabaff commented Oct 15, 2018

This example is using Zurich, Switzerland with the coordinates from the Metoffice website.

$ python3
Python 3.6.6 (default, Jul 19 2018, 14:25:17) 
[GCC 8.1.1 20180712 (Red Hat 8.1.1-5)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import datapoint
>>> conn = datapoint.connection(api_key="aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee")
>>> site = conn.get_nearest_site(47.383, 8.567)
>>> forecast = conn.get_forecast_for_site(site.id, "3hourly")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/fab/Documents/repos/ha/home-assistant/lib64/python3.6/site-packages/datapoint/Manager.py", line 217, in get_forecast_for_site
    forecast.continent = data['SiteRep']['DV']['Location']['continent']
KeyError: 'Location'
>>> 

It works for Paris and London.

Original issue: home-assistant/core#17492

@jacobtomlinson
Copy link
Collaborator

This API only provides data for the UK. Putting in locations outside of the UK will result in either misleading data (Paris will be showing the nearest UK location as it is within the UK bounding box) or no data (Zurich is outside of the UK bounding box).

That being said this should be failing more gracefully with an error stating that this location is out of bounds.

@EJEP
Copy link
Owner

EJEP commented Feb 1, 2019

This is fixed by #74

@EJEP EJEP closed this as completed Feb 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants