Untitled

From michal, 5 Months ago, written in Plain Text, viewed 1 times.
URL https://paste.linuxiarz.pl/view/f5052273 Embed
Download Paste or View Raw
  1. modbus:
  2.   - name: modbus_hub
  3.     type: rtuovertcp
  4.     host: 192.168.1.245
  5.     port: 4196
  6.     delay: 0
  7.     message_wait_milliseconds: 30
  8.     timeout: 5
  9.     id: mod_bus_sofar
  10.  
  11. modbus_controller:
  12.   - id: sofarsolar
  13.     address: 0x01
  14.     modbus_id: mod_bus_sofar
  15.     update_interval: 1s
  16.  
  17. text_sensor:
  18.   - platform: template
  19.     name: "ESP-Sofar Uptime (human readable)"
  20.     id: uptime_human
  21.     icon: "mdi:clock-start"
  22.     update_interval: 5s
  23.  
  24.   - platform: modbus_controller
  25.     modbus_controller_id: sofarsolar
  26.     name: ${friendly_name} Status
  27.     id: inverter_status
  28.     register_type: holding
  29.     icon: "mdi:information-outline"
  30.     address: 0x0000
  31.     response_size: 2
  32.     lambda: |-
  33.       auto z = "Unknown";
  34.       char d = data[item->offset+1];
  35.       if (d == 0) z = "Wait";
  36.       else if (d == 1) z = "Check";
  37.       else if (d == 2) z = "Normal";
  38.       else if (d == 3) z = "Fault";
  39.       else if (d == 4) z = "Permanent";
  40.       return {z};
  41.  
  42.   - platform: modbus_controller
  43.     modbus_controller_id: sofarsolar
  44.     name: ${friendly_name} Fault Message
  45.     id: inverter_fault_message
  46.     register_type: holding
  47.     icon: "mdi:alert-outline"
  48.     address: 0x0001
  49.     response_size: 10
  50.     lambda: |-
  51.       std::string z = "";
  52.       int idx = item->offset;
  53.       //byte[0]
  54.       if ((data[idx] & 0x1) != 0) z += "GridOVP,";
  55.       if ((data[idx] & 0x2) != 0) z += "GridUVP,";
  56.       if ((data[idx] & 0x4) != 0) z += "GridOFP,";
  57.       if ((data[idx] & 0x8) != 0) z += "GridUFP,";
  58.       if ((data[idx] & 0x10) != 0) z += "PVUVP,";
  59.       if ((data[idx] & 0x20) != 0) z += "GridLVRT,";
  60.       if ((data[idx] & 0x40) != 0) z += "reserve-ID7,";
  61.       if ((data[idx] & 0x80) != 0) z += "reserve-ID8,";
  62.       //byte[1]
  63.       idx++;
  64.       if ((data[idx] & 0x1) != 0) z += "PVOVP,";
  65.       if ((data[idx] & 0x2) != 0) z += "IpvUnbalance,";
  66.       if ((data[idx] & 0x4) != 0) z += "PvConfigSetWrong,";
  67.       if ((data[idx] & 0x8) != 0) z += "GFCIFault,";
  68.       if ((data[idx] & 0x10) != 0) z += "PhaseSequenceFault,";
  69.       if ((data[idx] & 0x20) != 0) z += "HwBoostOCP,";
  70.       if ((data[idx] & 0x40) != 0) z += "HwAcOCP,";
  71.       if ((data[idx] & 0x80) != 0) z += "AcRmsOCP,";
  72.       //byte[2]
  73.       idx++;
  74.       if ((data[idx] & 0x1) != 0) z += "HwADFaultIGrid,";
  75.       if ((data[idx] & 0x2) != 0) z += "HwADFaultDCI,";
  76.       if ((data[idx] & 0x4) != 0) z += "HwADFaultVGrid,";
  77.       if ((data[idx] & 0x8) != 0) z += "GFCIDeviceFault,";
  78.       if ((data[idx] & 0x10) != 0) z += "MChip_Fault,";
  79.       if ((data[idx] & 0x20) != 0) z += "HwAuxPowerFault,";
  80.       if ((data[idx] & 0x40) != 0) z += "BusVoltZeroFault,";
  81.       if ((data[idx] & 0x80) != 0) z += "IacRmsUnbalance,";
  82.       //byte[3]
  83.       idx++;
  84.       if ((data[idx] & 0x1) != 0) z += "BusUVP,";
  85.       if ((data[idx] & 0x2) != 0) z += "BusOVP,";
  86.       if ((data[idx] & 0x4) != 0) z += "VbusUnbalance,";
  87.       if ((data[idx] & 0x8) != 0) z += "DciOCP,";
  88.       if ((data[idx] & 0x10) != 0) z += "SwOCPInstant,";
  89.       if ((data[idx] & 0x20) != 0) z += "SwBOCPInstant,";
  90.       if ((data[idx] & 0x40) != 0) z += "reserved-ID31,";
  91.       if ((data[idx] & 0x80) != 0) z += "reserved-ID32,";
  92.       //byte[4]
  93.       idx++;
  94.       if (data[idx] != 0) z += "reserved-ID33~40,";
  95.       //byte[5]
  96.       idx++;
  97.       if (data[idx] != 0) z += "reserved-ID41~48,";
  98.       //byte[6]
  99.       idx++;
  100.       if ((data[idx] & 0x1) != 0) z += "ConsistentFault_VGrid,";
  101.       if ((data[idx] & 0x2) != 0) z += "ConsistentFault_FGrid,";
  102.       if ((data[idx] & 0x4) != 0) z += "ConsistentFault_DCI,";
  103.       if ((data[idx] & 0x8) != 0) z += "ConsistentFault_GFCI,";
  104.       if ((data[idx] & 0x10) != 0) z += "SpiCommLose,";
  105.       if ((data[idx] & 0x20) != 0) z += "SciCommLose,";
  106.       if ((data[idx] & 0x40) != 0) z += "RelayTestFail,";
  107.       if ((data[idx] & 0x80) != 0) z += "PvIsoFault,";
  108.       //byte[7]
  109.       idx++;
  110.       if ((data[idx] & 0x1) != 0) z += "OverTempFault_Inv,";
  111.       if ((data[idx] & 0x2) != 0) z += "OverTempFault_Boost,";
  112.       if ((data[idx] & 0x4) != 0) z += "OverTempFault_Env,";
  113.       if ((data[idx] & 0x8) != 0) z += "PEConnectFault,";
  114.       if ((data[idx] & 0x10) != 0) z += "reserved-ID61,";
  115.       if ((data[idx] & 0x20) != 0) z += "reserved-ID62,";
  116.       if ((data[idx] & 0x40) != 0) z += "reserved-ID63,";
  117.       if ((data[idx] & 0x80) != 0) z += "reserved-ID64,";
  118.       //byte[8]
  119.       idx++;
  120.       if ((data[idx] & 0x1) != 0) z += "unrecoverHwAcOCP,";
  121.       if ((data[idx] & 0x2) != 0) z += "unrecoverBusOVP,";
  122.       if ((data[idx] & 0x4) != 0) z += "unrecoverIacRmsUnbalance,";
  123.       if ((data[idx] & 0x8) != 0) z += "unrecoverIpvUnbalance,";
  124.       if ((data[idx] & 0x10) != 0) z += "unrecoverVbusUnbalance,";
  125.       if ((data[idx] & 0x20) != 0) z += "unrecoverOCPInstant,";
  126.       if ((data[idx] & 0x40) != 0) z += "unrecoverPvConfigSetWrong,";
  127.       if ((data[idx] & 0x80) != 0) z += "reserved-ID72,";
  128.       //byte[9]
  129.       idx++;
  130.       if ((data[idx] & 0x1) != 0) z += "reserved-ID73,";
  131.       if ((data[idx] & 0x2) != 0) z += "unrecoverIPVInstant,";
  132.       if ((data[idx] & 0x4) != 0) z += "unrecoverWRITEEEPROM,";
  133.       if ((data[idx] & 0x8) != 0) z += "unrecoverREADEEPROM,";
  134.       if ((data[idx] & 0x10) != 0) z += "unrecoverRelayFail,";
  135.       if ((data[idx] & 0x20) != 0) z += "reserved-ID78,";
  136.       if ((data[idx] & 0x40) != 0) z += "reserved-ID79,";
  137.       if ((data[idx] & 0x80) != 0) z += "reserved-ID80,";
  138.       if(z.length() > 0){
  139.         z.pop_back();
  140.       }
  141.       return {z};
  142.  
  143.   - platform: modbus_controller
  144.     modbus_controller_id: sofarsolar
  145.     name: ${friendly_name} DC1 Voltage
  146.     id: inverter_dc_v1
  147.     register_type: holding
  148.     address: 0x0006
  149.     unit_of_measurement: "V"
  150.     state_class: "measurement"
  151.     device_class: "voltage"
  152.     icon: "mdi:alpha-v-circle-outline"
  153.     value_type: U_WORD
  154.     accuracy_decimals: 1
  155.     filters:
  156.       - multiply: 0.1
  157.  
  158.   - platform: modbus_controller
  159.     modbus_controller_id: sofarsolar
  160.     name: ${friendly_name} DC1 Current
  161.     id: inverter_dc_c1
  162.     register_type: holding
  163.     address: 0x0007
  164.     unit_of_measurement: "A"
  165.     state_class: "measurement"
  166.     device_class: "current"
  167.     icon: "mdi:alpha-a-circle-outline"
  168.     value_type: U_WORD
  169.     accuracy_decimals: 2
  170.     filters:
  171.       - multiply: 0.01
  172.  
  173.   - platform: modbus_controller
  174.     modbus_controller_id: sofarsolar
  175.     name: ${friendly_name} DC2 Voltage
  176.     id: inverter_dc_v2
  177.     register_type: holding
  178.     address: 0x0008
  179.     unit_of_measurement: "V"
  180.     state_class: "measurement"
  181.     device_class: "voltage"
  182.     icon: "mdi:alpha-v-circle-outline"
  183.     value_type: U_WORD
  184.     accuracy_decimals: 1
  185.     filters:
  186.       - multiply: 0.1
  187.  
  188.   - platform: modbus_controller
  189.     modbus_controller_id: sofarsolar
  190.     name: ${friendly_name} DC2 Current
  191.     id: inverter_dc_c2
  192.     register_type: holding
  193.     address: 0x0009
  194.     unit_of_measurement: "A"
  195.     state_class: "measurement"
  196.     device_class: "current"
  197.     icon: "mdi:alpha-a-circle-outline"
  198.     value_type: U_WORD
  199.     accuracy_decimals: 2
  200.     filters:
  201.       - multiply: 0.01
  202.  
  203.   - platform: modbus_controller
  204.     modbus_controller_id: sofarsolar
  205.     name: ${friendly_name} DC1 Power
  206.     id: inverter_dc_power1
  207.     register_type: holding
  208.     address: 0x000a
  209.     unit_of_measurement: "W"
  210.     state_class: "measurement"
  211.     device_class: "power"
  212.     icon: "mdi:solar-power"
  213.     value_type: U_WORD
  214.     filters:
  215.       - multiply: 10
  216.  
  217.   - platform: modbus_controller
  218.     modbus_controller_id: sofarsolar
  219.     name: ${friendly_name} DC2 Power
  220.     id: inverter_dc_power2
  221.     register_type: holding
  222.     address: 0x000b
  223.     unit_of_measurement: "W"
  224.     state_class: "measurement"
  225.     device_class: "power"
  226.     icon: "mdi:solar-power"
  227.     value_type: U_WORD
  228.     filters:
  229.       - multiply: 10
  230.  
  231.   - platform: modbus_controller
  232.     modbus_controller_id: sofarsolar
  233.     name: ${friendly_name} AC Power
  234.     id: inverter_ac_power
  235.     register_type: holding
  236.     address: 0x000c
  237.     unit_of_measurement: "W"
  238.     state_class: "measurement"
  239.     device_class: "power"
  240.     icon: "mdi:solar-power-variant-outline"
  241.     value_type: U_WORD
  242.     filters:
  243.       - multiply: 10
  244.  
  245.   - platform: modbus_controller
  246.     modbus_controller_id: sofarsolar
  247.     name: ${friendly_name} AC Reactive Power
  248.     id: inverter_ac_reactive_power
  249.     register_type: holding
  250.     address: 0x000d
  251.     unit_of_measurement: "kVar"
  252.     state_class: "measurement"
  253.     #device_class: "reactive_power"
  254.     icon: "mdi:math-cos"
  255.     value_type: S_WORD
  256.     filters:
  257.       - multiply: 10
  258.  
  259.   - platform: modbus_controller
  260.     modbus_controller_id: sofarsolar
  261.     name: ${friendly_name} AC Freq
  262.     id: inverter_ac_freq
  263.     register_type: holding
  264.     address: 0x000e
  265.     unit_of_measurement: "Hz"
  266.     state_class: "measurement"
  267.     #device_class: "frequency"
  268.     icon: "mdi:current-ac"
  269.     value_type: U_WORD
  270.     accuracy_decimals: 2
  271.     filters:
  272.       - multiply: 0.01
  273.  
  274.   - platform: modbus_controller
  275.     modbus_controller_id: sofarsolar
  276.     name: ${friendly_name} L1 Voltage
  277.     id: inverter_ac_v1
  278.     register_type: holding
  279.     address: 0x000f
  280.     unit_of_measurement: "V"
  281.     state_class: "measurement"
  282.     device_class: "voltage"
  283.     icon: "mdi:alpha-v-circle"
  284.     value_type: U_WORD
  285.     accuracy_decimals: 1
  286.     filters:
  287.       - multiply: 0.1
  288.  
  289.   - platform: modbus_controller
  290.     modbus_controller_id: sofarsolar
  291.     name: ${friendly_name} L1 Current
  292.     id: inverter_ac_c1
  293.     register_type: holding
  294.     address: 0x0010
  295.     unit_of_measurement: "A"
  296.     state_class: "measurement"
  297.     device_class: "current"
  298.     icon: "mdi:alpha-a-circle"
  299.     value_type: U_WORD
  300.     accuracy_decimals: 2
  301.     filters:
  302.       - multiply: 0.01
  303.  
  304.   - platform: modbus_controller
  305.     modbus_controller_id: sofarsolar
  306.     name: ${friendly_name} L2 Voltage
  307.     id: inverter_ac_v2
  308.     register_type: holding
  309.     address: 0x0011
  310.     unit_of_measurement: "V"
  311.     state_class: "measurement"
  312.     device_class: "voltage"
  313.     icon: "mdi:alpha-v-circle"
  314.     value_type: U_WORD
  315.     accuracy_decimals: 1
  316.     filters:
  317.       - multiply: 0.1
  318.  
  319.   - platform: modbus_controller
  320.     modbus_controller_id: sofarsolar
  321.     name: ${friendly_name} L2 Current
  322.     id: inverter_ac_c2
  323.     register_type: holding
  324.     address: 0x0012
  325.     unit_of_measurement: "A"
  326.     state_class: "measurement"
  327.     device_class: "current"
  328.     icon: "mdi:alpha-a-circle"
  329.     value_type: U_WORD
  330.     accuracy_decimals: 2
  331.     filters:
  332.       - multiply: 0.01
  333.  
  334.   - platform: modbus_controller
  335.     modbus_controller_id: sofarsolar
  336.     name: ${friendly_name} L3 Voltage
  337.     id: inverter_ac_v3
  338.     register_type: holding
  339.     address: 0x0013
  340.     unit_of_measurement: "V"
  341.     state_class: "measurement"
  342.     device_class: "voltage"
  343.     icon: "mdi:alpha-v-circle"
  344.     value_type: U_WORD
  345.     accuracy_decimals: 1
  346.     filters:
  347.       - multiply: 0.1
  348.  
  349.   - platform: modbus_controller
  350.     modbus_controller_id: sofarsolar
  351.     name: ${friendly_name} L3 Current
  352.     id: inverter_ac_c3
  353.     register_type: holding
  354.     address: 0x0014
  355.     unit_of_measurement: "A"
  356.     state_class: "measurement"
  357.     device_class: "current"
  358.     icon: "mdi:alpha-a-circle"
  359.     value_type: U_WORD
  360.     accuracy_decimals: 2
  361.     filters:
  362.       - multiply: 0.01
  363.  
  364.   - platform: modbus_controller
  365.     modbus_controller_id: sofarsolar
  366.     name: ${friendly_name} Energy total
  367.     id: inverter_energy_total
  368.     register_type: holding
  369.     address: 0x0015
  370.     unit_of_measurement: "kWh"
  371.     accuracy_decimals: 2
  372.     device_class: "energy"
  373.     state_class: "total_increasing"
  374.     icon: "mdi:solar-power-variant-outline"
  375.     value_type: U_DWORD
  376.  
  377.   - platform: modbus_controller
  378.     modbus_controller_id: sofarsolar
  379.     name: ${friendly_name} Energy generation time total
  380.     id: inverter_energy_generation_time_total
  381.     register_type: holding
  382.     address: 0x0017
  383.     unit_of_measurement: "h"
  384.     icon: "mdi:timeline-clock"
  385.     value_type: U_DWORD
  386.  
  387.   - platform: modbus_controller
  388.     modbus_controller_id: sofarsolar
  389.     name: ${friendly_name} Energy today
  390.     id: inverter_energy_today
  391.     register_type: holding
  392.     address: 0x0019
  393.     unit_of_measurement: "kWh"
  394.     state_class: "measurement"
  395.     device_class: "energy"
  396.     icon: "mdi:solar-power-variant-outline"
  397.     value_type: U_WORD
  398.     accuracy_decimals: 2
  399.     filters:
  400.       - multiply: 0.01
  401.  
  402.   - platform: modbus_controller
  403.     modbus_controller_id: sofarsolar
  404.     name: ${friendly_name} Energy generation time today
  405.     id: inverter_energy_generation_time_today
  406.     register_type: holding
  407.     address: 0x001A
  408.     unit_of_measurement: "min"
  409.     icon: "mdi:timeline-clock"
  410.     value_type: U_WORD
  411.  
  412.   - platform: modbus_controller
  413.     modbus_controller_id: sofarsolar
  414.     name: ${friendly_name} Temprature module
  415.     id: inverter_temp_module
  416.     register_type: holding
  417.     address: 0x001B
  418.     unit_of_measurement: "°C"
  419.     state_class: "measurement"
  420.     device_class: "temperature"
  421.     icon: "mdi:temperature-celsius"
  422.     value_type: U_WORD
  423.  
  424.   - platform: modbus_controller
  425.     modbus_controller_id: sofarsolar
  426.     name: ${friendly_name} Temprature inverter
  427.     id: inverter_temp_inverter
  428.     register_type: holding
  429.     address: 0x001C
  430.     unit_of_measurement: "°C"
  431.     state_class: "measurement"
  432.     device_class: "temperature"
  433.     icon: "mdi:temperature-celsius"
  434.     value_type: U_WORD
  435.  
  436.   - platform: modbus_controller
  437.     modbus_controller_id: sofarsolar
  438.     name: ${friendly_name} Bus voltage
  439.     id: inverter_bus_voltage
  440.     register_type: holding
  441.     address: 0x001D
  442.     unit_of_measurement: "V"
  443.     state_class: "measurement"
  444.     device_class: "voltage"
  445.     icon: "mdi:alpha-v-circle-outline"
  446.     value_type: U_WORD
  447.     accuracy_decimals: 1
  448.     filters:
  449.       - multiply: 0.1
  450.  
  451.   - platform: modbus_controller
  452.     modbus_controller_id: sofarsolar
  453.     name: ${friendly_name} PV1+ isolation resistance
  454.     id: inverter_dc_isolation_resistance1
  455.     register_type: holding
  456.     address: 0x0024
  457.     unit_of_measurement: "Ohm"
  458.     state_class: "measurement"
  459.     icon: "mdi:omega"
  460.     value_type: U_WORD
  461.  
  462.   - platform: modbus_controller
  463.     modbus_controller_id: sofarsolar
  464.     name: ${friendly_name} PV2+ isolation resistance
  465.     id: inverter_dc_isolation_resistance2
  466.     register_type: holding
  467.     address: 0x0025
  468.     unit_of_measurement: "Ohm"
  469.     state_class: "measurement"
  470.     icon: "mdi:omega"
  471.     value_type: U_WORD
  472.  
  473.   - platform: modbus_controller
  474.     modbus_controller_id: sofarsolar
  475.     name: ${friendly_name} PV- isolation resistance
  476.     id: inverter_cathode_to_ground_impedance
  477.     register_type: holding
  478.     address: 0x0026
  479.     unit_of_measurement: "Ohm"
  480.     state_class: "measurement"
  481.     icon: "mdi:omega"
  482.     value_type: U_WORD
  483.  
  484.   - platform: template
  485.     name: ${friendly_name} AC Current (total)
  486.     lambda: |-
  487.       return (id(inverter_ac_c1).state + id(inverter_ac_c2).state + id(inverter_ac_c3).state);
  488.     unit_of_measurement: A
  489.     accuracy_decimals: 2
  490.     icon: "mdi:alpha-a-circle"
  491.     device_class: "current"
  492.     state_class: "measurement"
  493.     update_interval: 5s
  494.  
  495.   - platform: template
  496.     name: ${friendly_name} DC Current (total)
  497.     lambda: |-
  498.       return (id(inverter_dc_c1).state + id(inverter_dc_c2).state);
  499.     unit_of_measurement: A
  500.     accuracy_decimals: 1
  501.     state_class: "measurement"
  502.     device_class: "current"
  503.     icon: "mdi:alpha-a-circle-outline"
  504.     update_interval: 5s
  505.  
  506.   - platform: template
  507.     name: ${friendly_name} DC Power (total)
  508.     lambda: |-
  509.       return (id(inverter_dc_power2).state + id(inverter_dc_power1).state);
  510.     unit_of_measurement: W
  511.     state_class: "measurement"
  512.     device_class: "power"
  513.     accuracy_decimals: 0
  514.     icon: "mdi:alpha-a-circle-outline"
  515.     update_interval: 5s
  516.  

Reply to "Untitled"

Here you can reply to the paste above

captcha