BJReplay / EPA_AirQuality_HA

A Home Assistant custom component for reading air quality data from the EPA Victoria (Australia) Environment Monitoring API
Apache License 2.0
2 stars 1 forks source link

Missing local station #12

Open loryanstrant opened 1 week ago

loryanstrant commented 1 week ago

Woohoo! First issue, and it's a doozy! :-)

I've just installed the HACS component, rebooted, and went to configure the integration, but unfortunately my local polling site doesn't show up (I'm in Sunbury, and Melton is about 30mins drive away:

image

Now, the issue is that the polling site itself is most likely offline, as my original method of accessing the EPA VIC API is still in action, but has been showing this all day: image

So most likely the integration is returning Melton as it's the closest online station, but it would be nice if I could potentially put my own site ID (if known) and then it creates the sensors which probably would stay unavailable until it comes back online again.

As for right now, I'm in a state where I don't want to finish the configuration until my local site comes back online so that it shows up in the list.

github-actions[bot] commented 4 days ago

This issue is stale because it has been open 7 days with no activity. Remove stale label or comment or this will be closed in 2 days.

BJReplay commented 4 days ago

Sorry I didn't see this earlier.

Mad week last week.

Solar system failed, so tried to fix it 🤣 then getting quotes to replace.

There is logic to only list stations that have readings.

Will consider how to address.

BJReplay commented 4 days ago

I've realised my notification settings for this repo were completely wrong (my issues and mentions only 🤣), but I wasn't checking it as noted above.

So, the logic to build the list looks like this:

                                if site_type in (
                                    SITE_TYPE_SENSOR,
                                    SITE_TYPE_STANDARD,
                                ):  # If it isn't a camera
                                    if (
                                        record.get(SITE_HEALTH_ADVICES)[0] is not None
                                    ):  # Get Health Site Advices
                                        siteHealthAdvices = record[SITE_HEALTH_ADVICES][
                                            0
                                        ]
                                        if (
                                            siteHealthAdvices.get(HEALTH_PARAMETER)
                                            is not None
                                        ):  # If site has a Health Parameter

Where it's failing is, as you note, at the time of building the list, there are no health parameters.

If I check right now, I can't include Mildura:

        {
            "siteID": "48b39f0a-0ea6-4016-b8f2-23adbc72897a",
            "siteName": "Mildura",
            "siteType": "Sensor",
            "geometry": {
                "type": "Point",
                "coordinates": [
                    -34.1635132,
                    142.139374
                ]
            },
            "siteHealthAdvices": [
                {
                    "since": "2024-11-30T21:00:00Z",
                    "until": "2024-11-30T22:00:00Z"
                }
            ]
        },

but can include Sunbury

        {
            "siteID": "07967f24-444c-4fd8-901c-9c0c67144053",
            "siteName": "Sunbury",
            "siteType": "Sensor",
            "geometry": {
                "type": "Point",
                "coordinates": [
                    -37.58954,
                    144.719727
                ]
            },
            "siteHealthAdvices": [
                {
                    "since": "2024-11-30T21:00:00Z",
                    "until": "2024-11-30T22:00:00Z",
                    "healthParameter": "Particles",
                    "averageValue": 4.5,
                    "unit": "µg/m³",
                    "healthAdvice": "Good",
                    "healthAdviceColor": "#42A93C",
                    "healthCode": "9999"
                }
            ]
        },

I think I can work around it to show stations without current health parameters. The question is whether to do that as another step (warning users that they can set up the integration, but not add anything useful to their dashboards until the sensors start reading again), which might be a nicer experience, but does complicate the flow, or simply add an asterisk to the name in the list (and a note on the dialog) indicating that the site may not work as currently has no health sensors. Simpler code path.

What are your thoughts on the best way forwards, @loryanstrant?