Weatherbit.io - Current Weather and Forecast data

Release 0.11

Made some changes. Just update the files through HACS or Manually and restart HA - no need to re-add the Integration.

  • Changed Imperial Wind Unit from mi/h to mph
  • Fixed Rain value not displaying correctly when Imperial units
  • Changed Forecast for Weather and Sensor to start with Current Day.
4 Likes

Thanks for this, great work! In terms of the recent change to create sensors, for me that’s a better approach. However, Dark sky currently creates sensors for each attribute and each day i.e. precipitation0d, precipitation1d, windspeed0d, windspeed1d whereas your implementation creates a “day” sensor with each of the items as attributes. Personally I prefer the Dark Sky approach as they I just refer to the sensors, but interested to hear thoughts?

@briis Thanks so much for including the current day forecast. Unfortunately, I think there is still something wrong about the way this is implemented with the dates. This is my stock weather card after the update:

weathermon

Today is Monday. The card doesn’t show the current day high/low under the temperature because it doesn’t know what it is. I shouldn’t see Sunday in the forecast, it’s past. Sunday has the Monday - ie current - data in it; Monday is showing Tuesday’s data, etc.

I also have bramkragten’s custom weather card installed, and it shows the data incorrectly in the same way.

bramweather

@rsachoc I made a pile of template sensors to pull the forecast highs and lows out when I was trying to make this work with the custom Dark Sky weather card, so it is possible to make the sensors you want yourself. I agree it would be easier if the sensors were already created in this way by the custom component. There just needs to be some sanity on how many sensors - 16 days of forecast data sensors would be unnecessary in my opinion. But I don’t know how much work this would be for @briis, and what his philosophy is on how he created the component.

1 Like

Thank you for creating this integration. Just installed it for the first time today and I have the same problem as @Anwen in that today is Monday and it’s starting with Sunday.

2 Likes

To chime in, same with me, just noticed based on the above posters!

1 Like

Hi all,
I belive I found the error. All text based dates in the raw data are UTC time, and I need to get those converted to Local Timezone, which then will fix the wrong weekday issue. I hope to have this done some time tomorrow.

With regards to the sensor, and one sensor per value per forecast day. It is doable, but will of course create a lot of sensors in your system. Honestly I don’t use the sensors, as I have a personal Weatherstation, that I read through another Integration I wrote - so I am happy to do one or the other.

I will work on correcting the dates and let you all know when done.

2 Likes

That’s great - thanks so much for both your work on this, and your responsiveness!

Before sensors were created inside this integration, I created set of sensors for forecast to be able to feed data to weather card build from individual components. Below is code for one day set (as it is right now it will retrieve forecast for today). It can be easity adjusted to following days just by changing index (so all ‘0’ to ‘1’ and so on…) and adjusting sensor name. These sensors also include icons for overal condition (also considering partly cloudy night). I did not created sensors for wind, as I do not use it, but this should be easy to create from other one by analogy:

sensor:
  - platform: template
    sensors:
      temp_max_0:
        friendly_name: 'Temerature Forecast max 0'
        value_template: "{{ state_attr('weather.weatherbit_zielonka', 'forecast')[0].temperature }}"
        unit_of_measurement: '°C'
      temp_min_0:
        friendly_name: 'Temerature Forecast min 0'
        value_template: "{{ state_attr('weather.weatherbit_zielonka', 'forecast')[0].templow }}"
        unit_of_measurement: '°C'
      condition_0:
        friendly_name: 'Condition Forecast 0'
        value_template: "{{ state_attr('weather.weatherbit_zielonka', 'forecast')[0].condition }}"
        icon_template: >
          {% set stat = state_attr('weather.weatherbit_zielonka', 'forecast')[0].condition %}
          {% if stat == 'clear-night' %} mdi:weather-night
          {% elif stat == 'cloudy' %} mdi:weather-cloudy
          {% elif stat == 'exceptional' %} mdi:weather-sunny-alert
          {% elif stat == 'fog' %} mdi:weather-fog
          {% elif stat == 'hail' %} mdi:weather-hail
          {% elif stat == 'lightning' %} mdi:weather-lightning
          {% elif stat == 'lightning-rainy' %} mdi:weather-lightning-rainy
          {% elif stat == 'partlycloudy' %} mdi:weather-partly-cloudy
          {% elif stat == 'pouring' %} mdi:weather-pouring
          {% elif stat == 'rainy' %} mdi:weather-rainy
          {% elif stat == 'snowy' %} mdi:weather-snowy
          {% elif stat == 'snowy-rainy' %} mdi:weather-snowy-rainy
          {% elif stat == 'sunny' %} mdi:weather-sunny
          {% elif stat == 'windy' %} mdi:weather-windy
          {% elif stat == 'windy-variant' %} mdi:weather-windy-variant
          {% else %} mdi:cloud-question
          {% endif %}
      precip_0:
        friendly_name: 'Precipitation Forecast 0'
        value_template: "{{ state_attr('weather.weatherbit_zielonka', 'forecast')[0].precipitation }}"
        unit_of_measurement: 'mm'

