Since some time I have a strange issue with some scripts.
It might be that this started after installing the latest HA update to version 2025.4.2 but I am not sure about that.
This is an example of such a problematic script:
set_slaapduur_current:
alias: Set current Slaapduur
sequence:
- action: input_datetime.set_datetime
target:
entity_id: input_datetime.slaapduur
data:
time: '{% from ''easy_time.jinja'' import time_between %}{{ time_between(''input_datetime.in_slaap'',
''input_datetime.wakker'') }}'
Note the usage of the pairs of single quotation marks.
When I go to Developer tools → ACTIONS
, select this script and click on PERFORM ACTION
I am getting an error message:
Failed to perform the action script.set_slaapduur_current. Invalid time specified: {% from ‘easy_time.jinja’ import time_between %}{{ time_between(‘input_datetime.in_slaap’, ‘input_datetime.wakker’) }} for dictionary value @ data[‘time’]. Got None
And when I go to Settings → Automations & scenes → Scripts
, select the same script and in the top right-hand corner three dots menu select Run script
I get the same error message.
However, when I go to the three dots menu next to the script and select Run action
the script runs successfully without error messages.
When I paste the same template that is used in the script directly in the Developer tools → TEMPLATE → Template editor
I get another error message:
Template:
{% from ''easy_time.jinja'' import time_between %}{{ time_between(''input_datetime.in_slaap'', ''input_datetime.wakker'') }}
Error message:
TemplateSyntaxError: expected token ‘import’, got ‘easy_time’
When I replace each of the pairs of single quotation marks with one single quotation mark or with on double quotation mark in the template the problem is solved.
So these two templates are functioning correctly:
{% from "easy_time.jinja" import time_between %}{{ time_between("input_datetime.in_slaap", "input_datetime.wakker") }}
{% from 'easy_time.jinja' import time_between %}{{ time_between('input_datetime.in_slaap', 'input_datetime.wakker') }}
And this script also does function correctly:
set_slaapduur_current:
alias: Set current Slaapduur
sequence:
- action: input_datetime.set_datetime
target:
entity_id: input_datetime.slaapduur
data:
time: "{% from 'easy_time.jinja' import time_between %}{{ time_between('input_datetime.in_slaap',
'input_datetime.wakker') }}"
The problem however is that I did not enter these pairs of single quotation marks in the script myself.
These originally were either normal single or double quotation marks, but have been automatically changed to those pairs of single quotation marks.
It looks like this modification to the quotation marks is triggered by editing one of the scripts via: Settings → Automations & scenes → Scripts
, select the script and in the top right-hand corner three dots menu select Edit in YAML
. Then make a modification and save the script.
After that all scripts in scripts.yaml
were modified and a lot of those pairs of single quotation marks have appeared.
It looks like this is a problem only when using datetime entities in the script (or may be only when using the EasyTime script?), because for instance this script does still function properly:
cast_youtube_to_cc_chromecast:
alias: Cast YouTube to CC Chromecast
sequence:
- action: media_player.play_media
target:
entity_id: media_player.cc
data:
media_content_type: cast
media_content_id: '{{ { ''app_name'': ''youtube'', ''media_id'': ( states( ''input_text.ytl''
).split( ''v='' )[1] ) } | to_json }}'
Can someone please confirm this issue?
If I am not the only one with this problem I will raise an issue about this on GitHub.
1 post - 1 participant
Read full topic