HA with Victron with modbus

i was able to integrate Victron (RPI) with modbus in HA

i got the data in HA :slight_smile:

now in am trying to show text instead of value for the Solar Panel

‘0’ : ‘Off’, ‘2’ : ‘Fault’, ‘3’ : ‘Bulk’, ‘4’ : ‘Absorption’,‘5’ : ‘Float’

My formula work in developer Tool but not sure where to put this in the Configuration

  1. V-775-MQTT Charge State:
  2. 0=Off;2=Fault;3=Bulk;4=Absorption;5=Float;6=Storage;7=Equalize;11=Other (Hub-1);252=External control

  • value_template: >-
  1. {% set mapper = {‘0’ : ‘Off’, ‘2’ : ‘Fault’, ‘3’ : ‘Bulk’, ‘4’ : ‘Absorption’,‘5’ : ‘Float’ } %}
  2. {% set state = states.sensor.v_775_mqtt_charge_state.state %}
  3. {{ mapper[state] if state in mapper else ‘Unknown’ }}

My config

modbus: !include modbus.yaml


/config/modbus.yaml

modbus:

  • name: victron

type: tcp

host: 192.168.X.XX

port: 502

sensors:

  • name: “V-775-MQTT Charge State”

slave: 239

address: 775


Any help would be appreciate!

image|655x373

template:
  - sensor:
      - name: "Charge State"
        state: >
          {% set mapper = {‘0’ : ‘Off’, ‘2’ : ‘Fault’, ‘3’ : ‘Bulk’, ‘4’ : ‘Absorption’,‘5’ : ‘Float’ } %}
          {% set state = states.sensor.v_775_mqtt_charge_state.state %}
          {{ mapper[state] if state in mapper else ‘Unknown’ }}
          
1 Like

i add this to the configuration yaml… but the sensor/entity does not show up

it working…

Tks a lot :slight_smile: