ianByrne / HASS-ukho_tides

Home Assistant integration for tide information
MIT License
28 stars 5 forks source link

Off-set not applied to prediction graph #2

Closed DrJohnT closed 3 years ago

DrJohnT commented 3 years ago

The below image is of Willy Weather on RHS, my button card which shows the correct off-set value for high tide. However, the graph on lower LHS clearly shows high tide has passed. So I presume that the off-set is not been applied to the tide prediction data.

NextHighTide

Regards,

Your other user Dr John

ianByrne commented 3 years ago

Aha! Thanks for the heads up. It looks like it's a timezone issue - the tide data is being displayed in UTC on the chart.

You can confirm the offsets are being applied correctly by checking the predictions attribute of the sensor - the list of high/low events should (hopefully) be matching the Willy Weather times with its offsets.

Here is an update to the Lovelace Card's yaml to display the events in local time - just replace the data_generator bit with the below:

    data_generator: |
      return entity.attributes.predictions.map((event) => {
        return [moment.utc(event[0]).local(), event[1]];
      });

Thanks again - I'll update the docs shortly.

ianByrne commented 3 years ago

Also, if you happen to work out how to get rid of that wonky line running along the bottom of your chart, do please let me know... I've seen it popup a couple times on my end too, but not entirely sure what's causing it - I suspect it's something in the ApexCharts configuration aswell

DrJohnT commented 3 years ago

Wow! What service! Any idea what causes the straight line at the bottom of the graph?

My graph YAML looks like this (including your update already).

type: 'custom:apexcharts-card'
header:
  show: true
  title: IoD Tide
  show_states: false
graph_span: 2d
span:
  start: hour
  offset: '-5h'
now:
  show: true
  label: now
series:
  - entity: sensor.north_woolwich_tide
    extend_to_end: false
    unit: m
    data_generator: |
      return entity.attributes.predictions.map((event) => {
        return [moment.utc(event[0]).local(), event[1]];
      });
DrJohnT commented 3 years ago

We were clearly thinking on the same lines at the same time. I have no idea where it comes from...

DrJohnT commented 3 years ago

Wonky line has now gone after your update just now. Thanks! WonkyGone

ianByrne commented 3 years ago

Very peculiar... The only update was to the docs, so it looks like it somehow fixed itself. I suspect it's something that only pops up when there's a certain threshold being exceeded in the start and end dates. If you see it again, please try to grab the data from the predictions attribute, and I'll see if I can reproduce it to find a fix.

DrJohnT commented 3 years ago

Ian This morning the wonky line is back. Here is the predictions data:

attribution: Data provided by UK Hydrographic Office
predictions:
  - - '2021-04-06 21:13:00'
    - 5.6
  - - '2021-04-07 03:37:00'
    - 1.5
  - - '2021-04-07 10:01:00'
    - 6.1
  - - '2021-04-07 16:17:00'
    - 1.7
  - - '2021-04-07 22:45:00'
    - 5.9
  - - '2021-04-08 05:19:00'
    - 1.2
  - - '2021-04-08 11:22:00'
    - 6.5
  - - '2021-04-08 17:38:00'
    - 1.4
  - - '2021-04-08 23:52:00'
    - 6.3
  - - '2021-04-09 06:30:00'
    - 0.8
  - - '2021-04-09 12:19:00'
    - 6.8
  - - '2021-04-09 18:37:00'
    - 1.1
  - - '2021-04-10 00:41:00'
    - 6.6
  - - '2021-04-10 07:20:00'
    - 0.6
  - - '2021-04-10 13:03:00'
    - 7
  - - '2021-04-10 19:25:00'
    - 1
  - - '2021-04-11 01:20:00'
    - 6.8
  - - '2021-04-11 07:58:00'
    - 0.6
  - - '2021-04-11 13:41:00'
    - 7
  - - '2021-04-11 20:04:00'
    - 0.9
  - - '2021-04-12 01:54:00'
    - 6.9
  - - '2021-04-12 08:29:00'
    - 0.6
  - - '2021-04-12 14:13:00'
    - 6.9
  - - '2021-04-12 20:39:00'
    - 0.9
  - - '2021-04-07 03:37:00'
    - 1.5
  - - '2021-04-07 10:01:00'
    - 6.1
  - - '2021-04-07 16:17:00'
    - 1.7
  - - '2021-04-07 22:45:00'
    - 5.9
  - - '2021-04-08 05:19:00'
    - 1.2
  - - '2021-04-08 11:22:00'
    - 6.5
  - - '2021-04-08 17:38:00'
    - 1.4
  - - '2021-04-08 23:52:00'
    - 6.3
  - - '2021-04-09 06:30:00'
    - 0.8
  - - '2021-04-09 12:19:00'
    - 6.8
  - - '2021-04-09 18:37:00'
    - 1.1
  - - '2021-04-10 00:41:00'
    - 6.6
  - - '2021-04-10 07:20:00'
    - 0.6
  - - '2021-04-10 13:03:00'
    - 7
  - - '2021-04-10 19:25:00'
    - 1
  - - '2021-04-11 01:20:00'
    - 6.8
  - - '2021-04-11 07:58:00'
    - 0.6
  - - '2021-04-11 13:41:00'
    - 7
  - - '2021-04-11 20:04:00'
    - 0.9
  - - '2021-04-12 01:54:00'
    - 6.9
  - - '2021-04-12 08:29:00'
    - 0.6
  - - '2021-04-12 14:13:00'
    - 6.9
  - - '2021-04-12 20:39:00'
    - 0.9
  - - '2021-04-13 02:24:00'
    - 7
  - - '2021-04-13 08:53:00'
    - 0.6
  - - '2021-04-13 14:42:00'
    - 7
  - - '2021-04-13 21:10:00'
    - 0.8
  - - '2021-04-07 03:37:00'
    - 1.5
  - - '2021-04-07 10:01:00'
    - 6.1
  - - '2021-04-07 16:17:00'
    - 1.7
  - - '2021-04-07 22:45:00'
    - 5.9
  - - '2021-04-08 05:19:00'
    - 1.2
  - - '2021-04-08 11:22:00'
    - 6.5
  - - '2021-04-08 17:38:00'
    - 1.4
  - - '2021-04-08 23:52:00'
    - 6.3
  - - '2021-04-09 06:30:00'
    - 0.8
  - - '2021-04-09 12:19:00'
    - 6.8
  - - '2021-04-09 18:37:00'
    - 1.1
  - - '2021-04-10 00:41:00'
    - 6.6
  - - '2021-04-10 07:20:00'
    - 0.6
  - - '2021-04-10 13:03:00'
    - 7
  - - '2021-04-10 19:25:00'
    - 1
  - - '2021-04-11 01:20:00'
    - 6.8
  - - '2021-04-11 07:58:00'
    - 0.6
  - - '2021-04-11 13:41:00'
    - 7
  - - '2021-04-11 20:04:00'
    - 0.9
  - - '2021-04-12 01:54:00'
    - 6.9
  - - '2021-04-12 08:29:00'
    - 0.6
  - - '2021-04-12 14:13:00'
    - 6.9
  - - '2021-04-12 20:39:00'
    - 0.9
  - - '2021-04-13 02:24:00'
    - 7
  - - '2021-04-13 08:53:00'
    - 0.6
  - - '2021-04-13 14:42:00'
    - 7
  - - '2021-04-13 21:10:00'
    - 0.8
  - - '2021-04-07 03:37:00'
    - 1.5
  - - '2021-04-07 10:01:00'
    - 6.1
  - - '2021-04-07 16:17:00'
    - 1.7
  - - '2021-04-07 22:45:00'
    - 5.9
  - - '2021-04-08 05:19:00'
    - 1.2
  - - '2021-04-08 11:22:00'
    - 6.5
  - - '2021-04-08 17:38:00'
    - 1.4
  - - '2021-04-08 23:52:00'
    - 6.3
  - - '2021-04-09 06:30:00'
    - 0.8
  - - '2021-04-09 12:19:00'
    - 6.8
  - - '2021-04-09 18:37:00'
    - 1.1
  - - '2021-04-10 00:41:00'
    - 6.6
  - - '2021-04-10 07:20:00'
    - 0.6
  - - '2021-04-10 13:03:00'
    - 7
  - - '2021-04-10 19:25:00'
    - 1
  - - '2021-04-11 01:20:00'
    - 6.8
  - - '2021-04-11 07:58:00'
    - 0.6
  - - '2021-04-11 13:41:00'
    - 7
  - - '2021-04-11 20:04:00'
    - 0.9
  - - '2021-04-12 01:54:00'
    - 6.9
  - - '2021-04-12 08:29:00'
    - 0.6
  - - '2021-04-12 14:13:00'
    - 6.9
  - - '2021-04-12 20:39:00'
    - 0.9
  - - '2021-04-13 02:24:00'
    - 7
  - - '2021-04-13 08:53:00'
    - 0.6
  - - '2021-04-13 14:42:00'
    - 7
  - - '2021-04-13 21:10:00'
    - 0.8
  - - '2021-04-07 03:37:00'
    - 1.5
  - - '2021-04-07 10:01:00'
    - 6.1
  - - '2021-04-07 16:17:00'
    - 1.7
  - - '2021-04-07 22:45:00'
    - 5.9
  - - '2021-04-08 05:19:00'
    - 1.2
  - - '2021-04-08 11:22:00'
    - 6.5
  - - '2021-04-08 17:38:00'
    - 1.4
  - - '2021-04-08 23:52:00'
    - 6.3
  - - '2021-04-09 06:30:00'
    - 0.8
  - - '2021-04-09 12:19:00'
    - 6.8
  - - '2021-04-09 18:37:00'
    - 1.1
  - - '2021-04-10 00:41:00'
    - 6.6
  - - '2021-04-10 07:20:00'
    - 0.6
  - - '2021-04-10 13:03:00'
    - 7
  - - '2021-04-10 19:25:00'
    - 1
  - - '2021-04-11 01:20:00'
    - 6.8
  - - '2021-04-11 07:58:00'
    - 0.6
  - - '2021-04-11 13:41:00'
    - 7
  - - '2021-04-11 20:04:00'
    - 0.9
  - - '2021-04-12 01:54:00'
    - 6.9
  - - '2021-04-12 08:29:00'
    - 0.6
  - - '2021-04-12 14:13:00'
    - 6.9
  - - '2021-04-12 20:39:00'
    - 0.9
  - - '2021-04-13 02:24:00'
    - 7
  - - '2021-04-13 08:53:00'
    - 0.6
  - - '2021-04-13 14:42:00'
    - 7
  - - '2021-04-13 21:10:00'
    - 0.8
  - - '2021-04-07 03:37:00'
    - 1.5
  - - '2021-04-07 10:01:00'
    - 6.1
  - - '2021-04-07 16:17:00'
    - 1.7
  - - '2021-04-07 22:45:00'
    - 5.9
  - - '2021-04-08 05:19:00'
    - 1.2
  - - '2021-04-08 11:22:00'
    - 6.5
  - - '2021-04-08 17:38:00'
    - 1.4
  - - '2021-04-08 23:52:00'
    - 6.3
  - - '2021-04-09 06:30:00'
    - 0.8
  - - '2021-04-09 12:19:00'
    - 6.8
  - - '2021-04-09 18:37:00'
    - 1.1
  - - '2021-04-10 00:41:00'
    - 6.6
  - - '2021-04-10 07:20:00'
    - 0.6
  - - '2021-04-10 13:03:00'
    - 7
  - - '2021-04-10 19:25:00'
    - 1
  - - '2021-04-11 01:20:00'
    - 6.8
  - - '2021-04-11 07:58:00'
    - 0.6
  - - '2021-04-11 13:41:00'
    - 7
  - - '2021-04-11 20:04:00'
    - 0.9
  - - '2021-04-12 01:54:00'
    - 6.9
  - - '2021-04-12 08:29:00'
    - 0.6
  - - '2021-04-12 14:13:00'
    - 6.9
  - - '2021-04-12 20:39:00'
    - 0.9
  - - '2021-04-13 02:24:00'
    - 7
  - - '2021-04-13 08:53:00'
    - 0.6
  - - '2021-04-13 14:42:00'
    - 7
  - - '2021-04-13 21:10:00'
    - 0.8
  - - '2021-04-07 03:37:00'
    - 1.5
  - - '2021-04-07 10:01:00'
    - 6.1
  - - '2021-04-07 16:17:00'
    - 1.7
  - - '2021-04-07 22:45:00'
    - 5.9
  - - '2021-04-08 05:19:00'
    - 1.2
  - - '2021-04-08 11:22:00'
    - 6.5
  - - '2021-04-08 17:38:00'
    - 1.4
  - - '2021-04-08 23:52:00'
    - 6.3
  - - '2021-04-09 06:30:00'
    - 0.8
  - - '2021-04-09 12:19:00'
    - 6.8
  - - '2021-04-09 18:37:00'
    - 1.1
  - - '2021-04-10 00:41:00'
    - 6.6
  - - '2021-04-10 07:20:00'
    - 0.6
  - - '2021-04-10 13:03:00'
    - 7
  - - '2021-04-10 19:25:00'
    - 1
  - - '2021-04-11 01:20:00'
    - 6.8
  - - '2021-04-11 07:58:00'
    - 0.6
  - - '2021-04-11 13:41:00'
    - 7
  - - '2021-04-11 20:04:00'
    - 0.9
  - - '2021-04-12 01:54:00'
    - 6.9
  - - '2021-04-12 08:29:00'
    - 0.6
  - - '2021-04-12 14:13:00'
    - 6.9
  - - '2021-04-12 20:39:00'
    - 0.9
  - - '2021-04-13 02:24:00'
    - 7
  - - '2021-04-13 08:53:00'
    - 0.6
  - - '2021-04-13 14:42:00'
    - 7
  - - '2021-04-13 21:10:00'
    - 0.8
  - - '2021-04-07 03:37:00'
    - 1.5
  - - '2021-04-07 10:01:00'
    - 6.1
  - - '2021-04-07 16:17:00'
    - 1.7
  - - '2021-04-07 22:45:00'
    - 5.9
  - - '2021-04-08 05:19:00'
    - 1.2
  - - '2021-04-08 11:22:00'
    - 6.5
  - - '2021-04-08 17:38:00'
    - 1.4
  - - '2021-04-08 23:52:00'
    - 6.3
  - - '2021-04-09 06:30:00'
    - 0.8
  - - '2021-04-09 12:19:00'
    - 6.8
  - - '2021-04-09 18:37:00'
    - 1.1
  - - '2021-04-10 00:41:00'
    - 6.6
  - - '2021-04-10 07:20:00'
    - 0.6
  - - '2021-04-10 13:03:00'
    - 7
  - - '2021-04-10 19:25:00'
    - 1
  - - '2021-04-11 01:20:00'
    - 6.8
  - - '2021-04-11 07:58:00'
    - 0.6
  - - '2021-04-11 13:41:00'
    - 7
  - - '2021-04-11 20:04:00'
    - 0.9
  - - '2021-04-12 01:54:00'
    - 6.9
  - - '2021-04-12 08:29:00'
    - 0.6
  - - '2021-04-12 14:13:00'
    - 6.9
  - - '2021-04-12 20:39:00'
    - 0.9
  - - '2021-04-13 02:24:00'
    - 7
  - - '2021-04-13 08:53:00'
    - 0.6
  - - '2021-04-13 14:42:00'
    - 7
  - - '2021-04-13 21:10:00'
    - 0.8
  - - '2021-04-07 03:37:00'
    - 1.5
  - - '2021-04-07 10:01:00'
    - 6.1
  - - '2021-04-07 16:17:00'
    - 1.7
  - - '2021-04-07 22:45:00'
    - 5.9
  - - '2021-04-08 05:19:00'
    - 1.2
  - - '2021-04-08 11:22:00'
    - 6.5
  - - '2021-04-08 17:38:00'
    - 1.4
  - - '2021-04-08 23:52:00'
    - 6.3
  - - '2021-04-09 06:30:00'
    - 0.8
  - - '2021-04-09 12:19:00'
    - 6.8
  - - '2021-04-09 18:37:00'
    - 1.1
  - - '2021-04-10 00:41:00'
    - 6.6
  - - '2021-04-10 07:20:00'
    - 0.6
  - - '2021-04-10 13:03:00'
    - 7
  - - '2021-04-10 19:25:00'
    - 1
  - - '2021-04-11 01:20:00'
    - 6.8
  - - '2021-04-11 07:58:00'
    - 0.6
  - - '2021-04-11 13:41:00'
    - 7
  - - '2021-04-11 20:04:00'
    - 0.9
  - - '2021-04-12 01:54:00'
    - 6.9
  - - '2021-04-12 08:29:00'
    - 0.6
  - - '2021-04-12 14:13:00'
    - 6.9
  - - '2021-04-12 20:39:00'
    - 0.9
  - - '2021-04-13 02:24:00'
    - 7
  - - '2021-04-13 08:53:00'
    - 0.6
  - - '2021-04-13 14:42:00'
    - 7
  - - '2021-04-13 21:10:00'
    - 0.8
  - - '2021-04-07 03:37:00'
    - 1.5
  - - '2021-04-07 10:01:00'
    - 6.1
  - - '2021-04-07 16:17:00'
    - 1.7
  - - '2021-04-07 22:45:00'
    - 5.9
  - - '2021-04-08 05:19:00'
    - 1.2
  - - '2021-04-08 11:22:00'
    - 6.5
  - - '2021-04-08 17:38:00'
    - 1.4
  - - '2021-04-08 23:52:00'
    - 6.3
  - - '2021-04-09 06:30:00'
    - 0.8
  - - '2021-04-09 12:19:00'
    - 6.8
  - - '2021-04-09 18:37:00'
    - 1.1
  - - '2021-04-10 00:41:00'
    - 6.6
  - - '2021-04-10 07:20:00'
    - 0.6
  - - '2021-04-10 13:03:00'
    - 7
  - - '2021-04-10 19:25:00'
    - 1
  - - '2021-04-11 01:20:00'
    - 6.8
  - - '2021-04-11 07:58:00'
    - 0.6
  - - '2021-04-11 13:41:00'
    - 7
  - - '2021-04-11 20:04:00'
    - 0.9
  - - '2021-04-12 01:54:00'
    - 6.9
  - - '2021-04-12 08:29:00'
    - 0.6
  - - '2021-04-12 14:13:00'
    - 6.9
  - - '2021-04-12 20:39:00'
    - 0.9
  - - '2021-04-13 02:24:00'
    - 7
  - - '2021-04-13 08:53:00'
    - 0.6
  - - '2021-04-13 14:42:00'
    - 7
  - - '2021-04-13 21:10:00'
    - 0.8
  - - '2021-04-07 03:37:00'
    - 1.5
  - - '2021-04-07 10:01:00'
    - 6.1
  - - '2021-04-07 16:17:00'
    - 1.7
  - - '2021-04-07 22:45:00'
    - 5.9
  - - '2021-04-08 05:19:00'
    - 1.2
  - - '2021-04-08 11:22:00'
    - 6.5
  - - '2021-04-08 17:38:00'
    - 1.4
  - - '2021-04-08 23:52:00'
    - 6.3
  - - '2021-04-09 06:30:00'
    - 0.8
  - - '2021-04-09 12:19:00'
    - 6.8
  - - '2021-04-09 18:37:00'
    - 1.1
  - - '2021-04-10 00:41:00'
    - 6.6
  - - '2021-04-10 07:20:00'
    - 0.6
  - - '2021-04-10 13:03:00'
    - 7
  - - '2021-04-10 19:25:00'
    - 1
  - - '2021-04-11 01:20:00'
    - 6.8
  - - '2021-04-11 07:58:00'
    - 0.6
  - - '2021-04-11 13:41:00'
    - 7
  - - '2021-04-11 20:04:00'
    - 0.9
  - - '2021-04-12 01:54:00'
    - 6.9
  - - '2021-04-12 08:29:00'
    - 0.6
  - - '2021-04-12 14:13:00'
    - 6.9
  - - '2021-04-12 20:39:00'
    - 0.9
  - - '2021-04-13 02:24:00'
    - 7
  - - '2021-04-13 08:53:00'
    - 0.6
  - - '2021-04-13 14:42:00'
    - 7
  - - '2021-04-13 21:10:00'
    - 0.8
next_low_tide_in: 6h 51m
next_low_tide_height: 1.7m
next_high_tide_in: 0h 35m
next_high_tide_height: 6.1m
friendly_name: IoD Tide
icon: 'mdi:transfer-up'
ianByrne commented 3 years ago

Hmm looks like a lot of duplicate events were gradually being added to the collection. I've now pushed a small update to clear them out, hopefully it will prevent any wonky lines from slowly creeping in.

DrJohnT commented 3 years ago

I can confirm the pretty chart now has no wonky line. I also took the liberty of creating a pull request to icons and logos for UKHO which you can see here https://github.com/home-assistant/brands/pull/2410

ianByrne commented 3 years ago

That's great, thanks a bunch for your help!