Hello,
I have make a sensor to have my next alarm with -30mn like this : Mon Feb 06 06:30:00
How can I create a automation with this ? (My alarm can change and the day too).
I need to have this date and hour as a trigger.
Thanks you
Hello,
I have make a sensor to have my next alarm with -30mn like this : Mon Feb 06 06:30:00
How can I create a automation with this ? (My alarm can change and the day too).
I need to have this date and hour as a trigger.
Thanks you
Assuming you have created a Template Sensor, make it report the time in ISO format (for example: 2023-02-06T06:30:00-05:00
) and add device_class: timestamp
.
Then you can reference the sensor directly in a Time Trigger.
- trigger:
- platform: time
at: sensor.your_sensor
action:
... etc ...
Hello,
Ok now I have :
- name: "Alarme Guillaume -30min"
unique_id: alarme_guillaume_30min
state: >
{% if not is_state('sensor.oneplus_guillaume_next_alarm', 'unavailable') %}
{{ as_timestamp(strptime(state_attr('sensor.oneplus_guillaume_next_alarm', 'Local Time'), '%a %b %d %H:%M:%S %Z+01:00 %Y' ) - timedelta(minutes=30)) | timestamp_custom('%Y-%m-%dT%H:%M:%S') }}
{% else %}
Pas d'alarme
{% endif %}
My sensor is now : 2023-02-04T10:17:00
My automation :
alias: REVEIL-GUILLAUME
description: ""
trigger:
- platform: time
at: sensor.alarme_guillaume_30min
condition: []
action:
- service: input_select.select_option
data:
option: Confort
I have add an alarm and nothing happen, no trigger
You need to fix the following mistakes:
device_class: timestamp
.