Template AlexaMediaPlayer not working anymore

Hello Everyone

I was using the following template with a lot of success the past 3 Months to trigger an Automation 2 seconds before a alarm goes off.

{{as_timestamp(now()) | int > as_timestamp(states('sensor.echodotschlafzimmer_next_alarm')) -10 | int }}

Any idea what could be the issue?

Thanks in advance

Certain filters and function, including as_timestamp and int, usually require defaults since 2021.10 … The Alexa devices’ “next” sensors are “unavailable” whenever an alarm isn’t set.

I think what may have happened is that the automation was reloaded while the sensor was unavailable and the insuing error from the lack of defaults caused the trigger event listeners to not be set up.

{{ as_timestamp(now()) > 
as_timestamp(states('sensor.echodotschlafzimmer_next_alarm'), 0) -10 }}
1 Like

Thank you very much for your answer.
I apllied the default value like you suggested.
But it seems that this does not solve the issue.
It seems to allways resolve to true with the default

It renders false when there is an alarm set and the current time isn’t within the 10 second window. The template evaluation will change from false to true when the window is reached (triggering the automation) and stay true until a new alarm is set. If it bothers you, you can use something like:

{% set alarm_time = states('sensor.echodotschlafzimmer_next_alarm') | as_datetime %}
{% if alarm_time != None %}
  {{ now() >= alarm_time - timedelta( seconds=10) }}
{% else %} False {% endif %}

Ah I understand
No this does not bother me at all.
But I just checked. If i set an Alarm the template still returns true.
So there still seems to be something wrong

Edit: simply restarting the Alexa Media Player integration fixed that