Lallassu / smhialert

Home Assistant SMHI Warnings & Alerts
MIT License
9 stars 9 forks source link

sensor unavailable #15

Closed EagleStClair closed 1 year ago

EagleStClair commented 1 year ago

Since a week or so my sensor.smhialert is just in state unavailable and the log only shows this error: 2023-01-16 08:47:39.441 ERROR (SyncWorker_6) [custom_components.smhialert.sensor] Unable to fetch data from SMHI. 2023-01-16 08:47:39.443 ERROR (SyncWorker_6) [custom_components.smhialert.sensor] 'approximateEnd' No changes done on my side other than updating home assistant. Might have been when updating to 2023.1 but I'm not sure.

Lallassu commented 1 year ago

I had this in the end of last year due to connection issues towards their servers.

Remote end closed connection without response

But after that it has worked fine and still does for me. However, I haven't upgraded hass for a while, maybe there is something with the latest versions.

fredriklj commented 1 year ago

I think this occurs when there is not 'approximateEnd' in the issued warning. I've seen it from time to time, and today I had the time to investigate a little closer. Here is one example:

{
    "id": 1213,
    "normalProbability": true,
    "event": {
        "sv": "Höga flöden",
        "en": "High water discharge",
        "code": "HIGH_FLOW",
        "mhoClassification": {
            "sv": "Hydrologi",
            "en": "Hydrology",
            "code": "HYD"
        }
    },
    "descriptions": [

    ],
    "warningAreas": [
        {
            "id": 2868,
            "approximateStart": "2023-01-15T23:00:00.000Z",
            "published": "2023-01-17T10:13:03.750Z",
            "normalProbability": true,
            "areaName": {
                "sv": "Hedströmmen",
                "en": "River Hedströmmen"
            },
            "warningLevel": {
                "sv": "Gul",
                "en": "Yellow",
                "code": "YELLOW"
            },
            "eventDescription": {
                "sv": "Höga flöden",
                "en": "High water discharge",
                "code": "HIGH_FLOW"
            },
            "affectedAreas": [
                {
                    "id": 19,
                    "sv": "Västmanlands län",
                    "en": "Västmanland County"
                }
            ],

We need to account for the possibility that the time frame of the issued warning is open..