briis / weatherbit

The weatherbit integration adds support for the weatherbit.io web service as a source for meteorological data for your location.
MIT License
33 stars 7 forks source link

Alert sensor is not parsing data correctly #63

Open Anwen747 opened 2 years ago

Anwen747 commented 2 years ago

I recently updated to version 1.0.8 of the integration from an older version (pre 1.0). Today for the first time since I updated, an alert came up. The sensor for the alerts is not parsing the data correctly. I havedescription_english anddescription_local in the attributes. I am not sure why there are two description attributes as there is only one description field in the provided data.

Description string in original source data (shortened and with location redacted):

"description": "A period of snow will overspread xxxx xxxxx late\ntonight and early Thursday morning. Precipitation will likely be\nin the form of mainly rain [continues on, for several more sentences.]

In sensor.weatherbit_weather_alerts (with location redacted but not otherwise changed):

description_english: onight and early Thursday morning. Precipitation will likely be description_local: ' period of snow will overspread xxxx xxxxx late'

In other words,

description_local is giving me the first several words of the description string. missing the first character. The string starts and ends with single quotes.

description_english is giving me several words of the description string continuing from where description_local left off, also missing a first character. The rest of the description (which is most of it) is missing. There are no quotation marks at the start or end of the string.

It looks as though the /n characters in the original string may be part of the problem. I have saved the the full text of the original data and a screenshot of the sensor.weatherbit_weather_alerts information from Developer-States in Home Assistant, if that would be helpful to you. I do not want to post it here as it contains personal information.

I see from the other open issue that you are unavailable for a time, so I am aware there will be a delay in your looking at this issue. Congratulations on your new home.

briis commented 2 years ago

Hi @Anwen747 I am almost up and running - a house move takes more time than I anticipated  😁. The reason for the english and local description comes from the fact that in some countries the weather service supplies both a local language description and an english version, so I have tried to split the descriptions.

I now find that, depending on the Weather Authority, supplying the Weather Alerts, the format is different, so this gets complex. Next time you have an alert, could you post here, and supply a city/country, so that I can get the raw text that weatherbit supplies. Then I will try and see if I can make this work, also for you.

Anwen747 commented 2 years ago

Hi @briis - Thanks for your response, hope all is going well with the new house. I have been using a different integration for the weather alerts (NWS Alerts) which is working well for me (I am located in the US). I can still provide the information you requested, if you like, but I would prefer not to post my actual location here.

briis commented 2 years ago

but I would prefer not to post my actual location here.

Fully understand that. I will look at the NWS and find a place with a weather alert to get some data.