This paste brought to you by paste.linuxiarz.pl. View Raw

  1. substitutions:
  2.   devicename: sofarsolar-logger
  3.   friendly_name: SofarSolar
  4.   hostname: "esp8266-sofar"
  5.   comment: "SofarSolar modbus interface"
  6.   icon: "mdi:solar-power-variant-outline"
  7.   restore_mode: "restore_default_off"
  8.  
  9. wifi:
  10.   ssid: ""
  11.   password: ""
  12.   fast_connect: true
  13.   reboot_timeout: 120s
  14.   power_save_mode: none
  15.  
  16.   ap:
  17.     ssid: "Fallback-AP-${devicename}"
  18.     password: ""
  19.     ap_timeout: 300s
  20.  
  21. api:
  22.   password: "TbkEdpMbUuwCNxfU6CK3KHo392"
  23.  
  24. ota:
  25.   password: "TbkEdpMbUuwCNxfU6CK3KHo392"
  26.   safe_mode: False
  27.  
  28. captive_portal:
  29.  
  30. mdns:
  31.   disabled: True
  32.  
  33. web_server:
  34.   port: 80
  35.   ota: false
  36.  
  37. esphome:
  38.   name: $devicename
  39.   platform: ESP8266
  40.   board: esp01_1m
  41.   board_flash_mode: dout
  42.   comment: SofarSolar Logger (Modbus/RS485)
  43.  
  44. logger:
  45.     level: INFO
  46.     baud_rate: 0
  47.    
  48. status_led:
  49.   pin:
  50.     number: GPIO2
  51.     inverted: true
  52.  
  53. external_components:
  54.   - source:
  55.       type: git
  56.       url: https://github.com/ssieb/custom_components
  57.     components: [ heapmon ]
  58.  
  59. uart:
  60.   id: mod_bus
  61.   tx_pin: 1
  62.   rx_pin: 3
  63.   baud_rate: 9600
  64.   stop_bits: 1
  65.  
  66. modbus:
  67.   id: mod_bus_sofar
  68.  
  69. modbus_controller:
  70.   - id: sofarsolar
  71.     address: 0x01
  72.     modbus_id: mod_bus_sofar
  73.     update_interval: 5s
  74.  
  75. text_sensor:
  76.  
  77.   - platform: template
  78.     name: "ESP-Sofar Uptime (human readable)"
  79.     id: uptime_human
  80.     icon: "mdi:clock-start"
  81.     update_interval: 5s
  82.    
  83.   - platform: modbus_controller
  84.     modbus_controller_id: sofarsolar
  85.     name: ${friendly_name} Status
  86.     id: inverter_status
  87.     register_type: holding
  88.     icon: "mdi:information-outline"
  89.     address: 0x0000
  90.     response_size: 2
  91.     lambda: |-
  92.       auto z = "Unknown";
  93.       char d = data[item->offset+1];
  94.       if (d == 0) z = "Wait";
  95.       else if (d == 1) z = "Check";
  96.       else if (d == 2) z = "Normal";
  97.       else if (d == 3) z = "Fault";
  98.       else if (d == 4) z = "Permanent";
  99.       return {z};
  100.  
  101.   - platform: modbus_controller
  102.     modbus_controller_id: sofarsolar
  103.     name: ${friendly_name} Fault Message
  104.     id: inverter_fault_message
  105.     register_type: holding
  106.     icon: "mdi:alert-outline"
  107.     address: 0x0001
  108.     response_size: 10
  109.     lambda: |-
  110.       std::string z = "";
  111.       int idx = item->offset;
  112.       //byte[0]
  113.       if ((data[idx] & 0x1) != 0) z += "GridOVP,";
  114.       if ((data[idx] & 0x2) != 0) z += "GridUVP,";
  115.       if ((data[idx] & 0x4) != 0) z += "GridOFP,";
  116.       if ((data[idx] & 0x8) != 0) z += "GridUFP,";
  117.       if ((data[idx] & 0x10) != 0) z += "PVUVP,";
  118.       if ((data[idx] & 0x20) != 0) z += "GridLVRT,";
  119.       if ((data[idx] & 0x40) != 0) z += "reserve-ID7,";
  120.       if ((data[idx] & 0x80) != 0) z += "reserve-ID8,";
  121.       //byte[1]
  122.       idx++;
  123.       if ((data[idx] & 0x1) != 0) z += "PVOVP,";
  124.       if ((data[idx] & 0x2) != 0) z += "IpvUnbalance,";
  125.       if ((data[idx] & 0x4) != 0) z += "PvConfigSetWrong,";
  126.       if ((data[idx] & 0x8) != 0) z += "GFCIFault,";
  127.       if ((data[idx] & 0x10) != 0) z += "PhaseSequenceFault,";
  128.       if ((data[idx] & 0x20) != 0) z += "HwBoostOCP,";
  129.       if ((data[idx] & 0x40) != 0) z += "HwAcOCP,";
  130.       if ((data[idx] & 0x80) != 0) z += "AcRmsOCP,";
  131.       //byte[2]
  132.       idx++;
  133.       if ((data[idx] & 0x1) != 0) z += "HwADFaultIGrid,";
  134.       if ((data[idx] & 0x2) != 0) z += "HwADFaultDCI,";
  135.       if ((data[idx] & 0x4) != 0) z += "HwADFaultVGrid,";
  136.       if ((data[idx] & 0x8) != 0) z += "GFCIDeviceFault,";
  137.       if ((data[idx] & 0x10) != 0) z += "MChip_Fault,";
  138.       if ((data[idx] & 0x20) != 0) z += "HwAuxPowerFault,";
  139.       if ((data[idx] & 0x40) != 0) z += "BusVoltZeroFault,";
  140.       if ((data[idx] & 0x80) != 0) z += "IacRmsUnbalance,";
  141.       //byte[3]
  142.       idx++;
  143.       if ((data[idx] & 0x1) != 0) z += "BusUVP,";
  144.       if ((data[idx] & 0x2) != 0) z += "BusOVP,";
  145.       if ((data[idx] & 0x4) != 0) z += "VbusUnbalance,";
  146.       if ((data[idx] & 0x8) != 0) z += "DciOCP,";
  147.       if ((data[idx] & 0x10) != 0) z += "SwOCPInstant,";
  148.       if ((data[idx] & 0x20) != 0) z += "SwBOCPInstant,";
  149.       if ((data[idx] & 0x40) != 0) z += "reserved-ID31,";
  150.       if ((data[idx] & 0x80) != 0) z += "reserved-ID32,";
  151.       //byte[4]
  152.       idx++;
  153.       if (data[idx] != 0) z += "reserved-ID33~40,";
  154.       //byte[5]
  155.       idx++;
  156.       if (data[idx] != 0) z += "reserved-ID41~48,";
  157.       //byte[6]
  158.       idx++;
  159.       if ((data[idx] & 0x1) != 0) z += "ConsistentFault_VGrid,";
  160.       if ((data[idx] & 0x2) != 0) z += "ConsistentFault_FGrid,";
  161.       if ((data[idx] & 0x4) != 0) z += "ConsistentFault_DCI,";
  162.       if ((data[idx] & 0x8) != 0) z += "ConsistentFault_GFCI,";
  163.       if ((data[idx] & 0x10) != 0) z += "SpiCommLose,";
  164.       if ((data[idx] & 0x20) != 0) z += "SciCommLose,";
  165.       if ((data[idx] & 0x40) != 0) z += "RelayTestFail,";
  166.       if ((data[idx] & 0x80) != 0) z += "PvIsoFault,";
  167.       //byte[7]
  168.       idx++;
  169.       if ((data[idx] & 0x1) != 0) z += "OverTempFault_Inv,";
  170.       if ((data[idx] & 0x2) != 0) z += "OverTempFault_Boost,";
  171.       if ((data[idx] & 0x4) != 0) z += "OverTempFault_Env,";
  172.       if ((data[idx] & 0x8) != 0) z += "PEConnectFault,";
  173.       if ((data[idx] & 0x10) != 0) z += "reserved-ID61,";
  174.       if ((data[idx] & 0x20) != 0) z += "reserved-ID62,";
  175.       if ((data[idx] & 0x40) != 0) z += "reserved-ID63,";
  176.       if ((data[idx] & 0x80) != 0) z += "reserved-ID64,";
  177.       //byte[8]
  178.       idx++;
  179.       if ((data[idx] & 0x1) != 0) z += "unrecoverHwAcOCP,";
  180.       if ((data[idx] & 0x2) != 0) z += "unrecoverBusOVP,";
  181.       if ((data[idx] & 0x4) != 0) z += "unrecoverIacRmsUnbalance,";
  182.       if ((data[idx] & 0x8) != 0) z += "unrecoverIpvUnbalance,";
  183.       if ((data[idx] & 0x10) != 0) z += "unrecoverVbusUnbalance,";
  184.       if ((data[idx] & 0x20) != 0) z += "unrecoverOCPInstant,";
  185.       if ((data[idx] & 0x40) != 0) z += "unrecoverPvConfigSetWrong,";
  186.       if ((data[idx] & 0x80) != 0) z += "reserved-ID72,";
  187.       //byte[9]
  188.       idx++;
  189.       if ((data[idx] & 0x1) != 0) z += "reserved-ID73,";
  190.       if ((data[idx] & 0x2) != 0) z += "unrecoverIPVInstant,";
  191.       if ((data[idx] & 0x4) != 0) z += "unrecoverWRITEEEPROM,";
  192.       if ((data[idx] & 0x8) != 0) z += "unrecoverREADEEPROM,";
  193.       if ((data[idx] & 0x10) != 0) z += "unrecoverRelayFail,";
  194.       if ((data[idx] & 0x20) != 0) z += "reserved-ID78,";
  195.       if ((data[idx] & 0x40) != 0) z += "reserved-ID79,";
  196.       if ((data[idx] & 0x80) != 0) z += "reserved-ID80,";
  197.       if(z.length() > 0){
  198.         z.pop_back();
  199.       }
  200.       return {z};
  201.  
  202. sensor:
  203.   - platform: wifi_signal
  204.     id: inverter_wifi_signal
  205.     name: "ESP-Sofar WiFi Signal"
  206.     update_interval: 60s
  207.     icon: "mdi:wifi"
  208.  
  209.   - platform: uptime
  210.     id: inverter_uptime
  211.     name: "ESP-Sofar Uptime"
  212.     filters:
  213.       - lambda: return x / 60.0;
  214.     unit_of_measurement: minutes
  215.     icon: "mdi:clock-start"
  216.  
  217.   - platform: heapmon  
  218.     id: heapspace  
  219.     name: "ESP-Sofar Heapsize"
  220.     icon: "mdi:memory"
  221.     update_interval: 5s
  222.  
  223.   - platform: modbus_controller
  224.     modbus_controller_id: sofarsolar
  225.     name: ${friendly_name} DC1 Voltage
  226.     id: inverter_dc_v1
  227.     register_type: holding
  228.     address: 0x0006
  229.     unit_of_measurement: "V"
  230.     state_class: "measurement"
  231.     device_class: "voltage"
  232.     icon: "mdi:alpha-v-circle-outline"
  233.     value_type: U_WORD
  234.     accuracy_decimals: 1
  235.     filters:
  236.       - multiply: 0.1
  237.  
  238.   - platform: modbus_controller
  239.     modbus_controller_id: sofarsolar
  240.     name: ${friendly_name} DC1 Current
  241.     id: inverter_dc_c1
  242.     register_type: holding
  243.     address: 0x0007
  244.     unit_of_measurement: "A"
  245.     state_class: "measurement"
  246.     device_class: "current"
  247.     icon: "mdi:alpha-a-circle-outline"
  248.     value_type: U_WORD
  249.     accuracy_decimals: 2
  250.     filters:
  251.       - multiply: 0.01
  252.  
  253.   - platform: modbus_controller
  254.     modbus_controller_id: sofarsolar
  255.     name: ${friendly_name} DC2 Voltage
  256.     id: inverter_dc_v2
  257.     register_type: holding
  258.     address: 0x0008
  259.     unit_of_measurement: "V"
  260.     state_class: "measurement"
  261.     device_class: "voltage"
  262.     icon: "mdi:alpha-v-circle-outline"
  263.     value_type: U_WORD
  264.     accuracy_decimals: 1
  265.     filters:
  266.       - multiply: 0.1
  267.  
  268.   - platform: modbus_controller
  269.     modbus_controller_id: sofarsolar
  270.     name: ${friendly_name} DC2 Current
  271.     id: inverter_dc_c2
  272.     register_type: holding
  273.     address: 0x0009
  274.     unit_of_measurement: "A"
  275.     state_class: "measurement"
  276.     device_class: "current"
  277.     icon: "mdi:alpha-a-circle-outline"
  278.     value_type: U_WORD
  279.     accuracy_decimals: 2
  280.     filters:
  281.       - multiply: 0.01
  282.  
  283.   - platform: modbus_controller
  284.     modbus_controller_id: sofarsolar
  285.     name: ${friendly_name} DC1 Power
  286.     id: inverter_dc_power1
  287.     register_type: holding
  288.     address: 0x000a
  289.     unit_of_measurement: "W"
  290.     state_class: "measurement"
  291.     device_class: "power"
  292.     icon: "mdi:solar-power"
  293.     value_type: U_WORD
  294.     filters:
  295.       - multiply: 10
  296.  
  297.   - platform: modbus_controller
  298.     modbus_controller_id: sofarsolar
  299.     name: ${friendly_name} DC2 Power
  300.     id: inverter_dc_power2
  301.     register_type: holding
  302.     address: 0x000b
  303.     unit_of_measurement: "W"
  304.     state_class: "measurement"
  305.     device_class: "power"
  306.     icon: "mdi:solar-power"
  307.     value_type: U_WORD
  308.     filters:
  309.       - multiply: 10
  310.  
  311.   - platform: modbus_controller
  312.     modbus_controller_id: sofarsolar
  313.     name: ${friendly_name} AC Power
  314.     id: inverter_ac_power
  315.     register_type: holding
  316.     address: 0x000c
  317.     unit_of_measurement: "W"
  318.     state_class: "measurement"
  319.     device_class: "power"
  320.     icon: "mdi:solar-power-variant-outline"
  321.     value_type: U_WORD
  322.     filters:
  323.       - multiply: 10
  324.  
  325.   - platform: modbus_controller
  326.     modbus_controller_id: sofarsolar
  327.     name: ${friendly_name} AC Reactive Power
  328.     id: inverter_ac_reactive_power
  329.     register_type: holding
  330.     address: 0x000d
  331.     unit_of_measurement: "kVar"
  332.     state_class: "measurement"
  333.     #device_class: "reactive_power"
  334.     icon: "mdi:math-cos"
  335.     value_type: S_WORD
  336.     filters:
  337.       - multiply: 10
  338.  
  339.   - platform: modbus_controller
  340.     modbus_controller_id: sofarsolar
  341.     name: ${friendly_name} AC Freq
  342.     id: inverter_ac_freq
  343.     register_type: holding
  344.     address: 0x000e
  345.     unit_of_measurement: "Hz"
  346.     state_class: "measurement"
  347.     #device_class: "frequency"
  348.     icon: "mdi:current-ac"
  349.     value_type: U_WORD
  350.     accuracy_decimals: 2
  351.     filters:
  352.       - multiply: 0.01
  353.  
  354.   - platform: modbus_controller
  355.     modbus_controller_id: sofarsolar
  356.     name: ${friendly_name} L1 Voltage
  357.     id: inverter_ac_v1
  358.     register_type: holding
  359.     address: 0x000f
  360.     unit_of_measurement: "V"
  361.     state_class: "measurement"
  362.     device_class: "voltage"
  363.     icon: "mdi:alpha-v-circle"
  364.     value_type: U_WORD
  365.     accuracy_decimals: 1
  366.     filters:
  367.       - multiply: 0.1
  368.  
  369.   - platform: modbus_controller
  370.     modbus_controller_id: sofarsolar
  371.     name: ${friendly_name} L1 Current
  372.     id: inverter_ac_c1
  373.     register_type: holding
  374.     address: 0x0010
  375.     unit_of_measurement: "A"
  376.     state_class: "measurement"
  377.     device_class: "current"
  378.     icon: "mdi:alpha-a-circle"
  379.     value_type: U_WORD
  380.     accuracy_decimals: 2
  381.     filters:
  382.       - multiply: 0.01
  383.  
  384.   - platform: modbus_controller
  385.     modbus_controller_id: sofarsolar
  386.     name: ${friendly_name} L2 Voltage
  387.     id: inverter_ac_v2
  388.     register_type: holding
  389.     address: 0x0011
  390.     unit_of_measurement: "V"
  391.     state_class: "measurement"
  392.     device_class: "voltage"
  393.     icon: "mdi:alpha-v-circle"
  394.     value_type: U_WORD
  395.     accuracy_decimals: 1
  396.     filters:
  397.       - multiply: 0.1
  398.  
  399.   - platform: modbus_controller
  400.     modbus_controller_id: sofarsolar
  401.     name: ${friendly_name} L2 Current
  402.     id: inverter_ac_c2
  403.     register_type: holding
  404.     address: 0x0012
  405.     unit_of_measurement: "A"
  406.     state_class: "measurement"
  407.     device_class: "current"
  408.     icon: "mdi:alpha-a-circle"
  409.     value_type: U_WORD
  410.     accuracy_decimals: 2
  411.     filters:
  412.       - multiply: 0.01
  413.  
  414.   - platform: modbus_controller
  415.     modbus_controller_id: sofarsolar
  416.     name: ${friendly_name} L3 Voltage
  417.     id: inverter_ac_v3
  418.     register_type: holding
  419.     address: 0x0013
  420.     unit_of_measurement: "V"
  421.     state_class: "measurement"
  422.     device_class: "voltage"
  423.     icon: "mdi:alpha-v-circle"
  424.     value_type: U_WORD
  425.     accuracy_decimals: 1
  426.     filters:
  427.       - multiply: 0.1
  428.  
  429.   - platform: modbus_controller
  430.     modbus_controller_id: sofarsolar
  431.     name: ${friendly_name} L3 Current
  432.     id: inverter_ac_c3
  433.     register_type: holding
  434.     address: 0x0014
  435.     unit_of_measurement: "A"
  436.     state_class: "measurement"
  437.     device_class: "current"
  438.     icon: "mdi:alpha-a-circle"
  439.     value_type: U_WORD
  440.     accuracy_decimals: 2
  441.     filters:
  442.       - multiply: 0.01
  443.  
  444.   - platform: modbus_controller
  445.     modbus_controller_id: sofarsolar
  446.     name: ${friendly_name} Energy total
  447.     id: inverter_energy_total
  448.     register_type: holding
  449.     address: 0x0015
  450.     unit_of_measurement: "kWh"
  451.     accuracy_decimals: 2
  452.     device_class: "energy"
  453.     state_class: "total_increasing"
  454.     icon: "mdi:solar-power-variant-outline"
  455.     value_type: U_DWORD
  456.  
  457.   - platform: modbus_controller
  458.     modbus_controller_id: sofarsolar
  459.     name: ${friendly_name} Energy generation time total
  460.     id: inverter_energy_generation_time_total
  461.     register_type: holding
  462.     address: 0x0017
  463.     unit_of_measurement: "h"
  464.     icon: "mdi:timeline-clock"
  465.     value_type: U_DWORD
  466.  
  467.  
  468.   - platform: modbus_controller
  469.     modbus_controller_id: sofarsolar
  470.     name: ${friendly_name} Energy today
  471.     id: inverter_energy_today
  472.     register_type: holding
  473.     address: 0x0019
  474.     unit_of_measurement: "kWh"
  475.     state_class: "measurement"
  476.     device_class: "energy"
  477.     icon: "mdi:solar-power-variant-outline"
  478.     value_type: U_WORD
  479.     accuracy_decimals: 2
  480.     filters:
  481.       - multiply: 0.01
  482.  
  483.   - platform: modbus_controller
  484.     modbus_controller_id: sofarsolar
  485.     name: ${friendly_name} Energy generation time today
  486.     id: inverter_energy_generation_time_today
  487.     register_type: holding
  488.     address: 0x001A
  489.     unit_of_measurement: "min"
  490.     icon: "mdi:timeline-clock"
  491.     value_type: U_WORD
  492.  
  493.   - platform: modbus_controller
  494.     modbus_controller_id: sofarsolar
  495.     name: ${friendly_name} Temprature module
  496.     id: inverter_temp_module
  497.     register_type: holding
  498.     address: 0x001B
  499.     unit_of_measurement: "°C"
  500.     state_class: "measurement"
  501.     device_class: "temperature"
  502.     icon: "mdi:temperature-celsius"
  503.     value_type: U_WORD
  504.  
  505.   - platform: modbus_controller
  506.     modbus_controller_id: sofarsolar
  507.     name: ${friendly_name} Temprature inverter
  508.     id: inverter_temp_inverter
  509.     register_type: holding
  510.     address: 0x001C
  511.     unit_of_measurement: "°C"
  512.     state_class: "measurement"
  513.     device_class: "temperature"
  514.     icon: "mdi:temperature-celsius"
  515.     value_type: U_WORD
  516.  
  517.   - platform: modbus_controller
  518.     modbus_controller_id: sofarsolar
  519.     name: ${friendly_name} Bus voltage
  520.     id: inverter_bus_voltage
  521.     register_type: holding
  522.     address: 0x001D
  523.     unit_of_measurement: "V"
  524.     state_class: "measurement"
  525.     device_class: "voltage"
  526.     icon: "mdi:alpha-v-circle-outline"
  527.     value_type: U_WORD
  528.     accuracy_decimals: 1
  529.     filters:
  530.       - multiply: 0.1
  531.  
  532.   - platform: modbus_controller
  533.     modbus_controller_id: sofarsolar
  534.     name: ${friendly_name} PV1+ isolation resistance
  535.     id: inverter_dc_isolation_resistance1
  536.     register_type: holding
  537.     address: 0x0024
  538.     unit_of_measurement: "Ohm"
  539.     state_class: "measurement"
  540.     icon: "mdi:omega"
  541.     value_type: U_WORD
  542.  
  543.   - platform: modbus_controller
  544.     modbus_controller_id: sofarsolar
  545.     name: ${friendly_name} PV2+ isolation resistance
  546.     id: inverter_dc_isolation_resistance2
  547.     register_type: holding
  548.     address: 0x0025
  549.     unit_of_measurement: "Ohm"
  550.     state_class: "measurement"
  551.     icon: "mdi:omega"
  552.     value_type: U_WORD
  553.  
  554.   - platform: modbus_controller
  555.     modbus_controller_id: sofarsolar
  556.     name: ${friendly_name} PV- isolation resistance
  557.     id: inverter_cathode_to_ground_impedance
  558.     register_type: holding
  559.     address: 0x0026
  560.     unit_of_measurement: "Ohm"
  561.     state_class: "measurement"
  562.     icon: "mdi:omega"
  563.     value_type: U_WORD
  564.  
  565.   - platform: template
  566.     name: ${friendly_name} AC Current (total)    
  567.     lambda: |-
  568.       return (id(inverter_ac_c1).state + id(inverter_ac_c2).state + id(inverter_ac_c3).state);
  569.     unit_of_measurement: A
  570.     accuracy_decimals: 2
  571.     icon: "mdi:alpha-a-circle"
  572.     device_class: "current"
  573.     state_class: "measurement"
  574.     update_interval: 5s
  575.  
  576.   - platform: template
  577.     name: ${friendly_name} DC Current (total)  
  578.     lambda: |-
  579.       return (id(inverter_dc_c1).state + id(inverter_dc_c2).state);
  580.     unit_of_measurement: A
  581.     accuracy_decimals: 1
  582.     state_class: "measurement"
  583.     device_class: "current"
  584.     icon: "mdi:alpha-a-circle-outline"
  585.     update_interval: 5s
  586.  
  587.   - platform: template
  588.     name: ${friendly_name} DC Power (total)  
  589.     lambda: |-
  590.       return (id(inverter_dc_power2).state + id(inverter_dc_power1).state);
  591.     unit_of_measurement: W
  592.     state_class: "measurement"
  593.     device_class: "power"
  594.     accuracy_decimals: 0
  595.     icon: "mdi:alpha-a-circle-outline"
  596.     update_interval: 5s
  597.  
  598.   - platform: uptime
  599.     name: ${friendly_name} Uptime
  600.     id: uptime_sensor
  601.     update_interval: 5s
  602.     icon: "mdi:clock-start"
  603.     internal: true
  604.     on_raw_value:
  605.       then:
  606.         - text_sensor.template.publish:
  607.             id: uptime_human
  608.             state: !lambda |-
  609.               int seconds = round(id(uptime_sensor).raw_state);
  610.               seconds = seconds % (24 * 3600);
  611.               int hours = seconds / 3600;
  612.               seconds = seconds % 3600;
  613.               int minutes = seconds /  60;
  614.               seconds = seconds % 60;
  615.               return (
  616.                 (hours ? to_string(hours) + "h " : "") +
  617.                 (minutes ? to_string(minutes) + "m " : "") +
  618.                 (to_string(seconds) + "s")
  619.               ).c_str();
  620.  
  621.   - platform: template
  622.     unit_of_measurement: "%"
  623.     name: "ESP-Sofar WiFi Signal (human readable)"
  624.     accuracy_decimals: 0
  625.     update_interval: 30s
  626.     device_class: "signal_strength"
  627.     icon: "mdi:wifi"
  628.     lambda: return (-0.0134 * (id(inverter_wifi_signal).state * id(inverter_wifi_signal).state ) ) + (-0.2228 * id(inverter_wifi_signal).state) + 100.2;
  629.  
  630. switch:
  631.   - platform: restart
  632.     name: "ESP-Sofar Restart"
  633.  
  634. binary_sensor:
  635.   - platform: status
  636.     name: "ESP-Sofar Status"