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.
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"
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…
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.
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.
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"
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 ?