Rudd-O / homeassistant-meteoswiss

:sun_behind_rain_cloud: :switzerland: Meteo Swiss Integration for Home Assistant (forked from websylv)
86 stars 10 forks source link

Some conversion errors shown in the Log #14

Closed Cutty6343 closed 10 months ago

Cutty6343 commented 1 year ago

Hello, Rudd-O

I get some annoying errors in the logs. It does not really affect the function, but you may want to know about this. It attached the parts of the logs , I set it in debug mode. BTW, I suspect it relates to another comment/issue posted a couple days ago.

homeassistant_log_MeteoSwiss.txt

Take care

pascalfleury commented 1 year ago

I do have the same issue, alas in my case most values returned seem to be of that '-' format (so currently it's mildly useful :-).

My station is Uetliberg (UEB). One 'fix' would be to catch the ValueError in the native_* float conversions, besides the current caught Exception. What I am not sure is if this indicates that there is no value that was measured (even though the website gives a value for most measures on UEB) or if there is something in the API that needs tweaking so that it delivers the data. (or if the hamsclient lib is the culprit ?)

One such log looks like this:

2023-05-05 11:46:37.707 ERROR (MainThread) [custom_components.meteo-swiss.weather] Unable to convert humidity value: [{'Station/Location': 'UEB', 'Date': 202305050930, 'tre200s0': '-', 'rre150z0': '-', 'sre000z0': '10.00', 'gre000z0': '638.00', 'ure200s0': '-', 'tde200s0': '-', 'dkl010z0': '-', 'fu3010z0': '-', 'fu3010z1': '-', 'prestas0': '-', 'pp0qffs0': '-', 'pp0qnhs0': '-', 'ppz850s0': '-', 'ppz700s0': '-', 'dv1towz0': '32.00', 'fu3towz0': '4.00', 'fu3towz1': '10.40', 'ta1tows0': '14.20', 'uretows0': '69.20', 'tdetows0': '8.60'}]
Traceback (most recent call last):
File "/config/custom_components/meteo-swiss/weather.py", line 158, in humidity
return float(self._condition[0]["ure200s0"])
ValueError: could not convert string to float: '-'
2023-05-05 11:46:37.717 ERROR (MainThread) [custom_components.meteo-swiss.weather] Error converting pressure (qfe): [{'Station/Location': 'UEB', 'Date': 202305050930, 'tre200s0': '-', 'rre150z0': '-', 'sre000z0': '10.00', 'gre000z0': '638.00', 'ure200s0': '-', 'tde200s0': '-', 'dkl010z0': '-', 'fu3010z0': '-', 'fu3010z1': '-', 'prestas0': '-', 'pp0qffs0': '-', 'pp0qnhs0': '-', 'ppz850s0': '-', 'ppz700s0': '-', 'dv1towz0': '32.00', 'fu3towz0': '4.00', 'fu3towz1': '10.40', 'ta1tows0': '14.20', 'uretows0': '69.20', 'tdetows0': '8.60'}]
Traceback (most recent call last):
File "/config/custom_components/meteo-swiss/weather.py", line 102, in native_pressure
return float(self._condition[0]["prestas0"])
ValueError: could not convert string to float: '-'
2023-05-05 11:46:37.717 ERROR (MainThread) [custom_components.meteo-swiss.weather] Unable to convert windSpeed value: [{'Station/Location': 'UEB', 'Date': 202305050930, 'tre200s0': '-', 'rre150z0': '-', 'sre000z0': '10.00', 'gre000z0': '638.00', 'ure200s0': '-', 'tde200s0': '-', 'dkl010z0': '-', 'fu3010z0': '-', 'fu3010z1': '-', 'prestas0': '-', 'pp0qffs0': '-', 'pp0qnhs0': '-', 'ppz850s0': '-', 'ppz700s0': '-', 'dv1towz0': '32.00', 'fu3towz0': '4.00', 'fu3towz1': '10.40', 'ta1tows0': '14.20', 'uretows0': '69.20', 'tdetows0': '8.60'}]
Traceback (most recent call last):
File "/config/custom_components/meteo-swiss/weather.py", line 171, in native_wind_speed
return float(self._condition[0]["fu3010z0"])
ValueError: could not convert string to float: '-'
2023-05-05 11:46:37.733 ERROR (MainThread) [custom_components.meteo-swiss.weather] Error converting temp: [{'Station/Location': 'UEB', 'Date': 202305050930, 'tre200s0': '-', 'rre150z0': '-', 'sre000z0': '10.00', 'gre000z0': '638.00', 'ure200s0': '-', 'tde200s0': '-', 'dkl010z0': '-', 'fu3010z0': '-', 'fu3010z1': '-', 'prestas0': '-', 'pp0qffs0': '-', 'pp0qnhs0': '-', 'ppz850s0': '-', 'ppz700s0': '-', 'dv1towz0': '32.00', 'fu3towz0': '4.00', 'fu3towz1': '10.40', 'ta1tows0': '14.20', 'uretows0': '69.20', 'tdetows0': '8.60'}]
Traceback (most recent call last):
File "/config/custom_components/meteo-swiss/weather.py", line 92, in native_temperature
return float(self._condition[0]["tre200s0"])
ValueError: could not convert string to float: '-'
2023-05-05 11:46:37.734 ERROR (MainThread) [custom_components.meteo-swiss.weather] Unable to convert humidity value: [{'Station/Location': 'UEB', 'Date': 202305050930, 'tre200s0': '-', 'rre150z0': '-', 'sre000z0': '10.00', 'gre000z0': '638.00', 'ure200s0': '-', 'tde200s0': '-', 'dkl010z0': '-', 'fu3010z0': '-', 'fu3010z1': '-', 'prestas0': '-', 'pp0qffs0': '-', 'pp0qnhs0': '-', 'ppz850s0': '-', 'ppz700s0': '-', 'dv1towz0': '32.00', 'fu3towz0': '4.00', 'fu3towz1': '10.40', 'ta1tows0': '14.20', 'uretows0': '69.20', 'tdetows0': '8.60'}]
pascalfleury commented 1 year ago

I wrote pull/16 that should solve part of this problem (when the inexistent values are '-' and therefore unparseable as float values).

Another issue is that some stations do not publish "ground-level temperatures" for example. UEB is on a mast at 80m above ground, so the actual value is stored in another column of that CSV, and the current library does not read it there.

I have a fix for the hamsclientfork library, though I am not sure how to test that properly :-)

Rudd-O commented 10 months ago

Should be fixed since a few days now. @Pascalfleury had a great fix, but by the time I noticed it, another had gone in already.

@pascalfleury let's discuss in this issue the matter of the mast temperatures — I am not sure I have fully understood that CSV file just yet.

pascalfleury commented 10 months ago

Hi! When the measuring station is not on the ground (as is the case for Uetliberg) they named the sensors differently. Eg. temperature at ground level is named 'tre200s0' and at 120m altitude above ground it is named 'ta1tows0'

The downloaded CSV looks like this: Station/Location;Date ;tre200s0; [...] ;ta1tows0;uretows0;tdetows0 UEB ;202311132210; -; [...] ; 11.90; 82.80; 9.10 PAY ;202311132210; 13.20; [...] ; -; -; -

Which shows the temperature in Payerne to be 13.2 degrees, and on the Uetliberg mast it is 11.90 degrees.

Here are my notes I took while exploring this HA plugin and the underlying data format: -----------8<---------------- The pulled information from the meteo station network is as a VQHA80 formatted CSV file. The value names are explained in this page: https://data.geo.admin.ch/ch.meteoschweiz.messwerte-aktuell/info/VQHA80_en.txt (also exists in _fr, _de, _it)

A useful post about these readings: https://www.sturmforum.ch/viewtopic.php?t=10161

Interestingly, there are provisions for sensors at different levels of the station. Uetliberg's weather station being on a huge antenna and 120m above the ground, it will list different sensors that other statins that are on the ground. This makes for several such values to be absent and other to be present.

My changes would be as follows:

  1. have a mapping from the cryptic VQHA80 value names to a more generic one in the hamsclientfork lib (so HA does not need to know about those)
  2. have the library apply a bit of logic, and read the temperature from the ground sensor if available, and from the alternative if needed, then also map it to the more generic name.

This would make it possible to have a generic name (eg. 'air_temperature') but also be able to use the original HAMS names should a user want those (and therefore is expected to know what they are more precisely).

On Sat, Nov 11, 2023 at 12:18 PM Rudd-O @.***> wrote:

Should be fixed since a few days now. @pascalfleury https://github.com/pascalfleury had a great fix, but by the time I noticed it, another had gone in already.

@pascalfleury https://github.com/pascalfleury let's discuss in this issue the matter of the mast temperatures — I am not sure I have fully understood that CSV file just yet.

— Reply to this email directly, view it on GitHub https://github.com/Rudd-O/homeassistant-meteoswiss/issues/14#issuecomment-1806788233, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABBP5KHEU3UDRDO5RX7LJXDYD5NI3AVCNFSM6AAAAAAWTXG3EWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMBWG44DQMRTGM . You are receiving this because you were mentioned.Message ID: @.***>