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