Weatherbit.io - Current Weather and Forecast data

The data for these sensors come from the Forecast API, it is the Current data that fails. Please try the Fix above, to see if this gets you going.

you’re fast!
fixed :+1:
everything is back

1 Like

Thanks @briis! Fast and effective! It’s working again :+1:

1 Like
weatherbitpypi==0.24.3

did the trick for me on 2 independant instances => trested and aproved, ready for productive deployment.

Cheers, Andi

1 Like

Log Details (WARNING)

Logger: homeassistant.helpers.entity
Source: helpers/entity.py:284
First occurred: 7:09:46 AM (2 occurrences)
Last logged: 12:52:53 PM

  • Updating state for sensor.weatherbit_wind_direction (<class ‘custom_components.weatherbit.sensor.WeatherbitSensor’>) took 0.422 seconds. Please report it to the custom component author.
  • Updating state for weather.weatherbit_maassluis (<class ‘custom_components.weatherbit.weather.WeatherbitWeather’>) took 0.455 seconds. Please report it to the custom component author.

I’ve received this Warning couple of times last few days, any idea what could be the reason for it?

Hi Erik,
I assume that you don’t get an unavailable state for the sensors or weather entity? There is not a lot of processing going on inside the Integration itself, it mostly just pulls data from weatherbit, and presents it. So my only guess is that the connection from you to weatherbit, is lagging somehow.

Thanks for the, as usual, quick reply! :wink:
Indeed no unavailable state for the sensors or weather entity.
I’ll keep an eye on it to see if it always happens at the same time which might be indicating something is causing it.
Thanks again.

Deal. If it continous, try adding some debug to see if this gives more info. Add this to your configuration.yaml:

logger:
  default: error
  logs:
    custom_components.unifiprotect: debug

Started getting these errors in my log today, an idea whats causing them ?

2020-07-01 16:33:55 ERROR (MainThread) [custom_components.weatherbit] Unexpected error fetching weatherbit data: 'ClientConnectorError' object has no attribute 'message'
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/aiohttp/connector.py", line 936, in _wrap_create_connection
    return await self._loop.create_connection(*args, **kwargs)  # type: ignore  # noqa
  File "/usr/local/lib/python3.7/asyncio/base_events.py", line 962, in create_connection
    raise exceptions[0]
  File "/usr/local/lib/python3.7/asyncio/base_events.py", line 949, in create_connection
    await self.sock_connect(sock, address)
  File "/usr/local/lib/python3.7/asyncio/selector_events.py", line 473, in sock_connect
    return await fut
  File "/usr/local/lib/python3.7/asyncio/selector_events.py", line 503, in _sock_connect_cb
    raise OSError(err, f'Connect call failed {address}')
TimeoutError: [Errno 110] Connect call failed ('54.39.183.126', 443)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/weatherbitpypi/client.py", line 258, in async_request
    method, f"{BASE_URL}/{endpoint}"
  File "/usr/local/lib/python3.7/site-packages/aiohttp/client.py", line 1012, in __aenter__
    self._resp = await self._coro
  File "/usr/local/lib/python3.7/site-packages/aiohttp/client.py", line 483, in _request
    timeout=real_timeout
  File "/usr/local/lib/python3.7/site-packages/aiohttp/connector.py", line 523, in connect
    proto = await self._create_connection(req, traces, timeout)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/connector.py", line 859, in _create_connection
    req, traces, timeout)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/connector.py", line 1004, in _create_direct_connection
    raise last_exc
  File "/usr/local/lib/python3.7/site-packages/aiohttp/connector.py", line 986, in _create_direct_connection
    req=req, client_error=client_error)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/connector.py", line 943, in _wrap_create_connection
    raise client_error(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host api.weatherbit.io:443 ssl:None [Connect call failed ('54.39.183.126', 443)]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 136, in async_refresh
    self.data = await self._async_update_data()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 124, in _async_update_data
    return await self.update_method()
  File "/usr/local/lib/python3.7/site-packages/weatherbitpypi/client.py", line 47, in async_get_current_data
    return await self._get_current_data()
  File "/usr/local/lib/python3.7/site-packages/weatherbitpypi/client.py", line 73, in _get_current_data
    json_data = await self.async_request("get", endpoint)
  File "/usr/local/lib/python3.7/site-packages/weatherbitpypi/client.py", line 266, in async_request
    if err.message == "Forbidden":
AttributeError: 'ClientConnectorError' object has no attribute 'message'


I got the same errors - the root cause I cannot do a lot about, as it is weatherbit’s service being unavailable. But the error handling should be better. I have just released a fix for that. It should show up soon in HACS as v0.27.

Brilliant, thanks

Don’t update yet. It did not fix the errors.
/B

This is not working for me. It says none.

{{ state_attr('weather.weatherbit', 'forecast')[0].condition }}

This works though, but it gives all the forecast starting with Day 1 - Day 7. Unfortunately, forecast do not provide today’s weather condition, but on Day 1. How do I find today’s current condition??

{{ state_attr('weather.weatherbit_shimotoda', 'forecast')[0].condition
        in ('cloudy', 'partlycloudy', 'rainy') }}

Release 0.29 is out which should now handle errors much better, when Weatherbit cannot be contacted upon startup. The Integration will now retry several times with different intervals.
You should also not see these Crash Errors in the Log file anymore.

OK, I’ll give it a try, thanks

Did you try this, seems to reflect my current conditions:

{{ state_attr('weather.weatherbit_XXXXXX', 'alt_condition') }}

There is also a cloudiness attribute, maybe that could be used ?

Try this instead:

{{ states.weather.weatherbit_shimotoda.attributes.forecast[0].condition 
in ('cloudy', 'partlycloudy', 'rainy') }}

I’d avoid that as stated in the documentation:

Avoid using states.sensor.temperature.state , instead use states('sensor.temperature') . It is strongly advised to use the states() , is_state() , state_attr() and is_state_attr() as much as possible, to avoid errors and error message when the entity isn’t ready yet (e.g., during Home Assistant startup).

Also, just noticed that my current weather condition is not then same as the first forecast day (today) so it will probably best to use the current conditions and not the forecast ?

using 29, I still see this unfortunately:

2020-07-02 12:51:41 ERROR (MainThread) [custom_components.weatherbit] Unexpected error fetching weatherbit data: Error requesting data from https://api.weatherbit.io/v2.0/forecast/daily?lat=lat6&lon=4lon3&lang=nl&units=M&key=8redacted8: None
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/weatherbitpypi/client.py", line 258, in async_request
    method, f"{BASE_URL}/{endpoint}"
  File "/usr/local/lib/python3.7/site-packages/aiohttp/client.py", line 1012, in __aenter__
    self._resp = await self._coro
  File "/usr/local/lib/python3.7/site-packages/aiohttp/client.py", line 504, in _request
    await resp.start(conn)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/client_reqrep.py", line 847, in start
    message, payload = await self._protocol.read()  # type: ignore  # noqa
  File "/usr/local/lib/python3.7/site-packages/aiohttp/streams.py", line 591, in read
    await self._waiter
aiohttp.client_exceptions.ServerDisconnectedError: None

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 136, in async_refresh
    self.data = await self._async_update_data()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 124, in _async_update_data
    return await self.update_method()
  File "/usr/local/lib/python3.7/site-packages/weatherbitpypi/client.py", line 50, in async_get_forecast_daily
    return await self._get_forecast_daily()
  File "/usr/local/lib/python3.7/site-packages/weatherbitpypi/client.py", line 121, in _get_forecast_daily
    json_data = await self.async_request("get", endpoint)
  File "/usr/local/lib/python3.7/site-packages/weatherbitpypi/client.py", line 269, in async_request
    raise RequestError(f"Error requesting data from {BASE_URL}/{endpoint}: {str(err)}")
weatherbitpypi.errors.RequestError: Error requesting data from https://api.weatherbit.io/v2.0/forecast/daily?lat=lat6&lon=lon3&lang=nl&units=M&key=8redacted8: None

use the square brackets for the condition list:

{{ state_attr('weather.weatherbit_shimotoda', 'forecast')[0].condition
        in ['cloudy', 'partlycloudy', 'rainy'] }}

note I didnt check the correct working since my integration is offline now, I merely corrected the syntax

edit

actually, my post was not correct… both should work. pardon me please

1 Like