Protocol details...Error not understandable

Hope this issue is placed correctly. Have found today following protocol detail which is marked as an error and have now idea what it means… any idea?

Logger: homeassistant.helpers.event
Source: components/sensor/__init__.py:594
First occurred: 10. August 2023 um 07:58:05 (964 occurrences)
Last logged: 14:37:38

Error while dispatching event for sensor.power_import to <Job track state_changed event {'sensor.power_import', 'sensor.power_solargen', 'sensor.power_export'} HassJobType.Callback <bound method TrackTemplateResultInfo._refresh of <TrackTemplateResultInfo {Template<template=({% if (states('sensor.power_export')|float(0)) > 0 and (states('sensor.power_solargen')|float(0) - states('sensor.power_export')|float(0)) < 0 %} {% elif (states('sensor.power_export')|float(0)) > 0 and (states('sensor.power_solargen')|float(0) - states('sensor.power_export')|float(0)) > 0 %} {{ (states('sensor.power_solargen')|float(0)) - states('sensor.power_export')|float(0) }} {% else %} {{ states('sensor.power_import')|float(0) + states('sensor.power_solargen')|float(0) }} {% endif %}) renders=191822>: <RenderInfo Template<template=({% if (states('sensor.power_export')|float(0)) > 0 and (states('sensor.power_solargen')|float(0) - states('sensor.power_export')|float(0)) < 0 %} {% elif (states('sensor.power_export')|float(0)) > 0 and (states('sensor.power_solargen')|float(0) - states('sensor.power_export')|float(0)) > 0 %} {{ (states('sensor.power_solargen')|float(0)) - states('sensor.power_export')|float(0) }} {% else %} {{ states('sensor.power_import')|float(0) + states('sensor.power_solargen')|float(0) }} {% endif %}) renders=191822> all_states=False all_states_lifecycle=False domains=frozenset() domains_lifecycle=frozenset() entities=frozenset({'sensor.power_solargen', 'sensor.power_export'}) rate_limit=None has_time=False exception=None is_static=False>}>>>
Error while dispatching event for sensor.power_import to <Job track state_changed event {'sensor.power_import', 'sensor.power_solargen', 'sensor.power_export'} HassJobType.Callback <bound method TrackTemplateResultInfo._refresh of <TrackTemplateResultInfo {Template<template=({% if (states('sensor.power_export')|float(0)) > 0 and (states('sensor.power_solargen')|float(0) - states('sensor.power_export')|float(0)) < 0 %} {% elif (states('sensor.power_export')|float(0)) > 0 and (states('sensor.power_solargen')|float(0) - states('sensor.power_export')|float(0)) > 0 %} {{ (states('sensor.power_solargen')|float(0)) - states('sensor.power_export')|float(0) }} {% else %} {{ states('sensor.power_import')|float(0) + states('sensor.power_solargen')|float(0) }} {% endif %}) renders=193700>: <RenderInfo Template<template=({% if (states('sensor.power_export')|float(0)) > 0 and (states('sensor.power_solargen')|float(0) - states('sensor.power_export')|float(0)) < 0 %} {% elif (states('sensor.power_export')|float(0)) > 0 and (states('sensor.power_solargen')|float(0) - states('sensor.power_export')|float(0)) > 0 %} {{ (states('sensor.power_solargen')|float(0)) - states('sensor.power_export')|float(0) }} {% else %} {{ states('sensor.power_import')|float(0) + states('sensor.power_solargen')|float(0) }} {% endif %}) renders=193700> all_states=False all_states_lifecycle=False domains=frozenset() domains_lifecycle=frozenset() entities=frozenset({'sensor.power_solargen', 'sensor.power_export'}) rate_limit=None has_time=False exception=None is_static=False>}>>>
Error while dispatching event for sensor.power_import to <Job track state_changed event {'sensor.power_import', 'sensor.power_solargen', 'sensor.power_export'} HassJobType.Callback <bound method TrackTemplateResultInfo._refresh of <TrackTemplateResultInfo {Template<template=({% if (states('sensor.power_export')|float(0)) > 0 and (states('sensor.power_solargen')|float(0) - states('sensor.power_export')|float(0)) < 0 %} {% elif (states('sensor.power_export')|float(0)) > 0 and (states('sensor.power_solargen')|float(0) - states('sensor.power_export')|float(0)) > 0 %} {{ (states('sensor.power_solargen')|float(0)) - states('sensor.power_export')|float(0) }} {% else %} {{ states('sensor.power_import')|float(0) + states('sensor.power_solargen')|float(0) }} {% endif %}) renders=194128>: <RenderInfo Template<template=({% if (states('sensor.power_export')|float(0)) > 0 and (states('sensor.power_solargen')|float(0) - states('sensor.power_export')|float(0)) < 0 %} {% elif (states('sensor.power_export')|float(0)) > 0 and (states('sensor.power_solargen')|float(0) - states('sensor.power_export')|float(0)) > 0 %} {{ (states('sensor.power_solargen')|float(0)) - states('sensor.power_export')|float(0) }} {% else %} {{ states('sensor.power_import')|float(0) + states('sensor.power_solargen')|float(0) }} {% endif %}) renders=194128> all_states=False all_states_lifecycle=False domains=frozenset() domains_lifecycle=frozenset() entities=frozenset({'sensor.power_solargen', 'sensor.power_export'}) rate_limit=None has_time=False exception=None is_static=False>}>>>
Error while dispatching event for sensor.power_import to <Job track state_changed event {'sensor.power_import', 'sensor.power_solargen', 'sensor.power_export'} HassJobType.Callback <bound method TrackTemplateResultInfo._refresh of <TrackTemplateResultInfo {Template<template=({% if (states('sensor.power_export')|float(0)) > 0 and (states('sensor.power_solargen')|float(0) - states('sensor.power_export')|float(0)) < 0 %} {% elif (states('sensor.power_export')|float(0)) > 0 and (states('sensor.power_solargen')|float(0) - states('sensor.power_export')|float(0)) > 0 %} {{ (states('sensor.power_solargen')|float(0)) - states('sensor.power_export')|float(0) }} {% else %} {{ states('sensor.power_import')|float(0) + states('sensor.power_solargen')|float(0) }} {% endif %}) renders=194206>: <RenderInfo Template<template=({% if (states('sensor.power_export')|float(0)) > 0 and (states('sensor.power_solargen')|float(0) - states('sensor.power_export')|float(0)) < 0 %} {% elif (states('sensor.power_export')|float(0)) > 0 and (states('sensor.power_solargen')|float(0) - states('sensor.power_export')|float(0)) > 0 %} {{ (states('sensor.power_solargen')|float(0)) - states('sensor.power_export')|float(0) }} {% else %} {{ states('sensor.power_import')|float(0) + states('sensor.power_solargen')|float(0) }} {% endif %}) renders=194206> all_states=False all_states_lifecycle=False domains=frozenset() domains_lifecycle=frozenset() entities=frozenset({'sensor.power_solargen', 'sensor.power_export'}) rate_limit=None has_time=False exception=None is_static=False>}>>>
Error while dispatching event for sensor.power_import to <Job track state_changed event {'sensor.power_import', 'sensor.power_solargen', 'sensor.power_export'} HassJobType.Callback <bound method TrackTemplateResultInfo._refresh of <TrackTemplateResultInfo {Template<template=({% if (states('sensor.power_export')|float(0)) > 0 and (states('sensor.power_solargen')|float(0) - states('sensor.power_export')|float(0)) < 0 %} {% elif (states('sensor.power_export')|float(0)) > 0 and (states('sensor.power_solargen')|float(0) - states('sensor.power_export')|float(0)) > 0 %} {{ (states('sensor.power_solargen')|float(0)) - states('sensor.power_export')|float(0) }} {% else %} {{ states('sensor.power_import')|float(0) + states('sensor.power_solargen')|float(0) }} {% endif %}) renders=194230>: <RenderInfo Template<template=({% if (states('sensor.power_export')|float(0)) > 0 and (states('sensor.power_solargen')|float(0) - states('sensor.power_export')|float(0)) < 0 %} {% elif (states('sensor.power_export')|float(0)) > 0 and (states('sensor.power_solargen')|float(0) - states('sensor.power_export')|float(0)) > 0 %} {{ (states('sensor.power_solargen')|float(0)) - states('sensor.power_export')|float(0) }} {% else %} {{ states('sensor.power_import')|float(0) + states('sensor.power_solargen')|float(0) }} {% endif %}) renders=194230> all_states=False all_states_lifecycle=False domains=frozenset() domains_lifecycle=frozenset() entities=frozenset({'sensor.power_solargen', 'sensor.power_export'}) 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 590, in state
    numerical_value = int(value)
                      ^^^^^^^^^^
ValueError: invalid literal for int() with base 10: ''

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 274, in _async_dispatch_entity_id_event
    hass.async_run_hass_job(job, event)
  File "/usr/src/homeassistant/homeassistant/core.py", line 627, in async_run_hass_job
    hassjob.target(*args)
  File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 1156, in _refresh
    self.hass.async_run_hass_job(self._job, event, updates)
  File "/usr/src/homeassistant/homeassistant/core.py", line 627, in async_run_hass_job
    hassjob.target(*args)
  File "/usr/src/homeassistant/homeassistant/helpers/template_entity.py", line 362, in _handle_results
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 742, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 810, in _async_write_ha_state
    state = self._stringify_state(available)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 748, in _stringify_state
    if (state := self.state) is None:
                 ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 594, in state
    raise ValueError(
ValueError: Sensor sensor.power_consumption has device class 'None', state class 'None' unit 'W' and suggested precision 'None' thus indicating it has a numeric value; however, it has the non-numeric value: '' (<class 'str'>)

Your sensor sensor.power_consumption has an empty string '' as its state value.

However it must only contain a number as it has a unit_of_measurement (among other things).

Please share the configuration of your sensor.

Here it is:

 # Template sensor for values of power consumption
      power_consumption:
        friendly_name: "Power Consumption"
        unit_of_measurement: 'W'
        value_template: >-
          {% if (states('sensor.power_export')|float(0)) > 0 and (states('sensor.power_solargen')|float(0) - states('sensor.power_export')|float(0)) < 0 %}
          {% elif (states('sensor.power_export')|float(0)) > 0 and (states('sensor.power_solargen')|float(0) - states('sensor.power_export')|float(0)) > 0 %}
            {{ (states('sensor.power_solargen')|float(0)) - states('sensor.power_export')|float(0) }}    
          {% else %}
            {{ states('sensor.power_import')|float(0) + states('sensor.power_solargen')|float(0) }}
          {% endif %}

What is the sensor state if that first if test revolves to true?

# Template sensor for values of power consumption
      power_consumption:
        friendly_name: "Power Consumption"
        unit_of_measurement: 'W'
        value_template: >-
          {% if (states('sensor.power_export')|float(0)) > 0 and (states('sensor.power_solargen')|float(0) - states('sensor.power_export')|float(0)) < 0 %}
            ### You need a numeric value here ###
          {% elif (states('sensor.power_export')|float(0)) > 0 and (states('sensor.power_solargen')|float(0) - states('sensor.power_export')|float(0)) > 0 %}
            {{ (states('sensor.power_solargen')|float(0)) - states('sensor.power_export')|float(0) }}    
          {% else %}
            {{ states('sensor.power_import')|float(0) + states('sensor.power_solargen')|float(0) }}
          {% endif %}

Hmm there was never any value here. To be honest, have no idea which value should be used
the question here is how the system should deal with power is being exported and a negative result of the difference between solar generation and export.