Are you using .state anywhere?
like this
states.sensor.temperature.state
Literally just worked through this yesterday with another person.
Are you using .state anywhere?
like this
states.sensor.temperature.state
Literally just worked through this yesterday with another person.
I think at this point, you’re looking at old errors. Either that or it’s a new one. The template I provided above will work, copy/paste, without error.
So post the new error or copy/paste the template above. Remember to wrap it in double quotes if your interior quotes are single (if you copy the template I provided).
Hi @petro ,
I am facing an (IMHO) similar error
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 2332, in _render_with_context
return template.render(**kwargs)
that is new since the last update to 2024.2.1 and arising from
sensor:
- name: davis_vantage_pro_curr
platform: rest
resource: "http://192.168.90.146/v1/current_conditions"
json_attributes:
- data
value_template: "Vantage Pro"
- platform: template
sensors:
temp:
friendly_name: "Temperatur"
device_class: temperature
unit_of_measurement: "°F"
value_template: '{{ state_attr("sensor.davis_vantage_pro_curr", "data")["conditions"][0]["temp"] | round(2)}}'
As it worked before, and I am new, I have absolutely no idea, what is wrong. Except the update, I changed nothing.
thanks
Juergen
You’ll have to post the full error
Hi @petro,
sorry I wanted to keep it short. And again (as often), it was a different story: My wife plugged out the “davis_vantage_pro_curr” wifi connection, so there was no data.
(Took me 2 hours to find out, and got a “ohh sorry” )
But this arises the question: How do I have to configure the vantage, to get no such errors, if the device is not reachable, and instead I get “something” that the weather station is “off”. I see this automatically done with my e.g. shelly, but there I did no template configuration on my own, there are just the defaults from HA. I did not find the config, so I could not “steal” from there.
thanks
Juergen
Logger: homeassistant.helpers.event
Source: helpers/template.py:574
First occurred: 18:45:51 (1 occurrences)
Last logged: 18:45:51
Error while processing template: Template<template=({{ state_attr(entity, "distance") | round(1, 0) }} Mi) renders=66>
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 1656, in forgiving_round
value = round(float(value), precision)
^^^^^^^^^^^^
TypeError: float() argument must be a string or a real number, not 'NoneType'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 572, in async_render
render_result = _render_with_context(self.template, compiled, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 2332, in _render_with_context
return template.render(**kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/jinja2/environment.py", line 1301, in render
self.environment.handle_exception()
File "/usr/local/lib/python3.12/site-packages/jinja2/environment.py", line 936, in handle_exception
raise rewrite_traceback_stack(source=source)
File "<template>", line 1, in top-level template code
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 1661, in forgiving_round
raise_no_default("round", value)
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 1637, in raise_no_default
raise ValueError(
ValueError: Template error: round got invalid input 'None' when rendering template '{{ state_attr(entity, "distance") | round(1, 0) }} Mi' but no default was specified
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 698, in async_render_to_info
render_info._result = self.async_render(
^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 574, in async_render
raise TemplateError(err) from err
homeassistant.exceptions.TemplateError: ValueError: Template error: round got invalid input 'None' when rendering template '{{ state_attr(entity, "distance") | round(1, 0) }} Mi' but no default was specified
Pulling this error now, didn’t have any issues until recently, sorry not great with templating
Change round(1,0) to round(1, default=0)
I forgot the 2nd argument is for ceiling/floor rounding methods.
@petro makes a great point. I had to not just clear, but wipe my log entries to make the old code errors go away. I should have mentioned that.
That actually fixed it, thanks!
Any idea what’s creating this new error though
Logger: frontend.js.latest.202402071
Source: components/system_log/__init__.py:306
First occurred: 21:37:33 (1 occurrences)
Last logged: 21:37:33
Uncaught error from WebKit 605.1.15 on iOS 17.3 TypeError: null is not an object (evaluating 'current_config.background') removeDefaultBackground (/hacsfiles/lovelace-animated-background/animated-background.js:533:21) /hacsfiles/lovelace-animated-background/animated-background.js:572:36
I wish I would have had that round info 2 days ago, was driving me insane. I just eliminated them. Thanks for the update!!