Uslakes.info integration to track water levels

Hi, I’m looking to create a dashboard using the updated lake levels from a lake nearby. I know there is not an existing integration with uslakes.info but I’m looking to achieve this another way. Anyone have an idea how I can achieve this? Thanks in advance!

Clear Lake Water Level - page outputs information below:

It appears that the graph you see is made from data fetched from this URL: http://clear.uslakes.info/LevelDataJSON.asp?SiteID=CA012

This URL returns a JSON response which is good news because there is the rest integration that could process the data. However, it seems as if that site and its data hasn’t been updated since May 2022, so maybe this is a dead-end?

1 Like

Thanks for figuring that out. Yes that lake data seems not to be updated but other lakes are. I used Clear Lake as an example.

Here’s another example that does show current data.

Which REST integration in HA to use for this?

Ah, I see. For that the lake the data comes from https://folsom.uslakes.info/LevelDataJSON.asp?SiteID=CA021 and it does indeed have current data.
I would use this rest integration, but it requires a more complicated template to find the correct value. Some people may recommend the scrape integration to extrac today’s value directly from the HTML on the website, but I’m not a huge fan of website scraping, so I’d stick with extracting data from the JSON response.

You can use this as a starting point:

rest:
  - resource: https://folsom.uslakes.info/LevelDataJSON.asp?SiteID=CA021
    scan_interval: 14400
    sensor:
      - name: Folsom Lake Water Level
        unit_of_measurement: ft
        value_template: >-
          {% set today = now().strftime('%Y-%m-%d') %}
          {% for entry in value_json.charts %}
            {% if entry.date == today %}
              {{ entry['2023'] }}
            {% endif %}
          {% endfor %}

I’m not sure how often the data is updated - looks like once a day - and if that is updated each day around the same time, instead of using scan_interval you could write an automation that updates this sensor just after the value is expected to have updated.
Also, the above code does not contain any error handling, for example if there is no value yet for today.

1 Like