How to use alarm defined in Garmin watch to start heating in advance?

Hello, I have integration with Garmin, that can obtain time of next alarm as sensor.next_alarm_time

I would like to use that time value to start Tuya entity that turns on heating, but 1hr before the alarm.

How can I do that please? The automation GUI in browser does not offer to use sensor values as event trigger time.

Thanks, Jan

1 Like

Hi there. Please share the state of the sensor.next_alarm_time.

Thank you for the response. I am not sure how to find the status of sensor. When I click on it I get those screens:
image

or is there anything else I can do?

If you havent already added iso time senor, First you have to enable it in configuration by adding this to configuration.yaml

 sensor:
  - platform: time_date
    display_options:
      - 'time'
      - 'date'
      - 'date_time'
      - 'time_date'
      - 'date_time_iso'
      - 'time_utc'

From the figure you shared, assuming that the entity_id of next alarm time is sensor.next_alarm_time_2 you can build an automation with the following as template to get your requirement.

{{ as_timestamp(states.sensor.date_time_iso.state) == as_timestamp(as_timestamp(states.sensor.next_alarm_time_2.state) | timestamp_local)- 3600 }}

This will trigger the flow 1 hour before the alarm. If anything please let me know

I am sorry I feel very stupid. What do I use as trigger and as action in the automation please?

Hi…I need some more info to create the full automation. What is the entity_id of tuya entity that you use to turn n heating?

If you can set the action part of automation your self, you can use the following as the trigger. Rest of the actions you have to build or I have to get full info.

alias: Tuya Heating
description: ''
mode: single
trigger:
  - platform: template
    value_template: >-
      {{ as_timestamp(states.sensor.date_time_iso.state) ==
      as_timestamp(as_timestamp(states.sensor.next_alarm_time_2.state) |
      timestamp_local)- 3600 }}
condition: []
action:
  - service: switch.turn_on
    data: {}

Just let me know. Always happy to help more.

Hello, I am very sorry but I have problem to enter the template trigger in frontend. Following text seems to be accepted, but it does not fire the event e.g. it does not evaluate as true. What can I do? And what means the minus symbol in front of platform statement? If I add it there I cannot save automation because of error.

image

The template you have show is not correct. Please try to add the automation yaml that I have provided above to HA like this.

Just make suke sure that you add the action part also.

Hello, would you mind sharing how you managed to get the alarm time on your watch to the sensor.next_alarm_time? Thanks a lot.

Hello. I added “Garmin” integration and alarm was one of many sensors that were added from Garmin API.

Then I added automation for 1hr before alarm based in following trigger (you have to choose Template trigger):
{{ as_timestamp(states.sensor.date_time_iso.state) == as_timestamp(as_timestamp(states.sensor.next_alarm_time_2.state) | timestamp_local)- 3600 }}

Jan

1 Like

I tried to use this automation but it’s not working.
It seems that the alarm does not trigger anything…

anybody able to help? Maybe newer versions of HA or Date_time are working differently?

EDIT: you don’t really this anymore. You can create the same automation simply using the standard automation steps (not even need to edit YAML anymore!)