Error while processing template renders= 1614

I get some errors in different templates, it works fine most time
I don’t understand my mistake.
Thanks in advance for the help

Error while dispatching event for binary_sensor.heures_creuses to <Job track state_changed event {‘sensor.wiser_powertage_7_power’, ‘binary_sensor.heures_creuses’} HassJobType.Callback <bound method TrackTemplateResultInfo._refresh of <TrackTemplateResultInfo {Template<template=({{ ‘sensor.wiser_powertage_7_power’ | has_value and ‘binary_sensor.heures_creuses’| has_value }}) renders=1614>: <RenderInfo Template<template=({{ ‘sensor.wiser_powertage_7_power’ | has_value and ‘binary_sensor.heures_creuses’| has_value }}) renders=1614> all_states=False all_states_lifecycle=False domains=frozenset() domains_lifecycle=frozenset() entities=frozenset({‘sensor.wiser_powertage_7_power’, ‘binary_sensor.heures_creuses’}) rate_limit=None has_time=False exception=None is_static=False>, Template<template=({% if has_value(‘sensor.wiser_powertage_7_power’) and has_value(‘binary_sensor.heures_creuses’) %} {% if states(‘binary_sensor.heures_creuses’)== “off” %} {{states(‘sensor.wiser_powertage_7_power’)| float }} {%endif%} {%endif%}) renders=1614>: <RenderInfo Template<template=({% if has_value(‘sensor.wiser_powertage_7_power’) and has_value(‘binary_sensor.heures_creuses’) %} {% if states(‘binary_sensor.heures_creuses’)== “off” %} {{states(‘sensor.wiser_powertage_7_power’)| float }} {%endif%} {%endif%}) renders=1614> all_states=False all_states_lifecycle=False domains=frozenset() domains_lifecycle=frozenset() entities=frozenset({‘sensor.wiser_powertage_7_power’, ‘binary_sensor.heures_creuses’}) rate_limit=None has_time=False exception=None is_static=False>}>>>
Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/components/sensor/init.py”, line 684, in state
numerical_value = int(value)
ValueError: invalid literal for int() with base 10: ‘’

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/components/sensor/init.py”, line 687, in state
numerical_value = float(value)
ValueError: could not convert string to float: ‘’

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/helpers/event.py”, line 360, in _async_dispatch_entity_id_event
hass.async_run_hass_job(job, event)
~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^
File “/usr/src/homeassistant/homeassistant/core.py”, line 937, in async_run_hass_job
hassjob.target(*args)
~~~~~~~~~~~~~~^^^^^^^
File “/usr/src/homeassistant/homeassistant/helpers/event.py”, line 1322, in _refresh
self.hass.async_run_hass_job(self._job, event, updates)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/src/homeassistant/homeassistant/core.py”, line 937, in async_run_hass_job
hassjob.target(*args)
~~~~~~~~~~~~~~^^^^^^^
File “/usr/src/homeassistant/homeassistant/components/template/template_entity.py”, line 348, in _handle_results
self.async_write_ha_state()
~~~~~~~~~~~~~~~~~~~~~~~~~^^
File “/usr/src/homeassistant/homeassistant/helpers/entity.py”, line 1026, in async_write_ha_state
self._async_write_ha_state()
~~~~~~~~~~~~~~~~~~~~~~~~~~^^
File “/usr/src/homeassistant/homeassistant/helpers/entity.py”, line 1151, in _async_write_ha_state
self.__async_calculate_state()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
File “/usr/src/homeassistant/homeassistant/helpers/entity.py”, line 1088, in __async_calculate_state
state = self._stringify_state(available)
File “/usr/src/homeassistant/homeassistant/helpers/entity.py”, line 1032, in _stringify_state
if (state := self.state) is None:
^^^^^^^^^^
File “/usr/src/homeassistant/homeassistant/components/sensor/init.py”, line 691, in state
raise ValueError(
…<5 lines>…
) from err
ValueError: Sensor sensor.edf_hp_power_tag has device class ‘power’, state class ‘measurement’ unit ‘W’ and suggested precision ‘None’ thus indicating it has a numeric value; however, it has the non-numeric value: ‘’ (<class ‘str’>)

It appears you created a template sensor via Helpers and added the value as a string vs numeric.

1 Like

This template returns nothing (an empty string) when binary_sensor.heures_creuses is on. It should return 0.

FYI that is your state template.