Jc2k / aioeafm

Apache License 2.0
0 stars 3 forks source link

can't find station #2

Open IanAdd opened 4 years ago

IanAdd commented 4 years ago

You link us to the environment agency website to find the station we want, but the station I found and want is not in the dropdown list in the integration setup. What can I do? station of interest is: 'River Dee at Ironbridge' Thx PS The configuration information at https://www.home-assistant.io/integrations/eafm/ says 'UK Environment Ageny'. The HA integration list shows it as 'Environment Agency Flood Gauges'

Jc2k commented 4 years ago

Hi

In general it is best to post Home Assistant specific issues on the Home Assistant GitHub rather than on the libraries that it uses. I would have still seen it either way, but there is a triage system in place upstream that you are bypassing + other people may have been able to help.

I had trouble finding your river full stop. When I followed the link in the documentation and searched for the string your provided the website invited me to go away.

I managed to find it on this website which i believe is powered by the same API:

https://riverlevels.uk/dee-aldford-ironbridge-dee

I eventually went into the API directly to make sure your river was supported (here and found it is:

 { 
    "@id" : "http://environment.data.gov.uk/flood-monitoring/id/stations/067027_TG_127" ,
    "RLOIid" : "4173" ,
    "catchmentName" : "Dee" ,
    "dateOpened" : "1993-01-01" ,
    "easting" : 341800 ,
    "label" : "Ironbridge" ,
    "lat" : 53.134133 ,
    "long" : -2.871357 ,
    "northing" : 360020 ,
    "notation" : "067027_TG_127" ,
    "riverName" : "River Dee" ,
    "stageScale" : "http://environment.data.gov.uk/flood-monitoring/id/stations/067027_TG_127/stageScale" ,
    "stationReference" : "067027_TG 127" ,
    "status" : "http://environment.data.gov.uk/flood-monitoring/def/core/statusukcmf" ,
    "town" : "Aldford" ,
    "wiskiID" : "DEE067027"
  }

If my understanding is correct Home Assistant will use the "label" field in it's dropdown so you should be looking for just "Ironbridge".

I went back to the website from the documentation and tried again. This time i searched for Aldford. I found Ironbridge on the map and it took me here:

https://rloi.naturalresources.wales/ViewDetails?station=4173

It defaults to the "River level" tab, but you want the "Station details" tab. There you will see "Station name" is Ironbridge, matching my guess from looking at the API.

Alas, you are correct. This does indeed seem to be missing from the dropdown. Looking at what the API is returning vs what Home Assistant is showing, the API has ~4000 results but HA can only see ~2000 or so. Theres no filtering going on between calling the UI and between returning the results to Home Assistant. I missed this because the rivers i know in yorkshire seem to be present.

I thought maybe it was a HA limit on the dropdown, but its not. I can see the list is already truncated when its pushed to the front end.

Help updating the documentation is always appreciated. The typo will be corrected by https://github.com/home-assistant/home-assistant.io/pull/14546, but help expanding the documentation further would be appreciated.

Jc2k commented 4 years ago

(I'll try and dig in a bit deeper later)

Jc2k commented 4 years ago

We were actually applying a filter. So the API it actually calls is:

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

The numbers match. So for whatever reason the API doesn't consider your station to be Active. Yet it is shows as "Online" here and has recent data:

https://rloi.naturalresources.wales/ViewDetails?station=4173

And it also has recent data here:

https://riverlevels.uk/dee-aldford-ironbridge-dee

There are 5 stations with a status of "http://environment.data.gov.uk/flood-monitoring/def/core/statusukcmf" including yours. They are all in the Dee catchment area. That does not seem to be a documented state.

A "standard" active station has an @id like this:

http://environment.data.gov.uk/flood-monitoring/id/stations/L3404

Hitting it returns all the data for that station - and if the station has multiple sensors it means a single REST call to get them all. Here is the id for your station:

http://environment.data.gov.uk/flood-monitoring/id/stations/067027_TG_127

As you can see it is a 404.

It does have this URL:

http://environment.data.gov.uk/flood-monitoring/id/stations/067027_TG_127/stageScale

Which returns data but nothing useful that we could add a special case for.

So for whatever reason the Environment Agency API doesn't seem to work for:

My best guess is that they are valid stations but not real time for whatever reason. I don't think theres anything I can do here, unfortunately.

IanAdd commented 4 years ago

Thanks so much for your efforts.

I wonder if it is because they are in or managed by Wales? The source of the Dee and its flood management is in Wales.

https://rivers-and-seas.naturalresources.wales/

Any chance of getting data from there. There is a tab listing the data on their web site.

Ian

On Fri, 18 Sep 2020 at 18:50, Jc2k notifications@github.com wrote:

We were actually applying a filter. So the API it actually calls is:

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

The numbers match. So for whatever reason the API doesn't consider your station to be Active. Yet it is shows as "Online" here and has recent data:

https://rloi.naturalresources.wales/ViewDetails?station=4173

And it also has recent data here:

https://riverlevels.uk/dee-aldford-ironbridge-dee

There are 5 stations with a status of " http://environment.data.gov.uk/flood-monitoring/def/core/statusukcmf" including yours. They are all in the Dee catchment area. That does not seem to be a documented state.

A "standard" active station has an @id https://github.com/id like this:

http://environment.data.gov.uk/flood-monitoring/id/stations/L3404

Hitting it returns all the data for that station - and if the station has multiple sensors it means a single REST call to get them all. Here is the id for your station:

http://environment.data.gov.uk/flood-monitoring/id/stations/067027_TG_127

As you can see it is a 404.

It does have this URL:

http://environment.data.gov.uk/flood-monitoring/id/stations/067027_TG_127/stageScale

Which returns data but nothing useful that we could add a special case for.

So for whatever reason the Environment Agency API doesn't seem to work for:

  • Ironbridge
  • Lea Hall
  • Farndon
  • Manley Hall
  • Brynkinalt

My best guess is that they are valid stations but not real time for whatever reason. I don't think theres anything I can do here, unfortunately.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Jc2k/aioeafm/issues/2#issuecomment-694743435, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACQBSNKDY2IOIVWD3IU2LADSGMNPHANCNFSM4RRGE24A .

Jc2k commented 4 years ago

https://flood-warning.naturalresources.wales

Says this:

This improved Flood Warnings and Alerts service is currently unavailable. During the current introductory phase, Flood Warnings and Alerts will be available from 9am to 5pm on weekdays. From the end of October, the service will be live 24 hours a day, 7 days a week.

I can't really do very much to check this when it's actually available because I'll be at work.

I poked around and found this though:

https://api-portal.naturalresources.wales/docs/services/577521aed81b570928363e10/operations/577521e0d81b570928363e11

So eafm is for the EA flood monitoring API. If there is a Welsh version that's identical but with Welsh data it would make sense to add it.

But it looks like it's not the same API and then that means it's potentially a completely different HA integration - there would actually be very little to share.

You need to register to use it and there is a strict rate limit so I can't register on behalf of all HA users. Everyone would need to register and be able to put their token into HA.

It's looking more and more likely that it's technically possible but if it's another integration that's needed then time for me to do is likely to be a problem. It took months to get eafm through HA's tough code review process, heck it took a month to get through the queue. I barely have enough time to triage my GitHub tickets at the moment so it might be an api too far. But let me have a proper look at this when I've got a coffee.

Jc2k commented 4 years ago

Whats interesting is that there are at least 3 distinct categories on the page you found so far.

There are a handful of stations like Ironbridge that appear in the Environment Agency API but don't fully work. When you find them on the link you provided you get sent to to a .wales page here.

Then there are another bunch of stations which specfically mention the Environment Agency. There are 17 of those. These actually link directly to the environment agency UI here. These do appear in the environment agency API as is.

The remaining ones on the whole don't even appear in the environment agency list.

Unfortunately that last point really does drive home that you are probably looking at needing another integration entirely writing from scratch. Combined with the API key requirement we can't go from a generic way from the EA station list to hit different backends. So there woul be nothing shared by adding the Wales data to the Environment Agency integration, and at that point its not the Environment Agency integration.

It looks like someone came very close to adding it here: https://github.com/home-assistant/core/pull/34887

Very disapointed the EA doesn't at least aggregate these stations even if it doesn't operate them itself.

IanAdd commented 4 years ago

Thanks for your efforts, much appreciated. My interest is the safety on the Dee in Chester for rowing. Ian

On Sat, 19 Sep 2020 at 16:50, Jc2k notifications@github.com wrote:

Whats interesting is that there are at least 3 distinct categories on the page you found so far.

There are a handful of stations like Ironbridge that appear in the Environment Agency API but don't fully work. When you find them on the link you provided you get sent to to a .wales page here https://rivers-and-seas.naturalresources.wales/Station/4173?.

Then there are another bunch of stations which specfically mention the Environment Agency. There are 17 of those. These actually link directly to the environment agency UI here https://flood-warning-information.service.gov.uk/station/4035. These do appear in the environment agency API as is.

The remaining ones on the whole don't even appear in the environment agency list.

Unfortunately that last point really does drive home that you are probably looking at needing another integration entirely writing from scratch. Combined with the API key requirement we can't go from a generic way from the EA station list to hit different backends. So there woul be nothing shared by adding the Wales data to the Environment Agency integration, and at that point its not the Environment Agency integration.

It looks like someone came very close to adding it here: home-assistant/core#34887 https://github.com/home-assistant/core/pull/34887

Very disapointed the EA doesn't at least aggregate these stations even if it doesn't operate them itself.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Jc2k/aioeafm/issues/2#issuecomment-695174396, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACQBSNIV7YELDHWS4EFKSULSGRIDLANCNFSM4RRGE24A .