gjohansson-ST / pytrafikverket

python module for communicating with the swedish trafikverket api
MIT License
22 stars 7 forks source link

Historical rain data #11

Open magma1447 opened 3 years ago

magma1447 commented 3 years ago

Would it be reasonable to add historical rain data from the fairly new endpoints in Trafikverket's API?

I am interested in data like:

By using a query like the below it can be exposed to things using this library. `

  <QUERY objecttype="WeatherObservation" schemaversion="1">
        <FILTER>
              <EQ name="Measurepoint.Name" value="Oxie" />
        </FILTER>
        <INCLUDE>Aggregated10minutes.Precipitation.RainSum.Value</INCLUDE>
        <INCLUDE>Sample</INCLUDE>
  </QUERY>

` (usable example at https://api.trafikinfo.trafikverket.se/Console)

I am thinking that this library could expose the data as:

  • mm rain per day
  • mm rain last 24h

It would then be up to next part to calculate and expose what I am really after, in my case Home Assistant. I assume @endor-force is the code-owner of that part as well, so I'll go ahead with my suggestion here, to get a better overview of my idea.

The Home Assistant sensor could then fetch this data with the same time-delta as it already does (every 10th minute). Or even less. The only data that needs frequent updates are "rain today" and "rain last 24h". The sensor could then store the amount of rain per date in its attributes as a list, and in turn in .storage/core.restore_state for persistence (I don't know if it ends up there automatically). There should probably be a config option added if this should be fetched, since it's one more API call, and also how many days of history to save.

If it doesn't sound like something you wish for in this library I will make some hack for myself with a less serious solution. My Python skills are way too low to figure this out sadly.

github-actions[bot] commented 4 days ago

There hasn't been any activity on this issue recently, so we clean up some of the older and inactive issues. Please make sure to update to the latest version and check if that solves the issue. Let us know if that works for you by leaving a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thanks!