I have a working Home Assistant configuration reading Modbus values from an Epever inverter.
Some of the returned values are numeric, I would like to convert these numeric values to text to make the dashboard easier to read. eg:
0=Normal, 1=Overvoltage, 2=Undervoltage, 3=Undervoltage Disconnect, 4=Fault
After reading many posts on the subject i still don’t get it, there are code snippets that i could modify but i have no idea where to place this code, templates, configuration.yaml or states?
Could someone give me some advice please?
Kind regards
Ade
Regarding needing help, you could offer more information, such as the sensor, is it an attribute you’re trying to change. What have you come up with that doesn’t work?
Hi RoadkillUK,
Thanks for the tip but i have read this post previously. I tried adding my relevant values and adding it to configuration.yaml but i got errors. Not sure if it should go in configuration.yaml or somewhere else?
Many thanks
Ade
Regarding more info, i’m a bit embarrassed to post code as i see so many folks getting scalded for incorrect formatting of pasted code here. I tried the 3 backticks but it still looks a mess, more stuff i don’t understand.
Here is the beginning and the sensor from configuration.yaml
# Loads default set of integrations. Do not remove.
default_config:
# Load frontend themes from the themes folder
frontend:
themes: !include_dir_merge_named themes
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
modbus:
- name: epever
type: rtuovertcp
host: 192.168.1.170
port: 8088
delay: 5
timeout: 10
message_wait_milliseconds: 30
sensors:
- name: "Battery State 2"
# 0:Normal, 1:Overvoltage, 2:Undervoltage, 3:Undervoltage Disconnect, 4:Fault
slave: 10
address: 0x3589
input_type: input
It is the numeric output from sensor Battery State 2 that i would like to show as a text value on my dashboard EG: Numeric value 0 to show ‘normal’ on the dashboard
If you have the numeric code in an existing sensor, create a template sensor, which you can do via the UI, under Helpers. State template should be (guessing the entity ID from the code above):