Input_button to trigger current time, but time is not updated

Hello everyone,

that little helper should give me the current time and date:

alias: Ansage
description: Durchsage Uhrzeit und Datum.
triggers:
  - trigger: state
    entity_id:
      - input_button.ansaget
    from: null
conditions: []
actions:
  - action: tts.google_translate_say
    metadata: {}
    data:
      cache: false
      entity_id: media_player.wohnzimmer
      language: de
      message: |
        {% from 'message.jinja' import message %} {{ message }}
mode: single

The editor is telling me the correct time and date:

But when manually triggered (input button) I get something with 12:05 o’clock. I guess the state is the problem. No change in the state and you get the “old information”.

Is there a way to reset the state? Or a similar helper?

Thank you. :slight_smile:

Ok, found the problem here.

When you import those vairables, you’re importing the result when they were executed. They will not continuously update. Nore will they re-execute when you import them. You’re simply just getting the value of is_state(...) when the sets were executed.

You can change that as described here.

So I changed:

      message: |
        {% from 'message.jinja' import message %} {{ message }}

To:

      message: |
        {% from 'message.jinja' import message with context %} {{ message }}

Now it is working and the current time is updated everytime.