Jc2k / aioeafm

Apache License 2.0
0 stars 3 forks source link

UK data #3

Open ChipWolf opened 3 years ago

ChipWolf commented 3 years ago

Hey, I raised a feature request on the hass forums, but I reckon this is likely the place this would need to start.

It may be scope creep, but would it be possible to add riverlevels.uk's API as a data-source option? As they aggregate all the UK agencies in one place and provide an API, it gives us more of the UK data without integrating with each agency's open-data individually and "re-inventing the wheel".

Jc2k commented 3 years ago

Hello - i'm guessing you mean the home assistant forums. This library is specifically just a thin wrapper around the Environment Agency API so this is not really the place for such a feature request. I'd want to make a new package for this (if there isn't a wrapper already) that was dedicated to your API suggestion rather than shoehorn an unrelated API/service into this one.

On the HA front, I'm very annnoyed annoyed that the UK can't seem to provide a single data feed for this (tbh i thought i'd covered the whole UK, was gutted after the first ticket like this when i realised i hadn't). I'm interested in the API you suggested but it doesn't look like it updates as often (only daily?) so it's not a drop in replacement. At a glance, it also looks like it doesn't use the station ids, so migrating existing users of the integration wouldn't be straightforward. So i'm not sure that this is an update to the eafm integration, but instead a new one. But since HA added the update coordinator API this shouldn't be too hard - but I don't have much free time for eafm or homekit_controller right now so I definitely can't add another integration to my plate.

New integrations can take a while to get code reviewed, but if you go ahead with this approach (or someone on the forums does) tag me and i will give it a first pass while a more core reviewer is available.

ChipWolf commented 3 years ago

Hey, that sounds sensible. Perhaps the API I referenced isn't the best solution for this enhancement. Either way; most of SEPA's services are currently unavailable due to a ransomware attack they're making a huge fuss about, I'll have to revisit this again once they recover.

@Jc2k this is probably worth looking into though: I can see Scottish river levels on the UK Environment Agency's API but they don't populate in the UI; so, this may be the real issue.

Jc2k commented 3 years ago

I think the reason that it is visible is because it's a tide gauge not a river level gauge. I don't know what that means in terms of the data collected though. It is collected often (every 15 minutes) but only at 44 locations in the entire UK. It's run on behalf of UK Coastal Flood Forecasting which is why it covers more than England.

They don't seem to be part of the main flood monitoring API, so it would probably be cleaner to add a new integration on the HA side still.

ChipWolf commented 3 years ago

Perhaps yeah, it looks like River Levels use the Tidal Level. I guess it can be used interchangeably for most purposes if it's a value which could indicate a flood risk.

I don't understand why I can see Leith looking at the JSON in the browser, but the function which uses the same JSON endpoint doesn't seem to return the same object

Jc2k commented 3 years ago

So the reason you can't select it is it's not considered an active station, despite seemingly having recent data:

https://environment.data.gov.uk/flood-monitoring/id/stations?status=Active

ChipWolf commented 3 years ago

Ah, I'm guessing they don't apply the active flag to any of the data they import from the other agencies