I’m facing an issue with my Home Assistant setup involving a Modbus integration with the Epever UP HI inverter. Specifically, the entity representing the battery state on my dashboard displays ‘0’ instead of ‘Normal’. Here’s the relevant sensor template configuration I’m using:
sensor:
platform: template
sensors:
estado_da_bateria_text:
friendly_name: “Battery State”
value_template: >
{% set state = states(‘sensor.modbus_hub_Estado_da_Bateria_10_0x3553’) | int %}
{% set d0 = state & 1 %}
{% set d1 = (state & 2) >> 1 %}
{% set d2 = (state & 4) >> 2 %}
{% set d3 = (state & 8) >> 3 %}
{% set d4 = (state & 16) >> 4 %}
{% if d0 == 0 and d1 == 0 and d2 == 0 and d3 == 0 and d4 == 0 %}
Normal
{% elif d0 != 0 %}
Overvoltage
{% elif d1 != 0 %}
Undervoltage
{% elif d2 != 0 %}
Over discharge
{% elif d4 != 0 %}
Fault
{% else %}
Unknown
{% endif %}
Despite this configuration, the entity on the dashboard displays ‘0’ instead of ‘Normal’. The error reported by Home Assistant is:
Invalid config for ‘template’ from integration ‘sensor’ at configuration.yaml, line 194: invalid template (TemplateSyntaxError: unexpected char ‘&’ at 98)
hey man sorry i can t help you with this, but im using same inverter UP HI can you send me the configuration.yaml ? its not working with me…
my current setup is:
inverter connected to ATC-1200 serial to tcp/ip.
i have the software working on my PC using virtual COM port and even using TCP connection to the converter…
but with HomeAssistant its not working.
modbus:
- name: epever
type: serial
method: rtu
port: /dev/ttyS0
baudrate: 115200
bytesize: 8
stopbits: 1
parity: N
timeout: 10
Note: Replace IP_ADDRESS with the IP address of your device. Modbus TCP is generally more reliable, while Modbus UDP can be faster but with less delivery guarantee. Choose the protocol that best meets your needs.