hello,
i have a problem with this one in tempate:
- sensor:
- name: Zum Victron
unique_id: zum_victron
state_class: measurement
icon: mdi:transmission-tower
unit_of_measurement: W
device_class: power
state: >
{% if is_number (states('sensor.victron_inverter_ac_in_l1_w')) and states('sensor.victron_inverter_ac_in_l1_w') | float(0) > 0 %}
{{(states('sensor.victron_inverter_ac_in_l1_w') | float(0))*+1 | round (3) }}
{% else %}
{{(states (0.0) | float(0)) | round(3) }}
{% endif %}
become this error:
TemplateError('AttributeError: 'float' object has no attribute 'lower'') while processing template 'Template<template=({% if is_number (states('sensor.victron_inverter_ac_in_l1_w')) and states('sensor.victron_inverter_ac_in_l1_w') | float(0) > 0 %} {{(states('sensor.victron_inverter_ac_in_l1_w') | float(0))*+1 | round (3) }} {% else %} {{(states (0.0) | float(0)) | round(3) }} {% endif %}) renders=4>' for attribute '_attr_native_value' in entity 'sensor.zum_victron'
and this one:
Logger: homeassistant.helpers.event
Source: helpers/template.py:571
First occurred: 20:52:48 (1 occurrences)
Last logged: 20:52:48
Error while processing template: Template<template=({% if is_number (states('sensor.victron_inverter_ac_in_l1_w')) and states('sensor.victron_inverter_ac_in_l1_w') | float(0) > 0 %} {{(states('sensor.victron_inverter_ac_in_l1_w') | float(0))*+1 | round (3) }} {% else %} {{(states (0.0) | float(0)) | round(3) }} {% endif %}) renders=2>
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 569, in async_render
render_result = _render_with_context(self.template, compiled, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 2247, in _render_with_context
return template.render(**kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/jinja2/environment.py", line 1301, in render
self.environment.handle_exception()
File "/usr/local/lib/python3.11/site-packages/jinja2/environment.py", line 936, in handle_exception
raise rewrite_traceback_stack(source=source)
File "<template>", line 4, in top-level template code
File "/usr/local/lib/python3.11/site-packages/jinja2/sandbox.py", line 393, in call
return __context.call(__obj, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 872, in __call__
state = _get_state(self._hass, entity_id)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 1126, in _get_state
return _get_template_state_from_state(hass, entity_id, hass.states.get(entity_id))
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 1586, in get
return self._states_data.get(entity_id.lower())
^^^^^^^^^^^^^^^
AttributeError: 'float' object has no attribute 'lower'
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 695, in async_render_to_info
render_info._result = self.async_render(
^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 571, in async_render
raise TemplateError(err) from err
homeassistant.exceptions.TemplateError: AttributeError: 'float' object has no attribute 'lower'
The value from the sensor comes positive as well as negative.
That’s why I want to split it, because the energy dashboard wants to have one in and one out for the battery
pleas help thanks