jdejaegh / irm-kmi-ha

Home Assistant weather provider using data from Belgian IRM KMI 🇧🇪 🇱🇺 🇳🇱
MIT License
40 stars 0 forks source link

Warnings should be visible before they actually start #21

Closed schumi2309 closed 3 months ago

schumi2309 commented 4 months ago

hi, I am on the latest version, I am in Belgium, in Liège, where, for the moment, there is a yellow alert in the wind, but the alert sensor always tells me "secure" Is there anything to change or modify or is it a bug?

Capture d’écran 2024-04-15 à 11 33 24

Capture d’écran 2024-04-15 à 11 34 24

Capture d’écran 2024-04-15 à 11 37 18

there is indeed alert, so why tell me “secure”??

Capture d’écran 2024-04-15 à 11 41 24

jdejaegh commented 4 months ago

Hi, that's not a bug but I understand what you mean.

The alert starts at 2PM today (see starts_at: "2024-04-15T14:00:00+02:00") so the sensor will become "unsafe" at that time until ends_at (6PM).

The warning details are there because they are already available but the status is not active as the warning starts at 2PM.

You are not the first one to be surprised by the behavior, I'll consider adding a sensor "next warning starts in" showing when is the next warning starting. This way, people can create automation based on that.

schumi2309 commented 4 months ago

ok, I understand. I'll see what I can do to find a solution. On the other hand, I often lose the radar camera and especially the rain forecast information, which is listed under the "hint" section (see photo). and when that happens, I no longer have the video from the camera. So, it’s useless! Capture d’écran 2024-04-16 à 08 33 27

I created a sensor for rain information, and here is the result, works then, nothing!

Capture d’écran 2024-04-16 à 08 40 06

and it's common during the day, at certain times, I have the information, then, 10 minutes later, nothing. is this a server problem?

jdejaegh commented 4 months ago

I also noticed that the API of the IRM times out several times per day. When this happens, the integration cannot refresh the data and Home Assistant shows the sensors as 'unavailable' until a successful refresh. Those API timeouts may explain why you don't always get the camera hint.

To check if this the API timing out, you can open the logs of your Home Assistant (Settings > System > Logs) and look for those messages:

Error fetching IRM KMI weather data: Error communicating with API: Timeout error fetching information
Error fetching IRM KMI weather data: Error communicating with API: Error fetching information

When this happens, all the sensors of the integration go 'unavailable' for about 7 minutes (the polling interval).

I'll check if I can improve the integration to handle the timeouts when I have some time.

jdejaegh commented 4 months ago

I created a separate issue to track the timeouts issue.

I keep this issue to track the main question here: the warning not being shown ahead of time but only when it is truly active.

To investigate:

schumi2309 commented 4 months ago

The only one I see is this:

Capture d’écran 2024-04-16 à 19 52 48

jdejaegh commented 3 months ago

The changes related to the warnings have been merged into main. I tested the feature with unit tests but I'll wait until a real warning comes to see it in action before releasing it. The feature basically adds a timestamp sensor which show the start time or the next warning (or None if no warning are scheduled)