Do you think that it would be feasible to fetch date from this website? http://www.ukho.gov.uk/easytide/EasyTide/SelectPort.aspx
@ianByrne has now built an integration for UKHO Tide information which I can confirm works really well.
See the repo here: https://github.com/ianByrne/HASS_Integration_UKHOTides
Awesome. Many thanks @ianByrne and @jtnn60!
Is there any lovelace addon which can display information from this integration?
The sensor exposes a list of high/low tide times as an attribute, which can then be plugged into a 3rd party addon. In the docs I outline some steps on how to display a chart of the tide curves using ApexCharts
Hi Ian …thanks for the work on the add on …I am fairly new to HA - struggling to understand how you got the attributes in to the card as pictured …I have the integration working - but can only get the 'Tidestation Name — Rising (or falling) …I am getting the prediction attributes but can’t for the life of me figure how to build the card as you have.
Hi Ian - sorry to hear you’re running into some troubles. Unfortunately that screenshot is from an older version of the integration - as you’ve found, the same view in the current version will instead show a whole bunch of predictions there. However, right at the bottom of that list you should still be able to find those pictured attributes.
If your end goal is to display a card on a dashboard with just those attributes, you might like to look into something using templates and the state_attr
function to pick out the individual attributes you would like to display. Let me know how you go or if you would like more detailed examples.
Cheers,
Ian
I had a play around with this and it looks like it might be even easier than mucking about with templating. I’ve updated the docs on the repo with an example, but in a nutshell you can add a new card to your dashboard and scroll right down to the bottom of the options to select Manual, then paste the following YAML (be sure to tweak for your sensor name and which attributes you would like):
type: entities
entities:
- entity: sensor.hammersmith_bridge_tide
name: Tide State
- type: attribute
entity: sensor.hammersmith_bridge_tide
attribute: next_high_tide_in
name: Next High Tide In
icon: mdi:waves
- type: attribute
entity: sensor.hammersmith_bridge_tide
attribute: next_high_tide_height
name: Next High Tide Height
icon: mdi:waves
- type: attribute
entity: sensor.hammersmith_bridge_tide
attribute: next_low_tide_in
name: Next Low High Tide In
icon: mdi:wave
- type: attribute
entity: sensor.hammersmith_bridge_tide
attribute: next_low_tide_height
name: Next Low High Tide Height
icon: mdi:wave
title: Local Tides
That should produce something looking a little like this:
Hope it helps!
@ianByrne great work getting into the API for the UKHO tides, it is exactly what I need.
For ages I wanted to be able to query the tide through Google home. So I wrote a script to query the simple time and height of low tide which works fine:
low_tide_time:
alias: Low tide time
sequence:
- service: tts.google_translate_say
entity_id:
- media_player.bedroom_speaker
- media_player.kitchen
data:
message: >
"Low tide is at {{ as_timestamp(state_attr('sensor.shoreham_tide', 'next_low_tide_at')) | timestamp_custom('%H:%M') }} and is {{ state_attr('sensor.shoreham_tide', 'next_low_tide_height') }}"
However I also want to know what is the tide now and when will it be below 2m. A bit specific I know but lots of sailors will understand how useful this is.
I had a look at your Apex chart code, as it seems that all the data must be there, but it is way over my head:
type: 'custom:apexcharts-card'
graph_span: 2d
span:
start: hour
offset: '-5h'
now:
show: true
label: now
series:
- entity: sensor.london_bridge_tower_pier_tide
extend_to_end: false
unit: m
data_generator: |
return entity.attributes.predictions.map((event) => {
return [moment.utc(event[0]).local(), event[1]];
});
Are you able to point me in the right direction to create the data series in a script or automation so that I can pull current tide height and time of 2m tide from it if you think that is possible please?
For someone as woefully un-nautical as myself, that is indeed an interesting request!
Unfortunately the free version of the UKHO accounts will only return the high/low predictions; it doesn’t actually expose what the current tide is (this is however available for premium subscriptions). The Apex chart just draws a pretty line between those two values (the high and low tide heights), so whilst it may look like it could tell you the current tide, it’s unfortunately all smoke and mirrors.
As I only developed this against a free subscription, I’m afraid I wasn’t able to incorporate any of that premium data into the integration.
API Docs:
Free subscription
Premium subscription
Just wanted to say thank you for the UKHO integration, which all works fine.
I have a request though, the predictions attributes is really difficult to use, as there is no meaningful reference to the entries for the six days. It would be great if they carried labels. I have got round the problem by using Node-Red to split this into the 4 tides/day to populate a table, which is all a bit overkill. The alternative is to do the whole thing in Node-red, which seems a shame to duplicate all of your work
Hi @Lordlinhey, thanks for your request. Would you be able to provide further details of how you would like the predictions to be captured in an attribute? Would a simple “datetime → height” mapping work?
Hi ianByrne
Thank you for responding to my request as someone who goes sailing, I need to glance at a table and see the tidal info easily and quickly. I like the way your State, Next High and Next Low tides works, its just the info from the attributes, which is confusing, because the forementioned is in BST for me and the attributes are in GMT. that could present an issue here, as 1hr wrong means you could be stuck in the mud overnight.
This is the output which I have from using Node-Red using a flex table card, which works for me.
I have to add I am not used to javascript, but I managed to get all the info in the right date/times for BST in one function by interogating the UKHO directly not through the integration (it was a horrid rainy day today so I kept myself occupied wirh this).
Many thanks for the extra information, and great to hear you’ve managed to while away a rainy day and throw together a workaround for now!
I’m afraid I do not have a lot of time these days to work on the HA integration myself, but I have added an issue to the github page in the hopes that someone else might one day be able to implement this request.
All the best on the high seas in the meantime!
@ianByrne I completely missed this integration and was tearing my hair out with World Times as to how inaccurate it was for my UK coastal / harbour. This is just perfect! Thank you so much.
Thanks for taking the time to do that, let’s see what happens.
I did have a look at your code, but i don’t really have enough knowledge to mess with python.
Cheers