Tide Times

Great work. I was trying to work out how to do this with MQTT and found your contribution.

Is there any way to have the latest two tides showing? e.g. If was was low tide now, it would be great to see when the next high tide was too and vice versa. I know I can work it out but it would have a higher WAF with both displayed.

image

Check out the attributes and set them up as template sensors.

Thanks. I see both tide levels there so I’ll see if I can figure that out.

Keep us posted if you figure out how to do this, it will surely be helpful for others that are a little less talented … such as me.

Sorry on the road for a while, just create the template sensor for the attributes, if you don’t get it I can post my config later.

Should be something like:
state.device_id.attributes.low_tide…

1 Like

This is a complete configuration example. Fill in your API key, longitude and latitude. Please note that the worldtidesinfo sensor’s name is transformed into the entity id which in turn is required in the template sensor configuration.

sensor:
  - platform: worldtidesinfo
    api_key: <...>
    name: My Favourite Beach
    latitude: <...>
    longitude: <...>
  - platform: template
    sensors:
      tide_my_favourite_beach_next_high:
        value_template: '{{ as_timestamp(states.sensor.my_favourite_beach.attributes.high_tide_time_utc) | timestamp_custom("%a %d/%m/%Y %H:%M") }}'
        friendly_name: "My Favourite Beach Next High Tide"
      tide_my_favourite_beach_next_low:
        value_template: '{{ as_timestamp(states.sensor.my_favourite_beach.attributes.low_tide_time_utc) | timestamp_custom("%a %d/%m/%Y %H:%M") }}'
        friendly_name: "My Favourite Beach Next Low Tide"
5 Likes

@Coolie1101, @exxamalte. Thank you so much! That has saved me several hours trial and error. Very much appreciated.

Worked for me as well, thanks for sharing guys!

Hi, Does anyone know how I could use this to announce the next high tide 15 minutes before the high tide? I was thinking about a TTS component which would simply starte, “High tide in 15 minutes” and then have an automation which would use the condition of the time of the next high tide less 15 minutes…

Any ideas?

Hey @imikerussell thanks for this project.

I am new to this and still learning. I wanted to find out what does this command do that you have used:

sed 's/^.*: //'

Thanks.

sed is a standard Unix text editing/manipulation tool. It stands for Stream EDitor. Basically in the form used here it substitutes what is in the first group of / / with what is inside the second / /.

So it will search for every text matching the regular expression ^.*: and substitutes it with a zero length string.

My regular expression fu is weak, but I think the search string means look at the start of a line (^) followed by any character (.) repeated as many times as you like (*) followed by a colon (:). But don’t quote me on that - there are plenty of sed and regular expression tutorials on the web.

1 Like

Hey all,
So i’ve been using world tides for a while now but I have no idea how to convert the UTC time to Local time.
Can someone tell me how?

Have a look at my post above which shows how to create template sensors that convert the UTC timestamp, as long as you have correctly set your timezone in HA.

Oh Right sorry for the dumb question, I didn’t realize that what that code was doing.
Thanks heaps ill have a play with it now.

Please kindly check and correct for me as in the entity id. didn’t show the name given from worldtidesinfo.
in the entity id show the name from the template sensors with unknown state
Here is my configuration in sensor:

platform: worldtidesinfo
api_key: xxxxxxxxxxxxxxxxxxxxxxxxxxxx
name: Koh Samui Tide
latitude: 9.6
longitude: 100.067
platform: template
sensors:
  tide_big_buddha_beach_next_high:
    value_template: '{{ as_timestamp(states.sensor.koh_samui_tide.attributes.high_tide_time_utc) | timestamp_custom("%a %d/%m/%Y %H:%M") }}'
    friendly_name: "Big Buddha Beach Next High Tide"
  tide_big_buddha_beach_next_low:
    value_template: '{{ as_timestamp(states.sensor.koh_samui_tide.attributes.low_tide_time_utc) | timestamp_custom("%a %d/%m/%Y %H:%M") }}'
    friendly_name: "Big Buddha Beach Next Low Tide"

When you carefully compare your configuration with my example above you will see that yours is missing some rows, some indentations, and dashes.

Try this with your personal API key:

sensor:
  - platform: worldtidesinfo
    api_key: xxxxxxxxxxxxxxxxxxxxxxxxxxxx
    name: Koh Samui Tide
    latitude: 9.6
    longitude: 100.067
  - platform: template
    sensors:
      tide_big_buddha_beach_next_high:
        value_template: '{{ as_timestamp(states.sensor.koh_samui_tide.attributes.high_tide_time_utc) | timestamp_custom("%a %d/%m/%Y %H:%M") }}'
        friendly_name: "Big Buddha Beach Next High Tide"
      tide_big_buddha_beach_next_low:
        value_template: '{{ as_timestamp(states.sensor.koh_samui_tide.attributes.low_tide_time_utc) | timestamp_custom("%a %d/%m/%Y %H:%M") }}'
        friendly_name: "Big Buddha Beach Next Low Tide"

my sensor: is in individual file so the space and dash is from the one I posted above. Sorry for my bad english, I don’t understand much. But I will try to explain.

What I don’t understand is the one in the template (value_template). you said that the state sensor name will be the name from the worldtidesinfo (koh_samui_tide)? not from the entity id from template sensor (sensor.tide_big_buddha_beach_next_high_tide)?

value_template: '{{ as_timestamp(states.sensor. koh_samui_tide.attributes.high_tide_time_utc) | timestamp_custom("%a %d/%m/%Y %H:%M") }}'
friendly_name: "Big Buddha Beach Next High Tide"

    value_template: '{{ as_timestamp(states.sensor.tide_big_buddha_beach_next_hight.attributes.high_tide_time_utc) | timestamp_custom("%a %d/%m/%Y %H:%M") }}'
    friendly_name: "Big Buddha Beach Next High Tide"

Regarding for the date time in red that you mention. Do I have to change anything ?

I got it working now. I have to seperate every platform into individual .yaml file.
Thank you very much Mr.exxamalte ^^

1 Like

Hiya,

All of a sudden I am seeing “unknown” as the next high tide. I have chjecked my API and it is still triggering counts at worldtides side.

Any ideas?

Thanks

We have reached the limit of usage ^^