How create one automation with a date and hour


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
      ... etc ...


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 :

description: ""
  - platform: time
    at: sensor.alarme_guillaume_30min
condition: []
  - service: input_select.select_option
      option: Confort

I have add an alarm and nothing happen, no trigger

You need to fix the following mistakes:

  1. The sensor’s value isn’t reporting date and time in ISO format.
  2. The sensor’s configuration doesn’t contain device_class: timestamp.
  3. The sensor can sometimes report `Pas d’alarme’, instead of date and time in ISO format, and that’s invalid for use by a Time Trigger.