Tide Times

Thanks @eximo84!

Config file added and bug fixes made. Great idea to have a config file :slight_smile:

1 Like

@imikerussell - just pulled the latest and noticed line 76 and 108 are still incorrect in tidesupdate.py

Other than that it all works fine, i need to adjust permissions on the files as my pi user cannot read the tidestore.py without sudo.

Oh - another great request would be to have the location on the card too :slight_smile:

Edit: Using the same logic you have used i have scraped the location from the page. Its not ideal as the h2 tag used doesnt have a class and i dont know how to locate the specific section/div and then the h2 tag within that section/div. So im just finding all h2 tags and selecting the second one as that is what brings back the location.

Im then passing that into a new file that i created - i tried to append the date to the config.py but it overwrote what was there and broke everything. Added a new print line to the tideupdate.py file and setup a new command line sensor to read the location.

Works well although could be better - however i have never used python before.

Excellent ideas @eximo84!

I’ve made an update here and also included a Tide Times Location sensor:

Man I was looking out the window at the harbour and thinking of this a couple of weeks ago. Looked on here and found nothing. Now I am back and my ideas have been banished to the cutting room floor by the fact someone has beat me to it (frankly 1000000 monkeys typing random code would beat me to developing anything).

Great work, my discoveries did me to believe that wunderground was possibly the best international data source.

Thank you.

People who have the safety of large ships at stake probably pay for the info. The prevailing view seems to be that small boat owners can look it up on a casual basis.

Maritime NZ seems to publish figures, but not via an api. You can download a pdf or csv file. Fat load of use.

Magicseaweed has my local data, just compared their data to a look out the window. Spot on, high tide in a few minutes.

And yes, I can always look out the window, but I’d like to know, for example, what the tide will be next weekend, or when I get home from work.

PS it would be great to have a graph like on this page:

http://magicseaweed.com/Sumner-Bar-Christchurch-Surf-Report/1950/

I could get away with a once a month data scrape fairly decently I reckon but I’m only looking for a rough idea of when low tide is. Nothing critical, and not something I really need automated. I wonder if tide data is available as a calendar you could subscribe to in google calendars?

You might be able to just parse the data from magicseaweed website for your local break anyway - that was how I did it for a while with tasker for something similar - it seems nuts that tide isn’t included in their API.

Maybe an iframe might work for you, like people here do with weather radar images - this one is an image but if you inspect the page you linked the data looks to be being built, I’m not sure how easy it would be to isolate just that section of the page.

Spoke too soon, wunderground only has US tides.

Looking at the API here: http://tidespy.com/client/RawApi.php

@imikerussell sorry for being dumb, but why have tidestore.py and tidestorex.py?

In your examples on the web page they seem to contain the same info, just different variable names?

Nick, Puzzled.

@imikerussell - just pulled the latest version down to get rid of my own changes and i get the following error when running python3.4 tides.py

Traceback (most recent call last):
  File "tides.py", line 12, in <module>
    tl = tl.rstrip(' <span id="displayDate"></span>')
TypeError: Type str doesn't support the buffer API

any clues?

This is cool and I will be implementing it. I also have built a water level sensor using an ESP8266 and an ultrasonic sensor that actually measures the water level and water temperature off my dock and tracks those in HASS. I have tested it for a few days and now am working on the permanent physical install. Non-trivial in that environment.

Thanks for flagging this up @eximo84 - one letter on line 12 seems to fix it :slight_smile:

New code up here now: https://github.com/imikerussell/TideTimes

@BarryHampants love the idea of a graph - very cool!

@nickrout tidestore.py and tidestorex.py keep the tide info inside them so that you only need to ping the Met Office once a day. tidestorex.py is used while the cronjob runs to avoid data changing during the update.

@billy1 that sounds amazing. Having your own sensor certainly makes the data accurate. Love it!

1 Like

Ahh ok, now I see why it is duplicated.Thanks.

@imikerussell - thanks for the update. I now get the following error from the tidestore files

Traceback (most recent call last):
  File "tideupdate.py", line 3, in <module>
    from tidestorex import *
  File "/home/homeassistant/.homeassistant/tidetimes/tidestorex.py", line 1
    tl = 'b'Sandown (Beach)''

I think the additional quote is having a problem being parsed? If i remove the ‘b’ it works fine.

Thanks for finding that @eximo84 - the latest push should fix it now.

Perfect - thank you for your support on this

@imikerussell there are two spelling errors in your README.md - “location” is spelled “loaction” in two places.

No biggie of course, more a heads up.

@eximo84 it’s my pleasure.

Thanks, great catch @nickrout, I updated that in the latest push.

1 Like

Also intergration should be integration. Cheers.

Thank you, updated!

Lol just call me the spelling nazi.