Hi all,
New to this whole HA thing still and I am struggling to get my output from my inverter from a integer value to a text value.
My sensor the integer value comes from is called “sensor.inverter_state”
This is working - I get the different values based on the modbus connector.
The values it can display are as follows:
0=Off
1=Low Power
2=Fault
3=Bulk
4=Absorption
5=Float
6=Storage
7=Equalize
8=Passthru
9=Inverting
10=Power assist
11=Power supply
252=Bulk protection
Under my configuration.yaml I have the following:
- platform: template
sensors:
sensor_inverter_state:
friendly_name: "Inverter State Text"
unit_of_measurement: "State"
value_template: >-
{% set mapper = {
'0' : 'Off',
'1' : 'Low Power',
'2' : 'Fault',
'3' : 'Bulk',
'4' : 'Absorption',
'5' : 'Float',
'6' : 'Storage',
'7' : 'Equalize',
'8' : 'Passthrough',
'9' : 'Inverting',
'10' : 'Power',
'11' : 'Power Supply'
'12' : 'Bulk Protection' } %}
{% set state = states.sensor.inverter_state_text.state %}
{{ mapper[state] if state in mapper else 'Unknown' }}
Not sure I am understanding this template correctly but I’d essentially take the input from ‘sensor.inverter_state’ and output it to ‘sensor.inverter_state_text’ after the mapping takes place.
My issue is I don’t see sensor ‘sensor.inverter_state_text’