<?xml version="1.0" encoding="utf-8"?>
<Templates format="2" protocolVersion="83">
  <Template id="2774aa28-5301-4e0c-8514-b8c6fe7dd0b1" revision="1.0">
    <SuggestedCCUParameters>
      <Baudrate>9600</Baudrate>
      <Parity>None</Parity>
      <StopBits>One</StopBits>
      <DataBits>8</DataBits>
      <UseAsciiCommunication>False</UseAsciiCommunication>
      <DelayBetweenRequests>250</DelayBetweenRequests>
      <ReadWriteTimeout>2000</ReadWriteTimeout>
    </SuggestedCCUParameters>
    <Name>Deye SUN-xK-SG04LP3-EU / SG05LP3-EU</Name>
    <CcuModel>ModbusRtuCCU</CcuModel>
    <Producer>Deye</Producer>
    <Model>SUN-xK-SG04LP3-EU / SG05LP3-EU</Model>
    <Description>Three-phase low-voltage hybrid inverter with battery storage, grid monitoring and PV input.</Description>
    <Category>2</Category>
    <ImportParameters>
      <Parameter>
        <Id>SlaveId</Id>
        <Name>Modbus Slave ID</Name>
        <Value>1</Value>
      </Parameter>
    </ImportParameters>
    <Module>
      <Name>Deye SUN-xK-SG04LP3-EU</Name>
      <Id>-1</Id>
      <Model>ModbusModule</Model>
      <DeviceProperties>
        <SlaveId>$[SlaveId]</SlaveId>
        <MaxPrefetchGroupSize>32</MaxPrefetchGroupSize>
        <PrefetchModeId>0</PrefetchModeId>
        <ReadScript>VAR state := MODBUSR(H, 500, UInt16);
IF(state = 3, ADDWARNING(64, &quot;Inverter alarm (running state 3)&quot;));
IF(state = 4, ADDERROR(65, &quot;Inverter fault (running state 4)&quot;));

VAR w1 := MODBUSR(H, 553, UInt16);
IF(GETBIT(w1, 1), ADDWARNING(1, &quot;Fan warning&quot;));
IF(GETBIT(w1, 2), ADDWARNING(2, &quot;Grid phase sequence wrong&quot;));
IF(GETBIT(w1, 3), ADDWARNING(3, &quot;Meter communication failure&quot;));

VAR w2 := MODBUSR(H, 554, UInt16);
IF(GETBIT(w2, 14), ADDWARNING(14, &quot;Lithium battery lost&quot;));
IF(GETBIT(w2, 15), ADDWARNING(15, &quot;Parallel communication quality&quot;));

VAR f1 := MODBUSR(H, 555, UInt16);
IF(GETBIT(f1, 6), ADDERROR(6, &quot;F07 DC/DC soft-start fault&quot;));
IF(GETBIT(f1, 9), ADDERROR(9, &quot;F10 Auxiliary power supply fault&quot;));
IF(GETBIT(f1, 12), ADDERROR(12, &quot;F13 Working mode changed&quot;));

VAR f2 := MODBUSR(H, 556, UInt16);
IF(GETBIT(f2, 1), ADDERROR(17, &quot;F18 AC over-current&quot;));
IF(GETBIT(f2, 3), ADDERROR(19, &quot;F20 DC over-current&quot;));
IF(GETBIT(f2, 5), ADDERROR(21, &quot;F22 Emergency stop - inverter locked&quot;));
IF(GETBIT(f2, 6), ADDERROR(22, &quot;F23 Leakage current fault&quot;));
IF(GETBIT(f2, 7), ADDERROR(23, &quot;F24 PV insulation resistance fault&quot;));
IF(GETBIT(f2, 9), ADDERROR(25, &quot;F26 DC bus unbalanced&quot;));
IF(GETBIT(f2, 12), ADDERROR(28, &quot;F29 Parallel CAN bus fault&quot;));

VAR f3 := MODBUSR(H, 557, UInt16);
IF(GETBIT(f3, 2), ADDERROR(34, &quot;F35 No AC grid&quot;));
IF(GETBIT(f3, 8), ADDERROR(40, &quot;F41 Parallel system stop&quot;));
IF(GETBIT(f3, 9), ADDERROR(41, &quot;F42 AC line low voltage&quot;));
IF(GETBIT(f3, 13), ADDERROR(45, &quot;F46 Backup battery fault&quot;));
IF(GETBIT(f3, 14), ADDERROR(46, &quot;F47 AC over-frequency&quot;));
IF(GETBIT(f3, 15), ADDERROR(47, &quot;F48 AC under-frequency&quot;));

VAR f4 := MODBUSR(H, 558, UInt16);
IF(GETBIT(f4, 0), ADDERROR(48, &quot;F49 Backup battery fault&quot;));
IF(GETBIT(f4, 7), ADDERROR(55, &quot;F56 DC bus voltage too low&quot;));
IF(GETBIT(f4, 9), ADDERROR(57, &quot;F58 BMS communication fault&quot;));
IF(GETBIT(f4, 13), ADDERROR(61, &quot;F62 DRM stop&quot;));
IF(GETBIT(f4, 14), ADDERROR(62, &quot;F63 Arc fault&quot;));
IF(GETBIT(f4, 15), ADDERROR(63, &quot;F64 Heat sink temperature too high&quot;));
</ReadScript>
        <ServiceAttributesFormulas>[{&quot;AttributeDefinition&quot;:{&quot;Name&quot;:&quot;Running state&quot;},&quot;ReadFormula&quot;:&quot;IF(MODBUSR(H, 500, UInt16) = 0, \&quot;Standby\&quot;, IF(MODBUSR(H, 500, UInt16) = 1, \&quot;Self-check\&quot;, IF(MODBUSR(H, 500, UInt16) = 2, \&quot;Normal\&quot;, IF(MODBUSR(H, 500, UInt16) = 3, \&quot;Alarm\&quot;, IF(MODBUSR(H, 500, UInt16) = 4, \&quot;Fault\&quot;, \&quot;Activating\&quot;)))))&quot;},{&quot;AttributeDefinition&quot;:{&quot;Name&quot;:&quot;Device type&quot;},&quot;ReadFormula&quot;:&quot;TOSTRING(MODBUSR(H, 0, UInt16))&quot;},{&quot;AttributeDefinition&quot;:{&quot;Name&quot;:&quot;Rated power&quot;},&quot;ReadFormula&quot;:&quot;TOSTRING(MODBUSR(H, 20, LittleEndianUint32) / 10, \&quot;F1\&quot;) + \&quot; W\&quot;&quot;}]</ServiceAttributesFormulas>
      </DeviceProperties>
      <Devices>
        <Device>
          <Name>${deviceType_PVProduction}</Name>
          <Id>-2</Id>
          <Model>ModbusElectricityMeter</Model>
          <DeviceProperties>
            <DeviceType>9002</DeviceType>
            <InternalPollInterval>10000</InternalPollInterval>
            <ReadDemand>(MODBUSR(H, 672, UInt16) + MODBUSR(H, 673, UInt16) + MODBUSR(H, 674, UInt16) + MODBUSR(H, 675, UInt16)) / 1000</ReadDemand>
            <ReadTotalConsumption>MODBUSR(H, 534, LittleEndianUint32) / 10</ReadTotalConsumption>
          </DeviceProperties>
        </Device>
        <Device>
          <Name>${deviceType_PVLoad}</Name>
          <Id>-3</Id>
          <Model>ModbusElectricityMeter</Model>
          <DeviceProperties>
            <DeviceType>9003</DeviceType>
            <InternalPollInterval>10000</InternalPollInterval>
            <ReadDemand>MODBUSR(H, 653, Int16) / 1000</ReadDemand>
            <ReadTotalConsumption>MODBUSR(H, 527, LittleEndianUint32) / 10</ReadTotalConsumption>
          </DeviceProperties>
        </Device>
        <Device>
          <Name>${deviceType_PVFromGrid}</Name>
          <Id>-4</Id>
          <Model>ModbusElectricityMeter</Model>
          <DeviceProperties>
            <DeviceType>9004</DeviceType>
            <InternalPollInterval>10000</InternalPollInterval>
            <ReadDemand>MAX(MODBUSR(H, 625, Int16), 0) / 1000</ReadDemand>
            <ReadTotalConsumption>MODBUSR(H, 522, LittleEndianUint32) / 10</ReadTotalConsumption>
          </DeviceProperties>
        </Device>
        <Device>
          <Name>${deviceType_PVToGrid}</Name>
          <Id>-5</Id>
          <Model>ModbusElectricityMeter</Model>
          <DeviceProperties>
            <DeviceType>9005</DeviceType>
            <InternalPollInterval>10000</InternalPollInterval>
            <ReadDemand>MAX(-MODBUSR(H, 625, Int16), 0) / 1000</ReadDemand>
            <ReadTotalConsumption>MODBUSR(H, 524, LittleEndianUint32) / 10</ReadTotalConsumption>
          </DeviceProperties>
        </Device>
        <Device>
          <Name>${deviceType_PVFromBattery}</Name>
          <Id>-6</Id>
          <Model>ModbusElectricityMeter</Model>
          <DeviceProperties>
            <DeviceType>9006</DeviceType>
            <InternalPollInterval>10000</InternalPollInterval>
            <ReadDemand>MAX(MODBUSR(H, 590, Int16), 0) / 1000</ReadDemand>
            <ReadTotalConsumption>MODBUSR(H, 518, LittleEndianUint32) / 10</ReadTotalConsumption>
          </DeviceProperties>
        </Device>
        <Device>
          <Name>${deviceType_PVToBattery}</Name>
          <Id>-7</Id>
          <Model>ModbusElectricityMeter</Model>
          <DeviceProperties>
            <DeviceType>9007</DeviceType>
            <InternalPollInterval>10000</InternalPollInterval>
            <ReadDemand>MAX(-MODBUSR(H, 590, Int16), 0) / 1000</ReadDemand>
            <ReadTotalConsumption>MODBUSR(H, 516, LittleEndianUint32) / 10</ReadTotalConsumption>
          </DeviceProperties>
        </Device>
        <Device>
          <Name>${deviceType_BatterySOC}</Name>
          <Id>-8</Id>
          <Model>ModbusAnalogInput</Model>
          <DeviceProperties>
            <DeviceType>11001</DeviceType>
            <InternalPollInterval>15000</InternalPollInterval>
            <ReadInputLevel>MODBUSR(H, 588, UInt16) / 100</ReadInputLevel>
          </DeviceProperties>
        </Device>
        <Device>
          <Name>Battery - temperature</Name>
          <Id>-9</Id>
          <Model>ModbusTemperatureSensor</Model>
          <DeviceProperties>
            <DeviceType>0</DeviceType>
            <InternalPollInterval>30000</InternalPollInterval>
            <ReadTemperature>(MODBUSR(H, 586, UInt16) - 1000) / 10</ReadTemperature>
          </DeviceProperties>
        </Device>
        <Device>
          <Name>Battery - voltage</Name>
          <Id>-10</Id>
          <Model>ModbusVariable</Model>
          <DeviceProperties>
            <DeviceType>0</DeviceType>
            <InternalPollInterval>10000</InternalPollInterval>
            <IsReadOnly>True</IsReadOnly>
            <ReadState>MODBUSR(H, 587, UInt16) / 100</ReadState>
            <ServiceAttributesFormulas>[{&quot;AttributeDefinition&quot;:{&quot;Name&quot;:&quot;Battery current&quot;},&quot;ReadFormula&quot;:&quot;TOSTRING(MODBUSR(H, 591, Int16) / 100, \&quot;F2\&quot;) + \&quot; A\&quot;&quot;},{&quot;AttributeDefinition&quot;:{&quot;Name&quot;:&quot;Battery power&quot;},&quot;ReadFormula&quot;:&quot;TOSTRING(MODBUSR(H, 590, Int16), \&quot;F0\&quot;) + \&quot; W\&quot;&quot;}]</ServiceAttributesFormulas>
          </DeviceProperties>
        </Device>
        <Device>
          <Name>Battery - charge today</Name>
          <Id>-11</Id>
          <Model>ModbusVariable</Model>
          <DeviceProperties>
            <DeviceType>0</DeviceType>
            <InternalPollInterval>60000</InternalPollInterval>
            <IsReadOnly>True</IsReadOnly>
            <ReadState>MODBUSR(H, 514, UInt16) / 10</ReadState>
            <ServiceAttributesFormulas>[{&quot;AttributeDefinition&quot;:{&quot;Name&quot;:&quot;Battery discharge today&quot;},&quot;ReadFormula&quot;:&quot;TOSTRING(MODBUSR(H, 515, UInt16) / 10, \&quot;F1\&quot;) + \&quot; kWh\&quot;&quot;}]</ServiceAttributesFormulas>
          </DeviceProperties>
        </Device>
        <Device>
          <Name>Grid - voltage L1</Name>
          <Id>-12</Id>
          <Model>ModbusVariable</Model>
          <DeviceProperties>
            <DeviceType>0</DeviceType>
            <InternalPollInterval>10000</InternalPollInterval>
            <IsReadOnly>True</IsReadOnly>
            <ReadState>MODBUSR(H, 598, UInt16) / 10</ReadState>
            <ServiceAttributesFormulas>[{&quot;AttributeDefinition&quot;:{&quot;Name&quot;:&quot;Grid voltage L2&quot;},&quot;ReadFormula&quot;:&quot;TOSTRING(MODBUSR(H, 599, UInt16) / 10, \&quot;F1\&quot;) + \&quot; V\&quot;&quot;},{&quot;AttributeDefinition&quot;:{&quot;Name&quot;:&quot;Grid voltage L3&quot;},&quot;ReadFormula&quot;:&quot;TOSTRING(MODBUSR(H, 600, UInt16) / 10, \&quot;F1\&quot;) + \&quot; V\&quot;&quot;},{&quot;AttributeDefinition&quot;:{&quot;Name&quot;:&quot;Grid frequency&quot;},&quot;ReadFormula&quot;:&quot;TOSTRING(MODBUSR(H, 609, UInt16) / 100, \&quot;F2\&quot;) + \&quot; Hz\&quot;&quot;}]</ServiceAttributesFormulas>
          </DeviceProperties>
        </Device>
        <Device>
          <Name>Grid - power balance</Name>
          <Id>-13</Id>
          <Model>ModbusElectricityMeter</Model>
          <DeviceProperties>
            <DeviceType>0</DeviceType>
            <InternalPollInterval>5000</InternalPollInterval>
            <ReadDemand>MODBUSR(H, 625, Int16) / 1000</ReadDemand>
            <ReadTotalConsumption/>
            <ServiceAttributesFormulas>[{&quot;AttributeDefinition&quot;:{&quot;Name&quot;:&quot;Grid power L1&quot;},&quot;ReadFormula&quot;:&quot;TOSTRING(MODBUSR(H, 622, Int16)) + \&quot; W\&quot;&quot;},{&quot;AttributeDefinition&quot;:{&quot;Name&quot;:&quot;Grid power L2&quot;},&quot;ReadFormula&quot;:&quot;TOSTRING(MODBUSR(H, 623, Int16)) + \&quot; W\&quot;&quot;},{&quot;AttributeDefinition&quot;:{&quot;Name&quot;:&quot;Grid power L3&quot;},&quot;ReadFormula&quot;:&quot;TOSTRING(MODBUSR(H, 624, Int16)) + \&quot; W\&quot;&quot;},{&quot;AttributeDefinition&quot;:{&quot;Name&quot;:&quot;Grid energy bought today&quot;},&quot;ReadFormula&quot;:&quot;TOSTRING(MODBUSR(H, 520, UInt16) / 10, \&quot;F1\&quot;) + \&quot; kWh\&quot;&quot;},{&quot;AttributeDefinition&quot;:{&quot;Name&quot;:&quot;Grid energy sold today&quot;},&quot;ReadFormula&quot;:&quot;TOSTRING(MODBUSR(H, 521, UInt16) / 10, \&quot;F1\&quot;) + \&quot; kWh\&quot;&quot;}]</ServiceAttributesFormulas>
          </DeviceProperties>
        </Device>
        <Device>
          <Name>PV1 - voltage</Name>
          <Id>-14</Id>
          <Model>ModbusVariable</Model>
          <DeviceProperties>
            <DeviceType>0</DeviceType>
            <InternalPollInterval>10000</InternalPollInterval>
            <IsReadOnly>True</IsReadOnly>
            <ReadState>MODBUSR(H, 676, UInt16) / 10</ReadState>
            <ServiceAttributesFormulas>[{&quot;AttributeDefinition&quot;:{&quot;Name&quot;:&quot;PV1 current&quot;},&quot;ReadFormula&quot;:&quot;TOSTRING(MODBUSR(H, 677, UInt16) / 10, \&quot;F1\&quot;) + \&quot; A\&quot;&quot;},{&quot;AttributeDefinition&quot;:{&quot;Name&quot;:&quot;PV1 power&quot;},&quot;ReadFormula&quot;:&quot;TOSTRING(MODBUSR(H, 672, UInt16)) + \&quot; W\&quot;&quot;}]</ServiceAttributesFormulas>
          </DeviceProperties>
        </Device>
        <Device>
          <Name>PV2 - voltage</Name>
          <Id>-15</Id>
          <Model>ModbusVariable</Model>
          <DeviceProperties>
            <DeviceType>0</DeviceType>
            <InternalPollInterval>10000</InternalPollInterval>
            <IsReadOnly>True</IsReadOnly>
            <ReadState>MODBUSR(H, 678, UInt16) / 10</ReadState>
            <ServiceAttributesFormulas>[{&quot;AttributeDefinition&quot;:{&quot;Name&quot;:&quot;PV2 current&quot;},&quot;ReadFormula&quot;:&quot;TOSTRING(MODBUSR(H, 679, UInt16) / 10, \&quot;F1\&quot;) + \&quot; A\&quot;&quot;},{&quot;AttributeDefinition&quot;:{&quot;Name&quot;:&quot;PV2 power&quot;},&quot;ReadFormula&quot;:&quot;TOSTRING(MODBUSR(H, 673, UInt16)) + \&quot; W\&quot;&quot;}]</ServiceAttributesFormulas>
          </DeviceProperties>
        </Device>
        <Device>
          <Name>PV - production today</Name>
          <Id>-16</Id>
          <Model>ModbusVariable</Model>
          <DeviceProperties>
            <DeviceType>0</DeviceType>
            <InternalPollInterval>60000</InternalPollInterval>
            <IsReadOnly>True</IsReadOnly>
            <ReadState>MODBUSR(H, 529, UInt16) / 10</ReadState>
          </DeviceProperties>
        </Device>
        <Device>
          <Name>Load - consumption today</Name>
          <Id>-50</Id>
          <Model>ModbusVariable</Model>
          <DeviceProperties>
            <DeviceType>0</DeviceType>
            <InternalPollInterval>60000</InternalPollInterval>
            <IsReadOnly>True</IsReadOnly>
            <ReadState>MODBUSR(H, 526, UInt16) / 10</ReadState>
            <ServiceAttributesFormulas>[{&quot;AttributeDefinition&quot;:{&quot;Name&quot;:&quot;Load power L1&quot;},&quot;ReadFormula&quot;:&quot;TOSTRING(MODBUSR(H, 650, Int16)) + \&quot; W\&quot;&quot;},{&quot;AttributeDefinition&quot;:{&quot;Name&quot;:&quot;Load power L2&quot;},&quot;ReadFormula&quot;:&quot;TOSTRING(MODBUSR(H, 651, Int16)) + \&quot; W\&quot;&quot;},{&quot;AttributeDefinition&quot;:{&quot;Name&quot;:&quot;Load power L3&quot;},&quot;ReadFormula&quot;:&quot;TOSTRING(MODBUSR(H, 652, Int16)) + \&quot; W\&quot;&quot;}]</ServiceAttributesFormulas>
          </DeviceProperties>
        </Device>
        <Device>
          <Name>Inverter - output power total</Name>
          <Id>-17</Id>
          <Model>ModbusVariable</Model>
          <DeviceProperties>
            <DeviceType>0</DeviceType>
            <InternalPollInterval>10000</InternalPollInterval>
            <IsReadOnly>True</IsReadOnly>
            <ReadState>MODBUSR(H, 636, Int16)</ReadState>
            <ServiceAttributesFormulas>[{&quot;AttributeDefinition&quot;:{&quot;Name&quot;:&quot;Inverter output L1&quot;},&quot;ReadFormula&quot;:&quot;TOSTRING(MODBUSR(H, 633, Int16)) + \&quot; W\&quot;&quot;},{&quot;AttributeDefinition&quot;:{&quot;Name&quot;:&quot;Inverter output L2&quot;},&quot;ReadFormula&quot;:&quot;TOSTRING(MODBUSR(H, 634, Int16)) + \&quot; W\&quot;&quot;},{&quot;AttributeDefinition&quot;:{&quot;Name&quot;:&quot;Inverter output L3&quot;},&quot;ReadFormula&quot;:&quot;TOSTRING(MODBUSR(H, 635, Int16)) + \&quot; W\&quot;&quot;},{&quot;AttributeDefinition&quot;:{&quot;Name&quot;:&quot;Inverter voltage L1&quot;},&quot;ReadFormula&quot;:&quot;TOSTRING(MODBUSR(H, 627, UInt16) / 10, \&quot;F1\&quot;) + \&quot; V\&quot;&quot;},{&quot;AttributeDefinition&quot;:{&quot;Name&quot;:&quot;Inverter voltage L2&quot;},&quot;ReadFormula&quot;:&quot;TOSTRING(MODBUSR(H, 628, UInt16) / 10, \&quot;F1\&quot;) + \&quot; V\&quot;&quot;},{&quot;AttributeDefinition&quot;:{&quot;Name&quot;:&quot;Inverter voltage L3&quot;},&quot;ReadFormula&quot;:&quot;TOSTRING(MODBUSR(H, 629, UInt16) / 10, \&quot;F1\&quot;) + \&quot; V\&quot;&quot;},{&quot;AttributeDefinition&quot;:{&quot;Name&quot;:&quot;Inverter frequency&quot;},&quot;ReadFormula&quot;:&quot;TOSTRING(MODBUSR(H, 638, UInt16) / 100, \&quot;F2\&quot;) + \&quot; Hz\&quot;&quot;}]</ServiceAttributesFormulas>
          </DeviceProperties>
        </Device>
        <Device>
          <Name>Backup - output power</Name>
          <Id>-18</Id>
          <Model>ModbusVariable</Model>
          <DeviceProperties>
            <DeviceType>0</DeviceType>
            <InternalPollInterval>10000</InternalPollInterval>
            <IsReadOnly>True</IsReadOnly>
            <ReadState>MODBUSR(H, 643, UInt16)</ReadState>
          </DeviceProperties>
        </Device>
        <Device>
          <Name>Generator port - power</Name>
          <Id>-19</Id>
          <Model>ModbusVariable</Model>
          <DeviceProperties>
            <DeviceType>0</DeviceType>
            <InternalPollInterval>10000</InternalPollInterval>
            <IsReadOnly>True</IsReadOnly>
            <ReadState>MODBUSR(H, 667, Int16)</ReadState>
          </DeviceProperties>
        </Device>
        <Device>
          <Name>DC transformer temperature</Name>
          <Id>-20</Id>
          <Model>ModbusTemperatureSensor</Model>
          <DeviceProperties>
            <DeviceType>0</DeviceType>
            <InternalPollInterval>30000</InternalPollInterval>
            <ReadTemperature>(MODBUSR(H, 540, UInt16) - 1000) / 10</ReadTemperature>
          </DeviceProperties>
        </Device>
        <Device>
          <Name>Heat sink temperature</Name>
          <Id>-21</Id>
          <Model>ModbusTemperatureSensor</Model>
          <DeviceProperties>
            <DeviceType>0</DeviceType>
            <InternalPollInterval>30000</InternalPollInterval>
            <ReadTemperature>(MODBUSR(H, 541, UInt16) - 1000) / 10</ReadTemperature>
          </DeviceProperties>
        </Device>
        <Device>
          <Name>Settings - energy management mode</Name>
          <Id>-22</Id>
          <Model>ModbusMultiValueSwitch</Model>
          <DeviceProperties>
            <DeviceType>0</DeviceType>
            <InternalPollInterval>10000</InternalPollInterval>
            <ReadSwitchState>MODBUSR(H, 142, UInt16)</ReadSwitchState>
            <WriteSwitchState>MODBUSWNE(H, 142, UInt16, Mu)</WriteSwitchState>
            <Value0>0</Value0>
            <Value0Index>0</Value0Index>
            <Value0Name>Selling first</Value0Name>
            <Value0IconId>5</Value0IconId>
            <Value1>1</Value1>
            <Value1Index>1</Value1Index>
            <Value1Name>Zero export to load</Value1Name>
            <Value1IconId>6</Value1IconId>
            <Value2>2</Value2>
            <Value2Index>2</Value2Index>
            <Value2Name>Zero export to CT</Value2Name>
            <Value2IconId>7</Value2IconId>
            <Value3Index>67</Value3Index>
            <Value4Index>68</Value4Index>
            <Value5Index>69</Value5Index>
            <Value6Index>70</Value6Index>
            <Value7Index>71</Value7Index>
            <Value8Index>72</Value8Index>
            <Value9Index>73</Value9Index>
          </DeviceProperties>
        </Device>
        <Device>
          <Name>Settings - solar sell</Name>
          <Id>-23</Id>
          <Model>ModbusSwitch</Model>
          <DeviceProperties>
            <DeviceType>0</DeviceType>
            <InternalPollInterval>10000</InternalPollInterval>
            <OnStateIconId>60</OnStateIconId>
            <OffStateIconId>61</OffStateIconId>
            <OnStateName>${general_on}</OnStateName>
            <OffStateName>${general_off}</OffStateName>
            <ReadSwitchState>MODBUSR(H, 145, UInt16)</ReadSwitchState>
            <WriteSwitchState>MODBUSWNE(H, 145, UInt16, St)</WriteSwitchState>
          </DeviceProperties>
        </Device>
        <Device>
          <Name>Settings - max sell power</Name>
          <Id>-24</Id>
          <Model>ModbusVariable</Model>
          <DeviceProperties>
            <DeviceType>0</DeviceType>
            <InternalPollInterval>30000</InternalPollInterval>
            <IsReadOnly>False</IsReadOnly>
            <ReadState>MODBUSR(H, 143, UInt16)</ReadState>
            <WriteState>MODBUSWNE(H, 143, UInt16, Va)</WriteState>
          </DeviceProperties>
        </Device>
        <Device>
          <Name>Settings - max solar sell power</Name>
          <Id>-25</Id>
          <Model>ModbusVariable</Model>
          <DeviceProperties>
            <DeviceType>0</DeviceType>
            <InternalPollInterval>30000</InternalPollInterval>
            <IsReadOnly>False</IsReadOnly>
            <ReadState>MODBUSR(H, 340, UInt16)</ReadState>
            <WriteState>MODBUSWNE(H, 340, UInt16, Va)</WriteState>
          </DeviceProperties>
        </Device>
        <Device>
          <Name>Settings - grid charging</Name>
          <Id>-26</Id>
          <Model>ModbusSwitch</Model>
          <DeviceProperties>
            <DeviceType>0</DeviceType>
            <InternalPollInterval>10000</InternalPollInterval>
            <OnStateIconId>60</OnStateIconId>
            <OffStateIconId>61</OffStateIconId>
            <OnStateName>${general_on}</OnStateName>
            <OffStateName>${general_off}</OffStateName>
            <ReadSwitchState>MODBUSR(H, 130, UInt16)</ReadSwitchState>
            <WriteSwitchState>MODBUSWNE(H, 130, UInt16, St)</WriteSwitchState>
          </DeviceProperties>
        </Device>
        <Device>
          <Name>Settings - grid charge current</Name>
          <Id>-27</Id>
          <Model>ModbusVariable</Model>
          <DeviceProperties>
            <DeviceType>0</DeviceType>
            <InternalPollInterval>30000</InternalPollInterval>
            <IsReadOnly>False</IsReadOnly>
            <ReadState>MODBUSR(H, 128, UInt16)</ReadState>
            <WriteState>MODBUSWNE(H, 128, UInt16, Va)</WriteState>
          </DeviceProperties>
        </Device>
        <Device>
          <Name>Settings - max battery charge current</Name>
          <Id>-28</Id>
          <Model>ModbusVariable</Model>
          <DeviceProperties>
            <DeviceType>0</DeviceType>
            <InternalPollInterval>30000</InternalPollInterval>
            <IsReadOnly>False</IsReadOnly>
            <ReadState>MODBUSR(H, 108, UInt16)</ReadState>
            <WriteState>MODBUSWNE(H, 108, UInt16, Va)</WriteState>
          </DeviceProperties>
        </Device>
        <Device>
          <Name>Settings - max battery discharge current</Name>
          <Id>-29</Id>
          <Model>ModbusVariable</Model>
          <DeviceProperties>
            <DeviceType>0</DeviceType>
            <InternalPollInterval>30000</InternalPollInterval>
            <IsReadOnly>False</IsReadOnly>
            <ReadState>MODBUSR(H, 109, UInt16)</ReadState>
            <WriteState>MODBUSWNE(H, 109, UInt16, Va)</WriteState>
          </DeviceProperties>
        </Device>
        <Device>
          <Name>Settings - generator port use</Name>
          <Id>-30</Id>
          <Model>ModbusMultiValueSwitch</Model>
          <DeviceProperties>
            <DeviceType>0</DeviceType>
            <InternalPollInterval>30000</InternalPollInterval>
            <ReadSwitchState>MODBUSR(H, 133, UInt16)</ReadSwitchState>
            <WriteSwitchState>MODBUSWNE(H, 133, UInt16, Mu)</WriteSwitchState>
            <Value0>0</Value0>
            <Value0Index>0</Value0Index>
            <Value0Name>Generator input</Value0Name>
            <Value0IconId>5</Value0IconId>
            <Value1>1</Value1>
            <Value1Index>1</Value1Index>
            <Value1Name>Smart load output</Value1Name>
            <Value1IconId>6</Value1IconId>
            <Value2>2</Value2>
            <Value2Index>2</Value2Index>
            <Value2Name>Micro-inverter input</Value2Name>
            <Value2IconId>7</Value2IconId>
            <Value3Index>67</Value3Index>
            <Value4Index>68</Value4Index>
            <Value5Index>69</Value5Index>
            <Value6Index>70</Value6Index>
            <Value7Index>71</Value7Index>
            <Value8Index>72</Value8Index>
            <Value9Index>73</Value9Index>
          </DeviceProperties>
        </Device>
        <Device>
          <Name>TOU - enable</Name>
          <Id>-31</Id>
          <Model>ModbusSwitch</Model>
          <DeviceProperties>
            <DeviceType>0</DeviceType>
            <InternalPollInterval>10000</InternalPollInterval>
            <OnStateIconId>60</OnStateIconId>
            <OffStateIconId>61</OffStateIconId>
            <OnStateName>${general_on}</OnStateName>
            <OffStateName>${general_off}</OffStateName>
            <ReadSwitchState>GETBIT(MODBUSR(H, 146, UInt16), 0)</ReadSwitchState>
            <WriteSwitchState>VAR reg := MODBUSR(H, 146, UInt16);
reg := SETBIT(reg, 0, St);
MODBUSWNE(H, 146, UInt16, reg)</WriteSwitchState>
          </DeviceProperties>
        </Device>
        <Device>
          <Name>TOU W1 - start time</Name>
          <Id>-32</Id>
          <Model>ModbusVariable</Model>
          <DeviceProperties>
            <DeviceType>0</DeviceType>
            <InternalPollInterval>60000</InternalPollInterval>
            <IsReadOnly>False</IsReadOnly>
            <ReadState>MODBUSR(H, 148, UInt16)</ReadState>
            <WriteState>MODBUSWNE(H, 148, UInt16, Va)</WriteState>
          </DeviceProperties>
        </Device>
        <Device>
          <Name>TOU W1 - target SoC</Name>
          <Id>-33</Id>
          <Model>ModbusDimmer</Model>
          <DeviceProperties>
            <DeviceType>0</DeviceType>
            <InternalPollInterval>60000</InternalPollInterval>
            <ReadLevel>LINEAR(MODBUSR(H, 166, UInt16), 0, 0, 100, 1)</ReadLevel>
            <WriteLevel>MODBUSWNE(H, 166, UInt16, LINEAR(Le, 0, 0, 1, 100))</WriteLevel>
          </DeviceProperties>
        </Device>
        <Device>
          <Name>TOU W1 - grid charging</Name>
          <Id>-34</Id>
          <Model>ModbusSwitch</Model>
          <DeviceProperties>
            <DeviceType>0</DeviceType>
            <InternalPollInterval>60000</InternalPollInterval>
            <OnStateIconId>60</OnStateIconId>
            <OffStateIconId>61</OffStateIconId>
            <OnStateName>${general_on}</OnStateName>
            <OffStateName>${general_off}</OffStateName>
            <ReadSwitchState>GETBIT(MODBUSR(H, 172, UInt16), 0)</ReadSwitchState>
            <WriteSwitchState>VAR reg := MODBUSR(H, 172, UInt16);
reg := SETBIT(reg, 0, St);
MODBUSWNE(H, 172, UInt16, reg)</WriteSwitchState>
          </DeviceProperties>
        </Device>
        <Device>
          <Name>TOU W2 - start time</Name>
          <Id>-35</Id>
          <Model>ModbusVariable</Model>
          <DeviceProperties>
            <DeviceType>0</DeviceType>
            <InternalPollInterval>60000</InternalPollInterval>
            <IsReadOnly>False</IsReadOnly>
            <ReadState>MODBUSR(H, 149, UInt16)</ReadState>
            <WriteState>MODBUSWNE(H, 149, UInt16, Va)</WriteState>
          </DeviceProperties>
        </Device>
        <Device>
          <Name>TOU W2 - target SoC</Name>
          <Id>-36</Id>
          <Model>ModbusDimmer</Model>
          <DeviceProperties>
            <DeviceType>0</DeviceType>
            <InternalPollInterval>60000</InternalPollInterval>
            <ReadLevel>LINEAR(MODBUSR(H, 167, UInt16), 0, 0, 100, 1)</ReadLevel>
            <WriteLevel>MODBUSWNE(H, 167, UInt16, LINEAR(Le, 0, 0, 1, 100))</WriteLevel>
          </DeviceProperties>
        </Device>
        <Device>
          <Name>TOU W2 - grid charging</Name>
          <Id>-37</Id>
          <Model>ModbusSwitch</Model>
          <DeviceProperties>
            <DeviceType>0</DeviceType>
            <InternalPollInterval>60000</InternalPollInterval>
            <OnStateIconId>60</OnStateIconId>
            <OffStateIconId>61</OffStateIconId>
            <OnStateName>${general_on}</OnStateName>
            <OffStateName>${general_off}</OffStateName>
            <ReadSwitchState>GETBIT(MODBUSR(H, 173, UInt16), 0)</ReadSwitchState>
            <WriteSwitchState>VAR reg := MODBUSR(H, 173, UInt16);
reg := SETBIT(reg, 0, St);
MODBUSWNE(H, 173, UInt16, reg)</WriteSwitchState>
          </DeviceProperties>
        </Device>
        <Device>
          <Name>TOU W3 - start time</Name>
          <Id>-38</Id>
          <Model>ModbusVariable</Model>
          <DeviceProperties>
            <DeviceType>0</DeviceType>
            <InternalPollInterval>60000</InternalPollInterval>
            <IsReadOnly>False</IsReadOnly>
            <ReadState>MODBUSR(H, 150, UInt16)</ReadState>
            <WriteState>MODBUSWNE(H, 150, UInt16, Va)</WriteState>
          </DeviceProperties>
        </Device>
        <Device>
          <Name>TOU W3 - target SoC</Name>
          <Id>-39</Id>
          <Model>ModbusDimmer</Model>
          <DeviceProperties>
            <DeviceType>0</DeviceType>
            <InternalPollInterval>60000</InternalPollInterval>
            <ReadLevel>LINEAR(MODBUSR(H, 168, UInt16), 0, 0, 100, 1)</ReadLevel>
            <WriteLevel>MODBUSWNE(H, 168, UInt16, LINEAR(Le, 0, 0, 1, 100))</WriteLevel>
          </DeviceProperties>
        </Device>
        <Device>
          <Name>TOU W3 - grid charging</Name>
          <Id>-40</Id>
          <Model>ModbusSwitch</Model>
          <DeviceProperties>
            <DeviceType>0</DeviceType>
            <InternalPollInterval>60000</InternalPollInterval>
            <OnStateIconId>60</OnStateIconId>
            <OffStateIconId>61</OffStateIconId>
            <OnStateName>${general_on}</OnStateName>
            <OffStateName>${general_off}</OffStateName>
            <ReadSwitchState>GETBIT(MODBUSR(H, 174, UInt16), 0)</ReadSwitchState>
            <WriteSwitchState>VAR reg := MODBUSR(H, 174, UInt16);
