Logger: homeassistant.helpers.template
Source: helpers/template.py:1292
First occurred: 17:48:53 (1 occurrences)
Last logged: 17:48:53
Template warning: 'float' got invalid input 'unavailable' when rendering template '{% set home_generator = states('input_number.power_home_generator_ac_current') | float %} {% set total_ac_current = states('sensor.power_total_ac_current') | float %} {{ ((home_generator - total_ac_current) ) | round(1, default=0) }}' but no default was specified. Currently 'float' will return '0', however this template will fail to render in Home Assistant core 2022.1
You are getting that warning because you have not assigned defaults to your float filters. The requirement for defaults explained in the link below have not been fully implemented yet but they could be at any time. You need to update you templates or they will stop working when that happens.
If you want your example template to keep working as they have been, replace all instances of float with float(0).
Was wondering if there was a solution to the above? I have tried something similiar. Works fine in template editor as well as configurations, but when I check the state on Developer Tools I get hit with unknown. Is there something super simple here I am missing? Thanks!
Seems a trigger is missing, error message:
“This template does not listen for any events and will not update automatically.”
How do I have to trigger that?
I would like to update it every 30 seconds.
You don’t give any details of what you are talking about. I assume you’ve created a template in the Editor?
What are you trying to do?
Templates like the ones in the prior posts will be updated whenever either of the referenced sensors changes. You don’t need to specify “every 30 seconds”: it just happens. The message suggests your template has issues. Post it here in full, correctly formatted with the </> button.
Since the posts above were written, HA has evolved and you can now create template sensors in the UI, under Helpers:
You had confused the YAML configuration for the entire sensor (in “legacy” format because it’s an old topic) with the Jinja template that sets the state. You are not the first person to make that mistake.