RESTful sensor json help - Australian tide predictions (BOM)

No probs but I don’t feel I deserve that solution tag. it was @lolouk44 who solved the restful sensor problem.

1 Like

I’ll mark both as the solution, yours has a complete working example for others coming here.

This was my first post on the forum and it was a really positive experience. Thanks again. To the three of you @tom_l, SteveDinn and @lolouk44

1 Like

This is awesome. I was looking for this. I changed the location and it works. I also added this sensor:

hobart_tide_dir:
  entity_id: sensor.hobart_tides
  friendly_name 'Tide Direction'
  value_template: >-
    {% if (states('sensor.hobart_tides')|from_json).next_high.time|int < (states('sensor.hobart_tides')|from_json).next_low.time|int %}
      Rising
    {% else %}
      Falling
    {% endif %}

I couldn’t find anything from the API, but if there is a way to pull the previous tide high and low values, you could calculate the current tide since the tide cycle is of a predictable duration. If not, could you save the previous value?

This worked for me. Thanks for sharing.

Interesting. I stopped using it a while ago as I had no use for it. I thought the recently implemented BoM anti-scraping measures might have stopped it working.

Sorry I may have missed it but I can not find the details on BOM to change the location, I want to get the tides for Ettalong in NSW.

Would someone please be able to point me in the right direction

Also i was having a look at tides4fishing and really like the way they display the tides, is there any way to copy this over to home assistant.

To find what the URL needs to be for your location, go to http://www.bom.gov.au/australia/tides/ and select your location, then download one of the tide chart pdfs. The filename of the pdf will end with something like VIC_TP020 - substitute this with the URL and then change the timezone city as appropriate.

Hi Guys,

Cant get this URL to work for my location to save my life…
Anyone crack it for me? Will prob be bashing my head because its something simple…

http://www.bom.gov.au/australia/tides/scripts/getNextTides.php?aac=TAS_TP003&offset=false&tz=Australia%2FHobart

Location: Camp Cove, NSW
LOCATION: NSW_TP011
TZ: Sydney

New URL: http://www.bom.gov.au/australia/tides/scripts/getNextTides.php?aac=NSW_TP011&offset=false&tz=Australia%2FSydney

But that url is invalid and cannot figure out to save my life lol

Help appreciated :wink:

I’ve been able to get this working using that location:

rest:
  - resource: "http://www.bom.gov.au/australia/tides/scripts/getNextTides.php?aac=NSW_TP011&offset=false&tz=Australia%2FSydney"
    headers:
      User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36
      Content-Type: application/json
    sensor:
      - name: "Sydney Low Tide Height"
        value_template: "{{ value_json.results.next_low.height }}"
        unit_of_measurement: "m"
      - name: "Sydney High Tide Height"
        value_template: "{{ value_json.results.next_high.height }}"
        unit_of_measurement: "m"
      - name: "Sydney Low Tide Time"
        value_template: "{{ value_json.results.next_low.time | timestamp_local }}"
      - name: "Sydney High Tide Time"
        value_template: "{{ value_json.results.next_high.time | timestamp_local }}"
1 Like

Hi Dom,

Thanks for this… Works a charm

Only issue I see is time/date format reporting the follwoing “2023-06-21T22:28:00+10:00” for sensor

Cheers
G

It should just work using your local time/date as set in HA.

The time/date just comes through from the BOM as epoch time, so you should be able to pipe that to any format you want - change timestamp_local to any custom timestamp you want. The first couple of posts in this threat should be helpful: Convert date and time template