Hello,
im trying to set up a call service, that timestamps a helper that i created for date and time.
but the timestamp function does not seem to save.
Automation:
Helper:
Hello,
im trying to set up a call service, that timestamps a helper that i created for date and time.
but the timestamp function does not seem to save.
Automation:
Helper:
Post the code you used to “timestamp a helper” (not a screenshot). To get the code, click the overflow menu (three vertical dots in the upper right corner) and select YAML mode. Then copy-paste the code here.
service: input_datetime.set_datetime
data: {}
target:
entity_id: input_datetime.date_and_time
The problem has been fixed.
i used the “edit in yaml” option. Appearantly the visual editor doesnt support it.
service: input_datetime.set_datetime
data:
timestamp: '{{ now().timestamp() }}'
target:
entity_id: input_datetime.date_and_time
That is incorrect.
If you select “Timestamp”, the Visual Editor expects you to enter a Unix timestamp value (it even says so in its description). You had entered nothing and that’s why the YAML code showed data
was empty.
If you had enter a value like this:
data
would not be empty:
service: input_datetime.set_datetime
data:
timestamp: 1617279218
target:
entity_id: input_datetime.test
What the Visual Editor does not support is entering a template for Timestamp. However your original question didn’t ask if it supported templates.
Thank you for your explanation.
If i use a unix timestamp value, would that be the same time every time the automation gets triggered?
Yes, that’s what the numeric value represents, a specific time and date.
If you want it to compute the current time and date you must use a template. However, the Visual Editor doesn’t always support templates and so you must switch to YAML mode. The other alternative is to avoid using the Visual Editor and compose your automations, in YAML, using a text editor.
Great, thanks for the info!