Cant get an automaiotn to trigger on time!

I’m trying to set up an automation based on a time i can input in the UI and change when required.

i think i have everything set up correct but i cant get it to fire the animation at all

the following is in my config

sensor:
  - platform: time_date
    display_options:
      - 'time'
  
  
# Example configuration.yaml entry
input_datetime:
  only_time:
    name: Kitchen Lights On
    has_date: false
    has_time: true
  only_time2:
    name: Kitchen Lights Off
    has_date: false
    has_time: true

and the below is the automation, which when i trigger manually sends the alert to my phone

- id: '1576757804787'
  alias: test kitchen light automation
  description: test kitchen light automation
  trigger:
  - platform: template
    value_template: 'value_template: "{{ states(''sensor.time'') == (state_attr(''input_datetime.only_time2'', ''timestamp'') | int | timestamp_custom(''%H:%M'', False)) }}"'
  condition: []
  action:
  - data:
      message: test for timers at a set time
      title: test for lights on
    service: notify.notify

if i run the template code in the editor i get true or false returned depending on the time and the entered time accordingly

Any suggestions??

Your trigger is way off base. Not sure where you got the idea to put value_template inside the string being returned in the value_template… but that’s just not how this works.

  - platform: template
    value_template: "{{ states('sensor.time') == states('input_datetime.only_time2') }}"

Your syntax was correct. Even your double single quotes. I simplified it a little bit seeing that you are just using time without a date.

that was me copy and pasting like a muppet!!! i’ve removed that but it still doesn’t work. but if i paste it into the template in the dev tools section it gives me true when they match and false if not.

how ever if i used the simplifed code of yours i just get false all the time :frowning:

it should work, if not just remove the quotes around the other template. As I said before, your code was correct you just added the wrong extra stuff

it seems to be working now!!! it doesn’t work as soon as it trips for the time it some times take a few seconds to run but i’ll go with that as its working!!

Folks,

I can’t seem to get this automation to work.

Don’t I need to format my input_datetime value to remove the seconds? I looks like sensor.time is only HH:MM while the input_datetime is HH:MM:SS?

{{states('sensor.time') == (states('input_datetime.backyard_floodlight_reset_time')) }}
{{states('sensor.time')}}
{{(states('input_datetime.backyard_floodlight_reset_time'))}}

Results:

False
09:06
00:30:00

My config.yaml snippets:

- platform: time_date
  display_options:
    - 'time'
    - 'date'

input_datetime:
  backyard_floodlight_reset_time:
    name: 'Backyard Floodlights Reset Time'
    has_date: false
    has_time: true
    initial: 00:30

use everything before the fifth character

{{states('sensor.time') == states('input_datetime.backyard_floodlight_reset_time')[:5]}}
{{states('sensor.time')}}
{{states('input_datetime.backyard_floodlight_reset_time')[:5]}}

Also, there’s no need to wrap functions in parenthesis. Code is order of operation, like addition, subtraction, multiplication, and division. Functions act like a single number.

THANK YOU Petro!!

I tried so many different variations, I just ended up getting lost.

For the next person who runs down this rabbit hole, here are two variations which appear to work the same:

{{ states('sensor.time') == states.input_datetime.backyard_floodlight_reset_time.state[:5]}}
{{ states('sensor.time') == states('input_datetime.backyard_floodlight_reset_time')[:5]}}

Thank you again!