reg := SETBIT(reg, 0, St);
MODBUSWNE(H, 174, UInt16, reg)</WriteSwitchState>
          </DeviceProperties>
        </Device>
        <Device>
          <Name>TOU W4 - start time</Name>
          <Id>-41</Id>
          <Model>ModbusVariable</Model>
          <DeviceProperties>
            <DeviceType>0</DeviceType>
            <InternalPollInterval>60000</InternalPollInterval>
            <IsReadOnly>False</IsReadOnly>
            <ReadState>MODBUSR(H, 151, UInt16)</ReadState>
            <WriteState>MODBUSWNE(H, 151, UInt16, Va)</WriteState>
          </DeviceProperties>
        </Device>
        <Device>
          <Name>TOU W4 - target SoC</Name>
          <Id>-42</Id>
          <Model>ModbusDimmer</Model>
          <DeviceProperties>
            <DeviceType>0</DeviceType>
            <InternalPollInterval>60000</InternalPollInterval>
            <ReadLevel>LINEAR(MODBUSR(H, 169, UInt16), 0, 0, 100, 1)</ReadLevel>
            <WriteLevel>MODBUSWNE(H, 169, UInt16, LINEAR(Le, 0, 0, 1, 100))</WriteLevel>
          </DeviceProperties>
        </Device>
        <Device>
          <Name>TOU W4 - grid charging</Name>
          <Id>-43</Id>
          <Model>ModbusSwitch</Model>
          <DeviceProperties>
            <DeviceType>0</DeviceType>
            <InternalPollInterval>60000</InternalPollInterval>
            <OnStateIconId>60</OnStateIconId>
            <OffStateIconId>61</OffStateIconId>
            <OnStateName>${general_on}</OnStateName>
            <OffStateName>${general_off}</OffStateName>
            <ReadSwitchState>GETBIT(MODBUSR(H, 175, UInt16), 0)</ReadSwitchState>
            <WriteSwitchState>VAR reg := MODBUSR(H, 175, UInt16);
reg := SETBIT(reg, 0, St);
MODBUSWNE(H, 175, UInt16, reg)</WriteSwitchState>
          </DeviceProperties>
        </Device>
        <Device>
          <Name>TOU W5 - start time</Name>
          <Id>-44</Id>
          <Model>ModbusVariable</Model>
          <DeviceProperties>
            <DeviceType>0</DeviceType>
            <InternalPollInterval>60000</InternalPollInterval>
            <IsReadOnly>False</IsReadOnly>
            <ReadState>MODBUSR(H, 152, UInt16)</ReadState>
            <WriteState>MODBUSWNE(H, 152, UInt16, Va)</WriteState>
          </DeviceProperties>
        </Device>
        <Device>
          <Name>TOU W5 - target SoC</Name>
          <Id>-45</Id>
          <Model>ModbusDimmer</Model>
          <DeviceProperties>
            <DeviceType>0</DeviceType>
            <InternalPollInterval>60000</InternalPollInterval>
            <ReadLevel>LINEAR(MODBUSR(H, 170, UInt16), 0, 0, 100, 1)</ReadLevel>
            <WriteLevel>MODBUSWNE(H, 170, UInt16, LINEAR(Le, 0, 0, 1, 100))</WriteLevel>
          </DeviceProperties>
        </Device>
        <Device>
          <Name>TOU W5 - grid charging</Name>
          <Id>-46</Id>
          <Model>ModbusSwitch</Model>
          <DeviceProperties>
            <DeviceType>0</DeviceType>
            <InternalPollInterval>60000</InternalPollInterval>
            <OnStateIconId>60</OnStateIconId>
            <OffStateIconId>61</OffStateIconId>
            <OnStateName>${general_on}</OnStateName>
            <OffStateName>${general_off}</OffStateName>
            <ReadSwitchState>GETBIT(MODBUSR(H, 176, UInt16), 0)</ReadSwitchState>
            <WriteSwitchState>VAR reg := MODBUSR(H, 176, UInt16);
