ianbyrne / hass-ukho_tides Goto Github PK
View Code? Open in Web Editor NEWHome Assistant integration for tide information
License: MIT License
Home Assistant integration for tide information
License: MIT License
Just a thanks for this. Perfect timing. Signed up for my Admiralty API key and was looking to do a chart - and voila there you were. Worked perfect out of the box. Great work.
Latest version of HomeAssistant appears to have broken something. Error message saying βConfig flow could not be loaded: {"message":"Invalid handler specified"}β when trying to reinstall the integration.
Thank you very much for the great integration. I'm a HA novice, and finding it challenging to get at details, since I think the documentation is very much designed as a reference to those who are already familar with it.
I an add the simple sensor to a card fine with station id/name and state of the tide (rising/falling), but how do I access attributes such as tide times & heights? I did skim through the files very quickly but attribute names didn't spring out at me.
Also, what are high & low tide offsets?
Thanks for a great HA integration - this works so well πππ
It is good to see that it has an offset for High and Low tide times. For many installations (including my own π) a tidal height offset would also be very useful.
The sailing club is 15 minutes behind Osea Island times, but also 2.1M higher (so the tide has 2.1M less height)
The height may more complex than it first seems, as it will need to allow for areas that dry out, and so stay at zero for a period of time, so there is effectively no "Low Tide Time" which results in any graph having a flat bottom for part of that tidal cycle.
Many Thanks
I set up this integration as per the instructions with an Apex graph showing tidal curve and the text box displaying tide stats. After a few minutes of this running home assistant starts to become very slow.
Trying to load the options flow fails due to awaiting er.async_get(self.hass)
. Despite it's rather confusing name, the get function in the entity registry helper isn't an async function.
Full traceback:
2023-12-27 18:48:10.646 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/aiohttp/web_protocol.py", line 452, in _handle_request
resp = await request_handler(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/aiohttp/web_app.py", line 543, in _handle
resp = await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/aiohttp/web_middlewares.py", line 114, in impl
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 85, in security_filter_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 227, in forwarded_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 80, in ban_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 233, in auth_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/headers.py", line 31, in headers_middleware
response = await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 149, in handle
result = await handler(request, **request.match_info)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/decorators.py", line 63, in with_admin
return await func(self, request, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 213, in post
return await super().post(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 72, in wrapper
result = await method(view, request, data, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 71, in post
result = await self._flow_mgr.async_init(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 265, in async_init
result = await self._async_handle_step(flow, flow.init_step, data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 389, in _async_handle_step
result: FlowResult = await getattr(flow, method)(user_input)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/ukho_tides/config_flow.py", line 211, in async_step_init
entity_registry = await er.async_get(self.hass)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: object EntityRegistry can't be used in 'await' expression
Thank you so much for spending your own time writing this extension for HA. Having tried a few "tide" extensions for HA, this is the only one that works for me!
I originally started using an Australian site for tidal information called Willy Weather. They provide excellent graphics, but can only be integrated into HA by adding a dedicate tab panel mode as shown below:
Later I found they got their tidal data from UKHO. Indeed their web site is very informative as it tells me how they derived the tide times from a nearby tide station. i.e.
I was wondering if your component could possibly be extended to add an off-set for low and high tide, just like Willy Weather apply.
I saw you have an ambition to "Generate pretty charts for the dashboard". Well I have started using Apex Charts from HACS and I was wondering if your component could possibly be extended to provide the raw data for Apex Charts to use??
FYI, I made a new sensor wrapper around the sensor generated by your component so I could use a button card to encapsulate the information:
sensor:
- platform: template
sensors:
greenwich_tide:
friendly_name_template: >-
{{ states("sensor.north_woolwich_tide") }} Tide
value_template: >-
{% if states("sensor.north_woolwich_tide") == 'Falling' %}
Low in {{ state_attr("sensor.north_woolwich_tide","next_tide_in") }}
{% else %}
High in {{ state_attr("sensor.north_woolwich_tide","next_tide_in") }}
{% endif %}
icon_template: >-
{{ state_attr("sensor.north_woolwich_tide","icon") }}
Note that I edited your sensors.py to add the next_tide_in attribute.
Thanks again for the hard work!
data has stopped being displayed since HA update (running in a VM), version
Home Assistant 2023.5.2
Supervisor 2023.04.1
Operating System 10.1
Frontend 20230503.3 - latest
Trying to reinstall failed with error "Config flow could not be loaded: {"message":"Invalid handler specified"}"
This integration works nicely for me, and is the best explained integration I've seen. Some improvements might be made in parameters.
The list of tidal stations isn't in a useful order, so it's hard to find a particular station. It's probably in the order supplied by UKHO. Could the integration sort the names into alphabetical order?
The description for using ApexCharts is slightly out of date. What used to be extend_to_end: false
should now be extend_to: end
.
The integration appears to get two days' worth of tides. Could there be a parameter to set the number of days?
@ianByrne I really admire your work! Especially the ApexCharts integration. I was wondering if there's a possibility for you to create a similar project for the AU market, or if you could guide me towards resources to learn and potentially develop a similar project using Python. Thank you so much!
i am currently struggling with adding the attributes as a sensor to display High tide is at 11:50am on a card, i have tried to map as a template sensor to convert this but it refuses to work, an option attribute to say Next_High_Tide / Next_Low_Tide as a time value would be great.
thanks
Hi, great plugin which worked for a while but has stopped showing data. When I checked the logs, I saw that it was because I was getting errors saying the quota for free requests under the discovery tier of the UKHO API had been exceeded? Any thoughts?
When i copy and paste the apex charts code from the readme, it fails to load.
type: custom:apexcharts-card
graph_span: 2d
span:
start: hour
offset: '-5h'
now:
show: true
label: now
series:
- entity: sensor.lee_on_solent_tide
extend_to_end: false
unit: m
data_generator: |
return entity.attributes.predictions.map((event) => {
return [moment.utc(event[0]).local(), event[1]];
});
Upgraded to HA 2023.5 last night and it broke the okho_tides integration (and some others!). On the Settings, Integrations page is shows an error "Failed to set up: Import error".
Logger: homeassistant.helpers.entity
Source: helpers/entity.py:549
...
Entity sensor.ventnor_tide (<class 'custom_components.ukho_tides.sensor.UkhoTidesSensor'>) implements device_state_attributes. Please report it to the custom component author.
I think it is on sensor.py line 158 device_state_attributes should now be extra_state_attributes?
Thanks
It looks like the Admiralty Discovery Service have changed their subscriptions and sign-up process. The free Discovery API is still available, however your integration does not recognise the API key. When I run the configuration and enter the API into the API field it returns a "invalid_api_key" error message.
Currently the tide sensor has a predictions
attribute which is made up of an array of arrays:
predictions: [ [ '2023-01-01 06:00:00', '1.6' ], [ '2023-01-01 13:00:00', '0.2' ] ]
Perhaps it can be refactored into something more meaningful, like an array of objects:
predictions:
- datetime: 2023-01-01 06:00:00
height: 1.6
event: high tide
- datetime: 2023-01-01 13:00:00
height: 0.2
event: low tide
Either refactored (causing breaking changes for anyone using the attribute), or as a new attribute for backwards compatibility.
As requested here. PRs welcome
The URL for how to sign up to the API key in the read.me is no longer valid
In this paragraph:
API Key
First up, you will need an API key from the Admiralty Maritime Data Solutions developer portal. Follow their guide on how to do so and select one of the UK Tidal API products - the Discovery tier is free (the paid APIs are untested for this integration, but should in theory work fine).
The URL I found this on was https://developer.admiralty.co.uk/docs/startup and here https://admiraltyapi.developer.azure-api.net/
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.