I want to use the input time helper (input_datetime.tidtest) and then use this as a trigger in an automation BUT start 30 minutes earlier. I can calculate as below but how can I use that as trigger in automation?
Well, yeah, you’re right. I totally lost track of what you were actually asking.
Sorry about that.
you will need to compare the time value to the time now and if they are equal then make the trigger return “true”.
EDIT:
Ok, I’ve tried to manipulate this every way I know to do and I can’t seem to get any comparison to return a true for the trigger.
Unless someone else has any ideas I think the best (and only way I know) to do this is to change your input_datetime to contain the date and then just use the trigger template I gave in the beginning.
I think it has to do with the native data type changes in the latest versions but I can’t even e sure of that.
It can be done with an input_datetime with time only but you have to add today’s date to it first. See my binary sensor below that compares a couple of input_datetimes to now() :
lounge_ac_am_automation_time_active:
friendly_name: "Lounge AM Automation Time Active"
value_template: >
{% set d = now().strftime("%Y-%m-%d ") %}
{% set t = now().timestamp() %}
{% set am_start = strptime(d + states('input_datetime.lounge_ac_am_on_time'), '%Y-%m-%d %H:%M:%S').timestamp() %}
{% set am_end = strptime(d + states('input_datetime.lounge_ac_am_off_time'), '%Y-%m-%d %H:%M:%S').timestamp() %}
{{ am_start <= t <= am_end }}