Here are my yaml files:
configuration.yaml
Some original values are still there but commented in case I need to roll back.
#sensor: !include sensors.yaml -- deprecated; use template instead (https://community.home-assistant.io/t/where-to-place-template-code-and-how-to-add-the-template-integration/504260/2)
template: !include templates.yaml
modbus:
- name: conext_combox
type: tcp
host: 192.168.30.119
port: 502
delay: 2
timeout: 15
sensors:
#conext_combox device over Modbus: CSW4048 0 - Bus ID:2, Bus address:1, Modbus Slave Address (Port 502 [503 is for gateway]): 90
- name: ‘SW Operating Mode’
data_type: uint16
input_type: holding #input
slave: 90
address: 243
unique_id: SW4048_Operating_Mode
- name: ‘SW Device State’
data_type: uint16
input_type: holding #input
slave: 90
address: 65
unique_id: SW4048_Device_State
- name: ‘SW Inverter Enabled’
data_type: uint16
input_type: holding #input
slave: 90
address: 67
unique_id: SW4048_Inverter_Enabled
- name: ‘SW Charger Enabled’
data_type: uint16
input_type: holding #input
slave: 90
address: 68
unique_id: SW4048_Charger_Enabled
- name: ‘SW Active Faults’
data_type: uint16
input_type: holding #input
slave: 90
address: 69
unique_id: SW4048_Active_Faults
- name: ‘SW Active Warnings’
data_type: uint16
input_type: holding #input
slave: 90
address: 70
unique_id: SW4048_Active_Warnings
- name: ‘SW Inverter Status’
data_type: uint16
input_type: holding #input
slave: 90
address: 75
unique_id: SW4048_Inverter_Status
- name: ‘SW Battery Voltage’
data_type: uint16
input_type: holding #input
slave: 90
address: 78
#unit_of_measurement: V
scale: 0.001
precision: 2
unique_id: SW4048_Battery_Voltage
- name: ‘SW Battery Current’
data_type: int16
input_type: holding #input
#count: 2
slave: 90
address: 80
unit_of_measurement: A
scale: 0.001
offset: 0
precision: 3
unique_id: SW4048_Battery_Current
- name: ‘SW Battery Power’
data_type: int16
input_type: holding #input
#count: 2
slave: 90
address: 82
scale: 1
offset: 0
precision: 0
#device_class: power
unit_of_measurement: W
unique_id: SW4048_Battery_Power
- name: ‘SW Battery Temperature’
data_type: uint16
input_type: holding #input
slave: 90
address: 84
scale: 0.01
offset: -273
precision: 2
device_class: temperature
unit_of_measurement: °C
unique_id: SW4048_Battery_Temp
- name: ‘SW Charger Status’
data_type: uint16
input_type: holding #input
slave: 90
address: 85
unique_id: SW4048_Charger_Status
- name: ‘SW AC1 Frequency’
data_type: uint16
input_type: holding #input
slave: 90
address: 95
unit_of_measurement: Hz
scale: 0.01
offset: 0
precision: 2
unique_id: SW4048_AC1_Freq
- name: ‘SW AC1 Voltage’
data_type: uint16
input_type: holding #input
#count: 2
slave: 90
address: 96
unit_of_measurement: V
scale: 0.001
offset: 0
precision: 3
unique_id: SW4048_AC1_Voltage
- name: ‘SW AC1 Input Current’
data_type: int16
input_type: holding #input
#count: 2
slave: 90
address: 98
unit_of_measurement: A
scale: 0.001
offset: 0
precision: 3
unique_id: SW4048_AC1_Input_Current
- name: ‘SW AC1 Input Power’
data_type: int16
input_type: holding #input
#count: 2
slave: 90
address: 100
scale: 1
offset: 0
precision: 0
#device_class: power
unit_of_measurement: W
unique_id: SW4048_AC1_Input_Power
- name: ‘SW Load AC Voltage’
data_type: uint16
input_type: holding #input
#count: 2
slave: 90
address: 120
unit_of_measurement: V
scale: 0.001
offset: 0
precision: 3
unique_id: SW4048_Load_AC_Voltage
- name: ‘SW Load AC Current’
data_type: int16
input_type: holding #input
#count: 2
slave: 90
address: 130
unit_of_measurement: A
scale: 0.001
offset: 0
precision: 3
unique_id: SW4048_Load_AC_Current
- name: ‘SW Load AC Power’
data_type: int16
input_type: holding #input
#count: 2
slave: 90
address: 132
#device_class: power
unit_of_measurement: W
scale: 1
offset: 0
precision: 0
unique_id: SW4048_Load_AC_Power
- name: ‘SW Load AC Frequency’
data_type: uint16
input_type: holding #input
slave: 90
address: 138
unit_of_measurement: Hz
scale: 0.01
offset: 0
precision: 2
unique_id: SW4048_Load_AC_Freq
- name: ‘SW Energy From Battery This Hour’
data_type: int16
input_type: holding #input
#count: 2
slave: 90
address: 144
unit_of_measurement: kWh
scale: 0.001
offset: 0
precision: 0
unique_id: SW4048_Energy_fr_Batt_This_Hour
- name: ‘SW Battery Discharge Active This Hour’
data_type: int16
input_type: holding #input
#count: 2
slave: 90
address: 146
unit_of_measurement: kWh
scale: 0.001
offset: 0
precision: 0
unique_id: SW4048_Batt_Dischg_Active_This_Hour
- name: ‘SW AC1 Net Power’
data_type: int16
input_type: holding #input
#count: 2
slave: 90
address: 346
scale: 1
offset: 0
precision: 0
#device_class: power
unit_of_measurement: W
unique_id: SW4048_AC1_Net_Power
- name: ‘SW AC1 Net Current’
data_type: int16
input_type: holding #input
#count: 2
slave: 90
address: 344
unit_of_measurement: A
scale: 0.001
offset: 0
precision: 3
unique_id: SW4048_AC1_Net_Current
#data_type: int16, uint32, float, string, custom (default int)
#count: 1, 2 (default 1 for 16-bit register, 2 for 32-bit register)
#input_type: holding, input (default holding)
#CSW4048 0 - Bus ID:2, Bus Address:1, Modbus Slave Address (Port 502): 90
#MPPT60 0 - Bus ID:2, Bus Address:2, Modbus Slave Address (Port 502): 30 -- charge controller
#BattMon 0 - Bus ID:2, Bus Address:3, Modbus Slave Address (Port 502): 42
#Conext Combox xxx.xxx.xxx.xxx, Port 502
templates.yaml (replaces sensors.yaml)
(Emma is my dog, and I often find myself saying, “Uh oh, Emma” when something goes wrong, so I used that as the default when another status does not apply.)
#conext_combox device over Modbus
#Does not include templates for Battery Monitor and MPPT charge controller
sensor:
- name: "template-SW Operating Mode"
state: >-
{{ {"2": "Standby",
"3": "Operating"}.get(states('sensor.sw_operating_mode'), 'Uh oh Emma') }}
unique_id: "SW4048_operating_mode_template"
- name: "template-Inverter Device State"
state: >-
{{ {"0": "Hibernate",
"1": "Power Save",
"2": "Safe Mode",
"3": "Operating",
"4": "Diagnostic Mode",
"5": "Remote Power Off",
"255": "Data Not Available"}.get(states('sensor.sw_device_state'), 'Uh oh Emma') }}
unique_id: "SW4048_inverter_device_state_template"
- name: "template-Inverter Enabled"
state: >-
{{ {"0": "Standby",
"1": "Operating"}.get(states('sensor.sw_inverter_enabled'), 'Uh oh Emma') }}
unique_id: "SW4048_inverter_enabled_template"
- name: "template-Charger Enabled"
state: >-
{{ {"0": "Standby",
"1": "Operating"}.get(states('sensor.sw_charger_enabled'), 'Uh oh Emma') }}
unique_id: "SW4048_charger_enabled_template"
- name: "template-Active Faults"
state: >-
{{ {"0": "No Active Faults",
"1": "Has Active Faults"}.get(states('sensor.sw_active_faults'), 'Uh oh Emma') }}
unique_id: "SW4048_active_faults_template"
- name: "template-Active Warnings"
state: >-
{{ {"0": "No Active Warnings",
"1": "Has Active Warnings"}.get(states('sensor.sw_active_warnings'), 'Uh oh Emma') }}
unique_id: "SW4048_active_warnings_template"
- name: "template-Charger Status"
state: >-
{{ {"768": "Not Charging",
"769": "Bulk",
"770": "Absorption",
"771": "Overcharge",
"772": "Equalize",
"773": "Float",
"774": "No Float",
"775": "Constant VI",
"776": "Charger Disabled",
"777": "Qualifying AC",
"778": "Qualifying APS",
"779": "Engaging Charger",
"780": "Charge Fault",
"781": "Charger Suspend",
"782": "AC Good",
"783": "APS Good",
"784": "AC Fault",
"785": "Charge",
"786": "Absorption Exit Pending",
"787": "Ground Fault",
"788": "AC Good Pending",
"789": "Load Shaving",
"790": "AC Support",
"791": "Coupled",
"792": "Coupled Bulk",
"793": "Coupled Absorption",
"794": "Coupled Float",
"795": "AC Coupled No Float",
"796": "External BMS",
"797": "Load Sense"}.get(states('sensor.sw_charger_status'), 'Uh oh Emma') }}
unique_id: "SW4048_charger_status_template"
- name: "template-Inverter Status"
state: >-
{{ {"1024": "Invert",
"1025": "AC Pass Through",
"1026": "APS Only",
"1027": "Load Sense",
"1028": "Inverter Disabled",
"1029": "Load Sense Ready",
"1030": "Engaging Inverter",
"1031": "Invert Fault",
"1032": "Inverter Standby",
"1033": "Grid-Tied",
"1034": "Grid Support",
"1035": "Gen Support",
"1036": "Sell-to-Grid",
"1037": "Load Shaving",
"1038": "Grid Frequency Stabilization",
"1039": "AC Coupling",
"1040": "Reverse Ibatt"}.get(states('sensor.sw_inverter_status'), 'Uh oh Emma') }}
unique_id: "SW4048_inverter_status_template"