How to set date/time helper to current date?

Getting this error

Message malformed: template value should be a string for dictionary value @ data[‘action’][0][‘data’

show code please, did you use the quotes ?

EDIT: you should try this out with dev tools > template and/or services before going in the overall automation

service: input_datetime.set_datetime
data:
  date: "{{ (now()+ timedelta(days=1)).strftime(’%Y-%m-%d’) }}"
target:
  entity_id: input_datetime.sveglia

The single-quotes are wrong, use ’ instead of ’
It is hardly visible but one is a comma-alike character, the other more a tick

Worked thanks :heart:

Why not just use a time-only input_datetime?

Asked OP similar, iI did not spend much on detail but he needs to update the helper…hence

Ok I’ll give you a more complete reply.

I’m using this to sync iOS alarms to HA, then I run an automation for the alarm

In the discussion it says

  • It works with a one time modified scheduled alarm as well, but NOT with non-repeating alarms. They lack a date and can’t be used. A possible workaround could be to use names when setting those kind of alarms and filter those within the shortcuts-automation.

So i suppose date is also required. Not sure why but I don’t want to spend too much time on it.

Apart from the iOS shortcut, I have tried to run the blueprint with an input time only and it did not seem to work, no idea why.

I suppose if I ever decide to disable this iOS shortcut, I could just use the time input. I still have to decide if it’s more convenient to set the alarm via iOS or HA

I’ll try to take advantage of your kindness once more, do you know how to trigger an action X minutes before an input_datetime?

I’ve been searching and trying for 5 hours to no avail

For five minutes (300s), adjust as appropriate:

trigger:
  - platform: template
    value_template: "{{ now()|as_timestamp - states('input_datetime.ENTITY_ID')|as_timestamp(0) < 300 }}"

Did i make any mistake? Does not seem to work

{{ now()|as_timestamp - states('input_datetime.sveglia_ora')|as_timestamp(0) < 1800 }}

What is the state of that date_time helper? Date / time or just time?

The input helper is set to time only

Try this (I also got it the wrong way around last time):

trigger:
  - platform: template
    value_template: "{{ today_at(states('input_datetime.sveglia_ora'))|as_timestamp(0) - now()|as_timestamp < 1800 }}"

You can try the template out in Developer Tools / Template.

1 Like

Getting this error now

Message malformed: invalid template (TemplateAssertionError: No filter named 'as_timetamp'.) for dictionary value @ data['value_template']

Sorry, typo now fixed. You are allowed to try to fix things yourself…

I’m already trying my best :frowning:

Getting this now in the dev tools as a result

Tipo di risultato: boolean

true

That means it’s less than 30 minutes until the time in your helper (or past that time). Should go false at midnight, then true (triggering the automation) at 30 minutes before tomorrow’s time.

Not sure why, pasting it for the fourth time seemed to do the trick

Thank you so much, i was getting crazy over this, spent over 7 hours on it. If HA is great is thanks to people like you