Set datetime to text entity by automation

Hello,
I try to set the actual datetime to a text field via automation (cron).

The yaml looks like:

alias: DeyeTime
description: Set Deye Time
trigger:
  - platform: time_pattern
    minutes: "15"
condition: []
action:
  - device_id: ....
    domain: text
    entity_id: ....
    type: set_value
    value: "{{ now().strftime('%Y-%m-%d %H:%M:%S') }}"
mode: single

But this does not update the entity.

That this manually works as expected.

Best regards,

Can you give more details?

Does the automation not trigger as expected?
Does the automation trigger as expected, but the action doesn’t update the text entity?
What does the automation’s debug trace show?

You’re using a Device Action. It doesn’t support templates.

Use a Service Call. It supports templates.

alias: DeyeTime
description: Set Deye Time
trigger:
  - platform: time_pattern
    minutes: "15"
condition: []
action:
  - service: input_text.set_value
    target:
      entity_id: input_text.your_input_text
    data:
       value: "{{ now().strftime('%Y-%m-%d %H:%M:%S') }}"

Adding to Taras, this might be an interesting read: :slight_smile:

I am guessing you were hoping this would update every 15 minutes, however this yaml trigger is configured to update at 15 minutes past each hour.

trigger:
  - platform: time_pattern
    minutes: "/15"

The example above will trigger every 15 minutes.