reg := SETBIT(reg, 0, St);
MODBUSWNE(H, 176, UInt16, reg)</WriteSwitchState>
          </DeviceProperties>
        </Device>
        <Device>
          <Name>TOU W6 - start time</Name>
          <Id>-47</Id>
          <Model>ModbusVariable</Model>
          <DeviceProperties>
            <DeviceType>0</DeviceType>
            <InternalPollInterval>60000</InternalPollInterval>
            <IsReadOnly>False</IsReadOnly>
            <ReadState>MODBUSR(H, 153, UInt16)</ReadState>
            <WriteState>MODBUSWNE(H, 153, UInt16, Va)</WriteState>
          </DeviceProperties>
        </Device>
        <Device>
          <Name>TOU W6 - target SoC</Name>
          <Id>-48</Id>
          <Model>ModbusDimmer</Model>
          <DeviceProperties>
            <DeviceType>0</DeviceType>
            <InternalPollInterval>60000</InternalPollInterval>
            <ReadLevel>LINEAR(MODBUSR(H, 171, UInt16), 0, 0, 100, 1)</ReadLevel>
            <WriteLevel>MODBUSWNE(H, 171, UInt16, LINEAR(Le, 0, 0, 1, 100))</WriteLevel>
          </DeviceProperties>
        </Device>
        <Device>
          <Name>TOU W6 - grid charging</Name>
          <Id>-49</Id>
          <Model>ModbusSwitch</Model>
          <DeviceProperties>
            <DeviceType>0</DeviceType>
            <InternalPollInterval>60000</InternalPollInterval>
            <OnStateIconId>60</OnStateIconId>
            <OffStateIconId>61</OffStateIconId>
            <OnStateName>${general_on}</OnStateName>
            <OffStateName>${general_off}</OffStateName>
            <ReadSwitchState>GETBIT(MODBUSR(H, 177, UInt16), 0)</ReadSwitchState>
            <WriteSwitchState>VAR reg := MODBUSR(H, 177, UInt16);
reg := SETBIT(reg, 0, St);
MODBUSWNE(H, 177, UInt16, reg)</WriteSwitchState>
          </DeviceProperties>
        </Device>
      </Devices>
    </Module>
  </Template>
</Templates>
