Using @ianByrne UKHO tides HACS integration I made an automation of some custom sentences I thought I might quickly share. Feel free to add/correct.
Make sure to use your own tide sensor. Thanks @ianByrne
alias: tide sentences
description: "Some sentences to use with ianByrne HAC UKHO integration"
triggers:
- trigger: conversation
command:
- When is [the] [next] low tide
id: when_low_tide
- trigger: conversation
command:
- When is [the] [next] high tide
id: when_high_tide
- trigger: conversation
command:
- Is the tide rising or falling
- Is the tide falling or rising
id: rising_or_falling
conditions: []
actions:
- choose:
- conditions:
- condition: trigger
id:
- when_low_tide
sequence:
- set_conversation_response: >
{% set lt_in = state_attr('sensor.YOUR_TIDE_SENSOR',
'next_low_tide_in').split(' ') %}
{% set h = lt_in[0][:-1]|int %}
{% set m = lt_in[1][:-1]|int %}
The tide is currently {{states('sensor.YOUR_TIDE_SENSOR')}}.
..
The next low tide is in {{h}} hour{{iif(h > 1, 's', '')}} and
{{m}} minute{{iif(m > 1, 's', '')}}
at {{ as_timestamp(state_attr('sensor.YOUR_TIDE_SENSOR',
'next_low_tide_at'))|timestamp_custom ('%-H %M') }}.
..
{% set low_height = state_attr('sensor.YOUR_TIDE_SENSOR',
'next_low_tide_height') %}
The predicted low is {{ low_height.split('m')[0] }} meters.
- conditions:
- condition: trigger
id:
- when_high_tide
sequence:
- set_conversation_response: >
{% set ht_in = state_attr('sensor.YOUR_TIDE_SENSOR',
'next_high_tide_in').split(' ') %}
{% set h = ht_in[0][:-1]|int %}
{% set m = ht_in[1][:-1]|int %}
The tide is currently {{states('sensor.YOUR_TIDE_SENSOR')}}.
..
The next high tide is in {{h}} hour{{iif(h > 1, 's', '')}} and
{{m}} minute{{iif(m > 1, 's', '')}}
at {{ as_timestamp(state_attr('sensor.YOUR_TIDE_SENSOR',
'next_high_tide_at'))|timestamp_custom ('%-H %M') }}.
..
{% set high_height = state_attr('sensor.YOUR_TIDE_SENSOR',
'next_high_tide_height') %}
The predicted high is {{ high_height.split('m')[0] }} meters.
- conditions:
- condition: trigger
id:
- rising_or_falling
sequence:
- set_conversation_response: |
The tide is currently {{states('sensor.YOUR_TIDE_SENSOR')}}.
mode: single