Finally at the moment my weather looks like on the screenshot below. For current conditions I do use data from Netatmo Weather Station:
Screenshot 2020-06-01 at 10.29.17

2 Likes

Thank you for your great work! I think for now it’s probably better if you leave the single sensor per day and if people want they can create their own forecast sensors. More flexible, but a little more upfront work! Thanks again!

Hi All,
This took a bit longer than I expected, but handling dates and timezones, is more complicated than I thought. In the end I had to actually read the Developer Docs :grinning: and this Integration now conforms to the way HA expects it to. The Weather Entity always expects a DateTime entry in UTC, where as I had to convert the time for the Sensor to be Location Aware as this is not handled by Home Assistant.

I have done numerous tests, and in the end it boils down to the Timezone you have set on your Computer, if the Days are displayed correctly. So if you add a Weather Entity for the same Timezone as your Computer is set to, it should display correct, but if it is a location in a different Timezone, the days might not be correct for parts of the day.

Let me know how this goes.

Release 0.12

  • Weather Entity now reports datetime as UTC Date time in RFC 3339 format, which is what the Lovelace Weathercard expects.
  • Sensor Entity now reports datetime as Location aware Date time in RFC 3339 format.
  • Bumped weatherpypi to 0.13
2 Likes

Agree. And unless I get massive requests, I will leave it as is.

I “think” there is a bug with visibility. Mine always shows 3 miles and I’ve seen similar in other posts. Here is a screenshot:

weatherbit

I can’t really verify if it’s a bug in the python code or an issue with the API (as I can’t easily see the underlying data).

I just tested 8 different locations spread across the Globe, and unfortunately they all report 3mi or 5km. So I must conclude that the raw data we get from weatherbit always include that number. Maybe it would help if this was reported to weatherbit?

@briis Dates are working now! Thanks for figuring all that out! I agree with your decision on the sensors, but could I ask you to make just one more? There is a text description field in the current API:

"weather":{"icon":"c02d","code":"801","description":"Few clouds"}

and it would be great to have that text string (e.g.“Few clouds”) for a custom weather card.

My current visibility is 5 if I look at the API data as well.

@ffeingol If you want to see the raw weather data, you can look at the API data yourself. The documentation for the API is here: https://www.weatherbit.io/api. Scroll down and click on the green Documentation button for whichever data you are interested in. For example, if you choose Current Weather, and scroll down the page a bit, it gives an example API call:

https://api.weatherbit.io/v2.0/current?city=Raleigh,NC&key=API_KEY

Replace Raleigh,NC with your city and API_KEY with your API key, and paste that link into a browser. It will return the data is JSON format. If your city doesn’t work, you could also use latitude and longitude with

https://api.weatherbit.io/v2.0/current?lat=XXXX&lon=YYYY&key=API_KEY

1 Like

I’ll be happy to do that. I know it’s really outside the scope of this, but if you can give me an example of how to call the API via curl I could report it a lot easier. If not, I totally understand. Just read the next post and that was all I needed.

2 Likes

This is an all round brilliant alternative to Dark Sky. Thanks for your work on this!

1 Like

I will add that sensor as soon as possible.

1 Like

I wonder if you could give me a list of all the possible forecasts, i.e cloudy, sunny, rainy etc?
It would be a big help for my lovelace UI.

https://www.weatherbit.io/api/codes

Thank you. But I need to know the exact wording of what appears in the sensors. For instance, in the link you supplied, although there are ‘few clouds’, ‘broken clouds’ etc there is no ‘cloudy’, which is what appears in the sensors.