devicename: sofarsolar-logger
friendly_name: SofarSolar
hostname: "esp8266-sofar"
comment: "SofarSolar modbus interface"
icon: "mdi:solar-power-variant-outline"
restore_mode: "restore_default_off"
wifi:
ssid: ""
password: ""
fast_connect: true
reboot_timeout: 120s
power_save_mode: none
ap:
ssid: "Fallback-AP-${devicename}"
password: ""
ap_timeout: 300s
api:
password: "TbkEdpMbUuwCNxfU6CK3KHo392"
ota:
password: "TbkEdpMbUuwCNxfU6CK3KHo392"
safe_mode: False
captive_portal:
mdns:
disabled: True
web_server:
port: 80
ota: false
esphome:
name: $devicename
platform: ESP8266
board: esp01_1m
board_flash_mode: dout
comment: SofarSolar Logger (Modbus/RS485)
logger:
level: INFO
baud_rate: 0
status_led:
pin:
number: GPIO2
inverted: true
external_components:
- source:
type: git
url: https://github.com/ssieb/custom_components
components: [ heapmon ]
uart:
id: mod_bus
tx_pin: 1
rx_pin: 3
baud_rate: 9600
stop_bits: 1
modbus:
id: mod_bus_sofar
modbus_controller:
- id: sofarsolar
address: 0x01
modbus_id: mod_bus_sofar
update_interval: 5s
text_sensor:
- platform: template
name: "ESP-Sofar Uptime (human readable)"
id: uptime_human
icon: "mdi:clock-start"
update_interval: 5s
- platform: modbus_controller
modbus_controller_id: sofarsolar
name: ${friendly_name} Status
id: inverter_status
register_type: holding
icon: "mdi:information-outline"
address: 0x0000
response_size: 2
lambda: |-
auto z = "Unknown";
char d = data[item->offset+1];
if (d == 0) z = "Wait";
else if (d == 1) z = "Check";
else if (d == 2) z = "Normal";
else if (d == 3) z = "Fault";
else if (d == 4) z = "Permanent";
return {z};
- platform: modbus_controller
modbus_controller_id: sofarsolar
name: ${friendly_name} Fault Message
id: inverter_fault_message
register_type: holding
icon: "mdi:alert-outline"
address: 0x0001
response_size: 10
lambda: |-
std::string z = "";
int idx = item->offset;
//byte[0]
if ((data[idx] & 0x1) != 0) z += "GridOVP,";
if ((data[idx] & 0x2) != 0) z += "GridUVP,";
if ((data[idx] & 0x4) != 0) z += "GridOFP,";
if ((data[idx] & 0x8) != 0) z += "GridUFP,";
if ((data[idx] & 0x10) != 0) z += "PVUVP,";
if ((data[idx] & 0x20) != 0) z += "GridLVRT,";
if ((data[idx] & 0x40) != 0) z += "reserve-ID7,";
if ((data[idx] & 0x80) != 0) z += "reserve-ID8,";
//byte[1]
idx++;
if ((data[idx] & 0x1) != 0) z += "PVOVP,";
if ((data[idx] & 0x2) != 0) z += "IpvUnbalance,";
if ((data[idx] & 0x4) != 0) z += "PvConfigSetWrong,";
if ((data[idx] & 0x8) != 0) z += "GFCIFault,";
if ((data[idx] & 0x10) != 0) z += "PhaseSequenceFault,";
if ((data[idx] & 0x20) != 0) z += "HwBoostOCP,";
if ((data[idx] & 0x40) != 0) z += "HwAcOCP,";
if ((data[idx] & 0x80) != 0) z += "AcRmsOCP,";
//byte[2]
idx++;
if ((data[idx] & 0x1) != 0) z += "HwADFaultIGrid,";
if ((data[idx] & 0x2) != 0) z += "HwADFaultDCI,";
if ((data[idx] & 0x4) != 0) z += "HwADFaultVGrid,";
if ((data[idx] & 0x8) != 0) z += "GFCIDeviceFault,";
if ((data[idx] & 0x10) != 0) z += "MChip_Fault,";
if ((data[idx] & 0x20) != 0) z += "HwAuxPowerFault,";
if ((data[idx] & 0x40) != 0) z += "BusVoltZeroFault,";
if ((data[idx] & 0x80) != 0) z += "IacRmsUnbalance,";
//byte[3]
idx++;
if ((data[idx] & 0x1) != 0) z += "BusUVP,";
if ((data[idx] & 0x2) != 0) z += "BusOVP,";
if ((data[idx] & 0x4) != 0) z += "VbusUnbalance,";
if ((data[idx] & 0x8) != 0) z += "DciOCP,";
if ((data[idx] & 0x10) != 0) z += "SwOCPInstant,";
if ((data[idx] & 0x20) != 0) z += "SwBOCPInstant,";
if ((data[idx] & 0x40) != 0) z += "reserved-ID31,";
if ((data[idx] & 0x80) != 0) z += "reserved-ID32,";
//byte[4]
idx++;
if (data[idx] != 0) z += "reserved-ID33~40,";
//byte[5]
idx++;
if (data[idx] != 0) z += "reserved-ID41~48,";
//byte[6]
idx++;
if ((data[idx] & 0x1) != 0) z += "ConsistentFault_VGrid,";
if ((data[idx] & 0x2) != 0) z += "ConsistentFault_FGrid,";
if ((data[idx] & 0x4) != 0) z += "ConsistentFault_DCI,";
if ((data[idx] & 0x8) != 0) z += "ConsistentFault_GFCI,";
if ((data[idx] & 0x10) != 0) z += "SpiCommLose,";
if ((data[idx] & 0x20) != 0) z += "SciCommLose,";
if ((data[idx] & 0x40) != 0) z += "RelayTestFail,";
if ((data[idx] & 0x80) != 0) z += "PvIsoFault,";
//byte[7]
idx++;
if ((data[idx] & 0x1) != 0) z += "OverTempFault_Inv,";
if ((data[idx] & 0x2) != 0) z += "OverTempFault_Boost,";
if ((data[idx] & 0x4) != 0) z += "OverTempFault_Env,";
if ((data[idx] & 0x8) != 0) z += "PEConnectFault,";
if ((data[idx] & 0x10) != 0) z += "reserved-ID61,";
if ((data[idx] & 0x20) != 0) z += "reserved-ID62,";
if ((data[idx] & 0x40) != 0) z += "reserved-ID63,";
if ((data[idx] & 0x80) != 0) z += "reserved-ID64,";
//byte[8]
idx++;
if ((data[idx] & 0x1) != 0) z += "unrecoverHwAcOCP,";
if ((data[idx] & 0x2) != 0) z += "unrecoverBusOVP,";
if ((data[idx] & 0x4) != 0) z += "unrecoverIacRmsUnbalance,";
if ((data[idx] & 0x8) != 0) z += "unrecoverIpvUnbalance,";
if ((data[idx] & 0x10) != 0) z += "unrecoverVbusUnbalance,";
if ((data[idx] & 0x20) != 0) z += "unrecoverOCPInstant,";
if ((data[idx] & 0x40) != 0) z += "unrecoverPvConfigSetWrong,";
if ((data[idx] & 0x80) != 0) z += "reserved-ID72,";
//byte[9]
idx++;
if ((data[idx] & 0x1) != 0) z += "reserved-ID73,";
if ((data[idx] & 0x2) != 0) z += "unrecoverIPVInstant,";
if ((data[idx] & 0x4) != 0) z += "unrecoverWRITEEEPROM,";
if ((data[idx] & 0x8) != 0) z += "unrecoverREADEEPROM,";
if ((data[idx] & 0x10) != 0) z += "unrecoverRelayFail,";
if ((data[idx] & 0x20) != 0) z += "reserved-ID78,";
if ((data[idx] & 0x40) != 0) z += "reserved-ID79,";
if ((data[idx] & 0x80) != 0) z += "reserved-ID80,";
if(z.length() > 0){
z.pop_back();
}
return {z};
sensor:
- platform: wifi_signal
id: inverter_wifi_signal
name: "ESP-Sofar WiFi Signal"
update_interval: 60s
icon: "mdi:wifi"
- platform: uptime
id: inverter_uptime
name: "ESP-Sofar Uptime"
filters:
- lambda: return x / 60.0;
unit_of_measurement: minutes
icon: "mdi:clock-start"
- platform: heapmon
id: heapspace
name: "ESP-Sofar Heapsize"
icon: "mdi:memory"
update_interval: 5s
- platform: modbus_controller
modbus_controller_id: sofarsolar
name: ${friendly_name} DC1 Voltage
id: inverter_dc_v1
register_type: holding
address: 0x0006
unit_of_measurement: "V"
state_class: "measurement"
device_class: "voltage"
icon: "mdi:alpha-v-circle-outline"
value_type: U_WORD
accuracy_decimals: 1
filters:
- multiply: 0.1
- platform: modbus_controller
modbus_controller_id: sofarsolar
name: ${friendly_name} DC1 Current
id: inverter_dc_c1
register_type: holding
address: 0x0007
unit_of_measurement: "A"
state_class: "measurement"
device_class: "current"
icon: "mdi:alpha-a-circle-outline"
value_type: U_WORD
accuracy_decimals: 2
filters:
- multiply: 0.01
- platform: modbus_controller
modbus_controller_id: sofarsolar
name: ${friendly_name} DC2 Voltage
id: inverter_dc_v2
register_type: holding
address: 0x0008
unit_of_measurement: "V"
state_class: "measurement"
device_class: "voltage"
icon: "mdi:alpha-v-circle-outline"
value_type: U_WORD
accuracy_decimals: 1
filters:
- multiply: 0.1
- platform: modbus_controller
modbus_controller_id: sofarsolar
name: ${friendly_name} DC2 Current
id: inverter_dc_c2
register_type: holding
address: 0x0009
unit_of_measurement: "A"
state_class: "measurement"
device_class: "current"
icon: "mdi:alpha-a-circle-outline"
value_type: U_WORD
accuracy_decimals: 2
filters:
- multiply: 0.01
- platform: modbus_controller
modbus_controller_id: sofarsolar
name: ${friendly_name} DC1 Power
id: inverter_dc_power1
register_type: holding
address: 0x000a
unit_of_measurement: "W"
state_class: "measurement"
device_class: "power"
icon: "mdi:solar-power"
value_type: U_WORD
filters:
- multiply: 10
- platform: modbus_controller
modbus_controller_id: sofarsolar
name: ${friendly_name} DC2 Power
id: inverter_dc_power2
register_type: holding
address: 0x000b
unit_of_measurement: "W"
state_class: "measurement"
device_class: "power"
icon: "mdi:solar-power"
value_type: U_WORD
filters:
- multiply: 10
- platform: modbus_controller
modbus_controller_id: sofarsolar
name: ${friendly_name} AC Power
id: inverter_ac_power
register_type: holding
address: 0x000c
unit_of_measurement: "W"
state_class: "measurement"
device_class: "power"
icon: "mdi:solar-power-variant-outline"
value_type: U_WORD
filters:
- multiply: 10
- platform: modbus_controller
modbus_controller_id: sofarsolar
name: ${friendly_name} AC Reactive Power
id: inverter_ac_reactive_power
register_type: holding
address: 0x000d
unit_of_measurement: "kVar"
state_class: "measurement"
icon: "mdi:math-cos"
value_type: S_WORD
filters:
- multiply: 10
- platform: modbus_controller
modbus_controller_id: sofarsolar
name: ${friendly_name} AC Freq
id: inverter_ac_freq
register_type: holding
address: 0x000e
unit_of_measurement: "Hz"
state_class: "measurement"