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

Met.no weather platform #16582

Merged
merged 8 commits into from
Sep 20, 2018
Merged

Met.no weather platform #16582

merged 8 commits into from
Sep 20, 2018

Conversation

Danielhiversen
Copy link
Member

@Danielhiversen Danielhiversen commented Sep 12, 2018

Description:

A weather component with data from Met.no
This is the same data source as the yr.no sensor.

Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.io#6287

Example entry for configuration.yaml (if applicable):

weather:
  - platform: met

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • New dependencies have been added to the REQUIREMENTS variable (example).
  • New dependencies are only imported inside functions that use them (example).
  • New or updated dependencies have been added to requirements_all.txt by running script/gen_requirements_all.py.
  • New files were added to .coveragerc.

@ghost ghost assigned Danielhiversen Sep 12, 2018
@fabaff fabaff changed the title Met.no weather component Met.no weather platform Sep 12, 2018
continue

if param == 'precipitation':
new_state = loc_data[param]['@value']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should extract this into a third party lib.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok 👍

self._pressure = metno.get_forecast('pressure', ordered_entries)
self._humidity = metno.get_forecast('humidity', ordered_entries)
self._wind_speed = metno.get_forecast('windSpeed', ordered_entries)
self._wind_bearing = metno.get_forecast('windDirection', ordered_entries)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line too long (81 > 79 characters)

self._weather_data = metno.MetWeatherData(coordinates,
clientsession,
'https://aa015h6buqvih86i1.api.met.no/'
'weatherapi/locationforecast/1.9/'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line too long (84 > 79 characters)

self._urlparams = coordinates
self._weather_data = metno.MetWeatherData(coordinates,
clientsession,
'https://aa015h6buqvih86i1.api.met.no/'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line too long (89 > 79 characters)

'msl': str(elevation),
}

async_add_entities([MetWeather(name, coordinates, async_get_clientsession(hass))])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line too long (86 > 79 characters)

@Danielhiversen
Copy link
Member Author

Still need to test it more locally

Daniel Iversen added 2 commits September 15, 2018 15:08
"""Initialise the platform with a data instance and site."""
import metno
self._name = name
self._urlparams = coordinates
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't used.

"""Start unavailability tracking."""
await self._fetching_data()

async def _fetching_data(self, *_):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename to _fetch_data.

Copy link
Member

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@MartinHjelmare
Copy link
Member

@Danielhiversen merge when you're happy with testing. 👍

async def async_added_to_hass(self):
"""Start fetching data."""
await self._fetch_data()
async_track_utc_time_change(self.hass, self._update, minute=31, second=0)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line too long (81 > 79 characters)

https://home-assistant.io/components/weather.met/
"""
import logging
from datetime import timedelta

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'datetime.timedelta' imported but unused

@Danielhiversen Danielhiversen merged commit aa76353 into dev Sep 20, 2018
@ghost ghost removed the in progress label Sep 20, 2018
@Danielhiversen Danielhiversen deleted the met_no branch September 20, 2018 08:32
@balloob balloob mentioned this pull request Sep 28, 2018
@home-assistant home-assistant locked and limited conversation to collaborators Feb 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants