I need to craft a string that represent a date and time that along with a temp I need to send to my boiler to set a temporarily overridden temp setting.
Leaving the details aside I’m experimenting with the template editor in the dev tools
if I use this code to render the string (I’ll need to convert it to hex but that’s already solved)
{% set newtime=now()+timedelta(hours=states('input_number.temp_override_hours')|int) %}
{{ (states('input_number.temperature_override_temp') | float *10)|int }} {{ newtime.strftime('%H') }} {{ newtime.strftime('%M') }} {{ newtime.strftime('%S') }} {{ newtime.strftime('%d') }} {{ newtime.strftime('%m') }} {{ newtime.strftime('%Y') }}
the result is good (the input nr is now set to 1h offset):
215 23 51 00 11 02 2025
215 new temp setting (multiplied by 10 = 21.5°C)
23 51 00 time (+1h CET)
11 02 2025 date
but if I remove the spaces, placed here to help reading, the year goes back to 2024:
{% set newtime=now()+timedelta(hours=states('input_number.temp_override_hours')|int) %}
{{ (states('input_number.temperature_override_temp') | float *10)|int }}{{ newtime.strftime('%H') }}{{ newtime.strftime('%M') }}{{ newtime.strftime('%S') }}{{ newtime.strftime('%d') }}{{ newtime.strftime('%m') }}{{ newtime.strftime('%Y') }}
gives
21523581711022024
as this template render a number I though that there could be a rounding error of some kind but i I cast it to a string with something like this:
{% set newtime=now()+timedelta(hours=states('input_number.temp_override_hours')|int) %}
{{ ((states('input_number.temperature_override_temp') | float *10)|int|string + newtime.strftime('%H') + newtime.strftime('%M') + newtime.strftime('%S') + newtime.strftime('%d') + newtime.strftime('%m') + newtime.strftime('%Y')) | string }}
result is also wrong.
21500030012022024
I know I’m missing something very stupid, can you point it to my dumb brain?
TY