Hello, I just got an inverter that doesn’t have direct Home Assistant integration, but it has modbus support. I set up these sensors that I copied from someone who is using the same hardware as I do, but I am not able to see any of these sensors anywhere. Where should I be looking for them?
- type: tcp
name: "solar"
host: 192.168.0.153
port: 502
sensors:
- name: Solar Potencia Grid
scan_interval: 5
data_type: int16
input_type: input
unit_of_measurement: W
slave: 1
address: 71
unique_id: sensor.solar_potencia_grid
- name: Solar Potencia Bateria
scan_interval: 5
data_type: int16
input_type: input
unit_of_measurement: W
slave: 1
address: 19
unique_id: sensor.solar_potencia_bateria
- name: Solar Potencia Inversor grid
scan_interval: 5
data_type: int16
input_type: input
unit_of_measurement: W
slave: 1
address: 51
unique_id: sensor.solar_potencia_inversor_grid
- name: Solar Potencia Inversor criticas
scan_interval: 5
data_type: int16
input_type: input
unit_of_measurement: W
slave: 1
address: 46
unique_id: sensor.solar_potencia_inversor_criticas
- name: Solar Potencia Inversor
scan_interval: 5
data_type: int16
input_type: input
unit_of_measurement: W
slave: 1
address: 37
unique_id: sensor.solar_potencia_inversor
- name: Solar Potencia PV1
scan_interval: 5
data_type: int16
input_type: input
unit_of_measurement: W
slave: 1
address: 33
unique_id: sensor.solar_potencia_pv1
- name: Solar Potencia PV2
scan_interval: 5
data_type: int16
input_type: input
unit_of_measurement: W
slave: 1
address: 36
unique_id: sensor.solar_potencia_pv2
- name: Solar bateria carga
scan_interval: 15
data_type: uint16
input_type: input
unit_of_measurement: "%"
slave: 1
address: 20
unique_id: sensor.solar_bateria_carga
I restarted Home Assistant, and I see that it has been connected to the device because I see connections on it every 5 seconds. But, I found on my log some template errors when I tried to use these values:
Logger: homeassistant.helpers.event
Source: helpers/template.py:643
First occurred: 18:18:07 (6 occurrences)
Last logged: 18:18:08
Error while processing template: Template<template=({% set pv1 = states('sensor.solar_potencia_pv1') | float %} {% set pv2 = states('sensor.solar_potencia_pv2') | float %} {{ ((pv1 + pv2)) | round(0, default=0) }}) renders=2>
Error while processing template: Template<template=({% if states('sensor.solar_potencia_bateria')|float <= 0 %} {{ -((states('sensor.solar_potencia_bateria'))|int) }} {% endif %}) renders=2>
Error while processing template: Template<template=({% if states('sensor.solar_potencia_bateria')|float >= 0 %} {{ (states('sensor.solar_potencia_bateria')) }} {% endif %}) renders=2>
Error while processing template: Template<template=({% if states('sensor.solar_potencia_grid')|float <= 0 %} {{ -((states('sensor.solar_potencia_grid'))|int) }} {% endif %}) renders=2>
Error while processing template: Template<template=({% if states('sensor.solar_potencia_grid')|float >= 0 %} {{ (states('sensor.solar_potencia_grid')) }} {% endif %}) renders=2>
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 2307, in strptime
return datetime.strptime(string, fmt)
~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
File "/usr/local/lib/python3.13/_strptime.py", line 674, in _strptime_datetime
tt, fraction, gmtoff_fraction = _strptime(data_string, format)
~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.13/_strptime.py", line 453, in _strptime
raise ValueError("time data %r does not match format %r" %
(data_string, format))
ValueError: time data '1' does not match format '%Y-%m-%dT%H:%M:%S.%fZ'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 641, in async_render
render_result = _render_with_context(self.template, compiled, **kwargs)
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 2977, in _render_with_context
return template.render(**kwargs)
~~~~~~~~~~~~~~~^^^^^^^^^^
File "/usr/local/lib/python3.13/site-packages/jinja2/environment.py", line 1295, in render
self.environment.handle_exception()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
File "/usr/local/lib/python3.13/site-packages/jinja2/environment.py", line 942, in handle_exception
raise rewrite_traceback_stack(source=source)
File "<template>", line 1, in top-level template code
File "/usr/local/lib/python3.13/site-packages/jinja2/sandbox.py", line 401, in call
return __context.call(__obj, *args, **kwargs)
~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 2310, in strptime
raise_no_default("strptime", string)
~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 1975, in raise_no_default
raise ValueError(
...<2 lines>...
)
ValueError: Template error: strptime got invalid input '1' when rendering template '{% set t = now() %} {{ relative_time(strptime(states.input_text.esomeprazol_last.state,"%Y-%m-%dT%H:%M:%S.%fZ" )) }}' but no default was specified
The above exception was the direct cause of the following exception:
This is the template sensors that I’m using:
- sensor:
- name: "Solar Potencia PV"
unit_of_measurement: "W"
state: >
{% set pv1 = states('sensor.solar_potencia_pv1') | float %}
{% set pv2 = states('sensor.solar_potencia_pv2') | float %}
{{ ((pv1 + pv2)) | round(0, default=0) }}
unique_id: sensor.solar_potencia_pv
- name: "Solar Potencia Bateria Carga"
unit_of_measurement: "W"
state: >
{% if states('sensor.solar_potencia_bateria')|float <= 0 %}
{{ -((states('sensor.solar_potencia_bateria'))|int) }}
{% endif %}
unique_id: sensor.solar_potencia_bateria_carga
- name: "Solar Potencia Bateria Descarga"
unit_of_measurement: "W"
state: >
{% if states('sensor.solar_potencia_bateria')|float >= 0 %}
{{ (states('sensor.solar_potencia_bateria')) }}
{% endif %}
unique_id: sensor.solar_potencia_bateria_descarga
- name: "Solar Potencia Red Volcado"
unit_of_measurement: "W"
state: >
{% if states('sensor.solar_potencia_grid')|float <= 0 %}
{{ -((states('sensor.solar_potencia_grid'))|int) }}
{% endif %}
unique_id: sensor.solar_potencia_red_volcado
- name: "Solar Potencia Red Consumo"
unit_of_measurement: "W"
state: >
{% if states('sensor.solar_potencia_grid')|float >= 0 %}
{{ (states('sensor.solar_potencia_grid')) }}
{% endif %}
unique_id: sensor.solar_potencia_red_consumo
It’s worth noticing that I don’t see any of the sensors coming from the tcp integration, only the ones from the template appear in the UI and they appear as unavailable.
For reference, this is the repository I pick the files from: