Automation trigger from input datetime helper

Hey!
First of all, i have searched the forum for hours but can’t find a solution for this. Maybe my search-skills are bad, but i give this thread a try…

I am trying to build an alarm clock in Home Assistant, that will trigger my google home with an alarm sound. But, i wan’t to set it manually with different times every day - and make the automation trigger at the time i set it.

My setup so far is this;

  • I created an input_datetime.time so i can set a specifyed time “HH:MM” from my dashboard, works fine.
  • I created the sensor.time sensor in HA to get local time to have something to compare it to.

I am trying to use this template as a trigger, but it won’t work.
What i am doing wrong?

Thanks!

trigger:
  - platform: template
    value_template: >
      value_template: "{{
      as_timestamp(states('input_datetime.tid'))|timestamp_custom('%H:%M', true)
      == states('sensor.time')  }}"

Too much value_templates :slight_smile: and defaults are missing. Use either


value_template: > 

{{ states('sensor.time') == (state_attr('input_datetime.tid', 'timestamp') ) | timestamp_custom('%H:%M', false, now() ) }}


or


value_template: "{{ states('sensor.time') == (state_attr('input_datetime.tid', 'timestamp') ) | timestamp_custom('%H:%M', false, now() ) }}"

1 Like

Yeah i noticed it to, the problem was i was editing the template in the dashboard and not as yaml, so that’s why it got double “value_template”…

But it still dosen’t work :frowning:

But i just realised that the time from input_datetime.tid gives me “05:30:00” and the time from sensor.time gives me “05:30”, could that be why it isn’t working…?

Thanks for the reply!

Update;

I tried to convert it to show HH:MM instead of HH:MM:SS, but that didn’t make a difference… something else is wrong :frowning:

My code example works in Developer Tools. Did you try it?

Hmm, i get “false” from developer tools…

Ah sorry, missed the attribute. I corrected the code above.

That did the trick!
Thank you so much for the help! :smiling_face_with_three_hearts: