briis / smartweather

WeatherFlow Smart Weather Component for Home Assistant
MIT License
108 stars 11 forks source link

Replace DarkSky with Tempest Forecast #35

Closed max-rousseau closed 4 years ago

max-rousseau commented 4 years ago

@briis since the Tempest now has forecasting data, I'm looking at trying to adapt the weather entity such that it pulls forecasting data from the Tempest API rather than the soon to be dead DarkSky. I did a quick POC and it seems to work but I don't have as much experience in HA so my WeatherEntity isn't mapping to the right icons and such.

Any interest in going this route rather than remove the weather entity altogether?

briis commented 4 years ago

Hi there, I could do that, but I looked through the API reference on https://weatherflow.github.io/SmartWeather/api/ and I cannot find the description for Forecast data - Where did you find that?

max-rousseau commented 4 years ago

It is indeed not documented as they said its still in beta phase however I've got a unique knack for figuring out undocumented APIs and I have figured out how to utilize the beta API to pull forecast data. I'm looking to clean up my POC code a little and then I can push a branch for you to look at. Once the Data feeder object works, the rest (i imagine) would be really easy for you.

max-rousseau commented 4 years ago

Meanwhile if you want to try it, the crux is this:

        baseurl = 'https://swd.weatherflow.com/swd/rest/better_forecast?station_id={}&api_key={}&lat={}&lon={}'`
        url = baseurl.format(self._pws_id, self._api_key, self._latitude, self._longitude)
        with async_timeout.timeout(10, loop=self._hass.loop):
            response = await self._session.get(url, headers=headers)
        tmpest_data = await response.json()
briis commented 4 years ago

This is not difficult to do. I all ready made some tests with the API, and I can see it delivers both Daily and Hourly forecast data. I will have some time to work on this next week, where I will give the whole IO module an update at the same time.
Thanks for sharing

max-rousseau commented 4 years ago

Awesome, I have some time this week to mess with it a little bit and I'll commit my ugly code if you want to use it. Might save you a few minutes of mapping the properties between hass > tempest.

Might also want to be aware of what dsj mentions on the weatherflow forum: https://community.weatherflow.com/t/forecast-api-software/1003/38

Once they release the official version, some code tweaks may be needed.

briis commented 4 years ago

Please share whatever you have - everything you do, I don't have to again, so that is great. I just skimmed the link you posted, and can see that, we might get a working model now, but soon we will need to get a different authorisation model - but let us cross that river when we get to it.

max-rousseau commented 4 years ago

Here you go, I put the code on this PR (hope you dont mind) https://github.com/briis/smartweather/pull/36

Feel free to change anything. I didn't delete code but commented it out to leave you the final call.

briis commented 4 years ago

The V2.0 branch is now merged in to the master branch, and I will work on this from now on. If you have changes, please feel free to change directly here also.

I will update the documentation before I release it to HACS, for more people to test and find bugs.

briis commented 4 years ago

Hi @max-rousseau Finally I got to updating the Docs, so I have now officially released this as V2.0.2. Please let me know if you find any errors. I am closing this topic now.