physje / waterinfo

Home Assistant custom component to use the Waterinfo API (Rijkswaterstaat, the Netherlands) to fetch measurements/observations for all kind of waterdata into a sensor
MIT License
8 stars 1 forks source link

entities on same station in 1 'device' or 'Service'? #3

Open Mariusthvdb opened 2 weeks ago

Mariusthvdb commented 2 weeks ago

Hi, thanks for your integration, been looking for some time for Water info in HA, so yes, definitely very nice you made this!

This is not an Issue (bug), more a Discussion / FR probably

having set up some data (sensors) for OS4b, I had hoped to see all available info in that single device/dienst (so all entities on the same station station) automatically, but believe we have to set each data point up individually?

I get this now:

Scherm­afbeelding 2024-09-24 om 08 25 56

so not sure if I am doing it correctly.

Cant we set up those stations in 1 go, and have the integration setup all datapoints (maybe disable those by default)? And all on that single 'Dienst' OS4b

as it is, it requires a lot of manual setting up, and not sure if this is the preferred way.

anyways, hope you can have a look

for a FR: would you be willing to add an option to link directly to the station more info like https://waterinfo.rws.nl/#/thema/Actueel%20Waterbericht/Oosterschelde-4%28OS4%29/details?parameters=Windsnelheid___20Lucht___20t.o.v.___20Mean___20Sea___20Level___20in___20m___2Fs

physje commented 2 weeks ago

First of all: yes, you added the sensors correctly. And yes, that is ugly if you have more sensors for the same locations. So a better/nicer way is indeed preferred.

Writing a home assistant integration is a steep learning curve, so I was already happy I succeded :)

I'm also not completely satisfied with the way of configuring (that you have to enter 2 obscure codes separately), so I am also thinking about a way to improve that. This could probably be included in that as well.

The "problem" is the less user-friendly API. As far as I know, you cannot request a location and then get all measurements back. I think we cannot avoid requesting all locations and then filtering. The next hurdle will be to do the data fetching, I am afraid that a DataUpdateCoordinator is needed for that. That will be a major change to the integration, so if it works at all, it will take me some time.

Your other suggestion, of a direct link, also sounds interesting (and apparently easier). I need to figure out if I can build/generate the URL based on data from the API. If that is possible, I need to figure out the possibilities to show that URL as a clickable link. Suggestions ?

Mariusthvdb commented 2 weeks ago

I've done this now in a card:

        card_type: iframe
        aspect_ratio: 100%
        url: >
          https://waterinfo.rws.nl/#/publiek/waterhoogte?center=595738.2557389276%2C5711921.911579281&zoom=4"

or as a panel:

- title: Water info
  path: water_info
  panel: true
  cards:

    - type: iframe
      url: https://waterinfo.rws.nl/#/publiek/waterhoogte?center=595738.2557389276%2C5711921.911579281&zoom=4

tbh, I didnt yet check if the url is made up of Api retrievable info....

if you need dev help, maybe hop over to the Discord develop channels and see what reponse you get there. https://discord.gg/C3ATFHfA

Nick Koston is the coordinator updater expert (@ Bdraco) so he might be willing to help you out there

there's also another core integration, called WAQI, that integrates via a certain station, and then creates all entities automatically on that station:

Scherm­afbeelding 2024-09-24 om 11 26 47

this integration recently was updated to use the config flow in the UI, and creates all individual entities for the data points.

Might be a good example of how to do that? the code owner Joost Lekkerkerker (@ joostlek) most likely is very willing to share his methods