Templating changes in 2021.10.0

I’d appreciate any help, did i miss anything on this line of code

{% set hour = as_timestamp(now()|timestamp_local|default(none))|int(0)|timestamp_custom(’%H’)|int(0) %}

it still is getting warnings, i put the default(none) for timestamp_local,
default int(0) for as_timestamp, and another default int(0) for timestamp_custom

in my test in developer tools->template->
now()|timestamp_local returned a date string,
so i went with default(none) instead of some date defaults.

here is the warning from HA log below

2021-10-10 00:47:00 WARNING (MainThread) [homeassistant.helpers.template] Template warning: ‘timestamp_local’ got invalid input ‘2021-10-10 00:47:00.184837-05:00’ when rendering template
but no default was specified. Currently ‘timestamp_local’ will return ‘2021-10-10 00:47:00.184837-05:00’, however this template will fail to render in Home Assistant core 2021.12

{% set hour = now().hour %}

As for the error you got, timestamp_local transform a unix timestamp (now is 1633852646) to a string. You passed it a datetime object because as_timestamp should apply to now() only.

the proper way could have been

{{ now().strftime('%H') }}

I am running on Debian supervisor. I had to use
tail -f /usr/share/hassio/homeassistant/home-assistant.log --lines=250

1 Like

You don’t have samba set up for your system? Or SSH for SCP? Why are you running supervised?

Because no HAOS upgrades on my system has worked since last November. (5.4). Many open issues in GitHub. Debian 11 supervisor is stable. HAOS is not. Same system, hardware and software.
I do use Samba

Then use a log viewing software like baretale or logexpert. Both update logs on the fly

Interestng, can you share the yaml template code on how you did this? thanks

1 Like

Had the same situation running Supervised (on Debian 11) until I added


    homeassistant.helpers.template: info
    template.py: info

in my logger configuration.

CORRECTION: Now I get template warnings, but nothing related to {{ 'foo' | float }} .

Thanks. The logger app works as well. I was just confused on what logs I needed.

1 Like

After added this you are seeing some warnings in the template editor but not others? According to petro the editor was not designed to show warnings.

Also according to Petro, template warnings are shown in the log.

Maybe I didn’t understand. You are not seeing the warnings in the log? I was on some devices but not others. I was told it was a cache issue. That is why I was told to use cli.

I didn’t see any template warnings in the logs til I added explicitly homeassistant.helpers.template: info template.py: info

Now I can see the foo warning, too (needed a few minutes).

I guess your logger default level is “error”?

So you are saying it takes time for the warning to show on your logs? I believe it should be almost instant. If it isn’t the editor tool is not very useful for troubleshooting the warnings.

The warnings in logs only show based on your settings in logger.

Default config for logger is everything set to info, which will make them appear. If you adjusted logger settings they may or may not appear based on your settings

Sure :slight_smile: . Here is one of them. The first line was what it use to be (commented out), the rest is what I now use

       #state: '{{(states("sensor.solaredge_lifetime_energy") | float / 1000000) | round(3)}}'
        state: >-
          {% if is_number(states("sensor.solaredge_lifetime_energy"))  %}
            {{(states("sensor.solaredge_lifetime_energy") | float / 1000000) | round(3)}}
          {%- else -%}
            {{ states("sensor.solaredge_lifetime_energy") }}
          {%- endif %}
2 Likes

Cool, thanks

Where is this reasonably explained, so that a normal 08/15 user can understand it without having to constantly ask? It really annoys me that the devs don’t explain changes in an understandable way.

Nothing changed in that regard. You were confused at the moment you wrote the template, and didn’t read the doc thoroughly.
Or just copy pasted some random snippet without understanding them.

PS: What is a “08/15 user”, btw?