<?xml version="1.0" encoding="utf-8"?>
<Templates format="2" protocolVersion="83">
  <Template id="7f3b2a91-4c8e-4d2a-9b6f-1e5a8c0d4f23" revision="1.1">
    <SuggestedCCUParameters>
      <TcpPort>502</TcpPort>
      <ReadWriteTimeout>1000</ReadWriteTimeout>
    </SuggestedCCUParameters>
    <RevisionHistory>
      <Revision id="1.0">Initial version</Revision>
      <Revision id="1.1">Split the single-line IF … END blocks in the module ReadScript into separate lines — Core rejected the script (Unexpected character &apos;;&apos;) and never ran it, so inverter fault, warning and off messages never showed. Nothing else changed. Verified on TapHome Core core_stable/32388 with a Modbus TCP simulator, fault, warning, off and healthy scenario.</Revision>
    </RevisionHistory>
    <Name>SMA Sunny Tripower Smart Energy</Name>
    <CcuModel>ModbusTcpCCU</CcuModel>
    <Producer>SMA</Producer>
    <Model>Sunny Tripower Smart Energy (STPxx-3SE-40)</Model>
    <Description>Read-only monitoring of the SMA Sunny Tripower Smart Energy hybrid inverter over Modbus TCP (SMA Modbus profile, Unit ID 3): solar production, grid exchange, battery state and grid diagnostics.</Description>
    <Category>2</Category>
    <ImportParameters>
      <Parameter>
        <Id>IpAddress</Id>
        <Name>IP address</Name>
        <Value>192.168.1.100</Value>
      </Parameter>
      <Parameter>
        <Id>SlaveId</Id>
        <Name>Unit ID (SMA Modbus profile)</Name>
        <Value>3</Value>
      </Parameter>
    </ImportParameters>
    <Module>
      <Name>SMA Sunny Tripower Smart Energy</Name>
      <Id>-1</Id>
      <Model>ModbusModule</Model>
      <DeviceProperties>
        <DeviceType>7001</DeviceType>
        <InternalPollInterval>30000</InternalPollInterval>
        <PrefetchModeId>0</PrefetchModeId>
        <IpAddress>$[IpAddress]</IpAddress>
        <Port>502</Port>
        <SlaveId>$[SlaveId]</SlaveId>
        <MaxPrefetchGroupSize>10</MaxPrefetchGroupSize>
        <ReadScript>VAR health := MODBUSR(H, 30201, UInt32);
IF(health = 35)
  ADDERROR(0, &quot;Inverter reports a fault - check the event log in the inverter user interface&quot;);
END
IF(health = 455)
  ADDWARNING(1, &quot;Inverter reports a warning - check the event log in the inverter user interface&quot;);
END
IF(health = 303)
  ADDINFO(2, &quot;Inverter is off&quot;);
END</ReadScript>
        <ServiceAttributesFormulas>[{&quot;AttributeDefinition&quot;: {&quot;Name&quot;: &quot;Device condition&quot;}, &quot;ReadFormula&quot;: &quot;SWITCH(MODBUSR(H, 30201, UInt32), 35, \&quot;Fault\&quot;, 303, \&quot;Off\&quot;, 307, \&quot;OK\&quot;, 455, \&quot;Warning\&quot;, \&quot;Unknown\&quot;)&quot;}, {&quot;AttributeDefinition&quot;: {&quot;Name&quot;: &quot;Battery operating status&quot;}, &quot;ReadFormula&quot;: &quot;SWITCH(MODBUSR(H, 30955, UInt32), 303, \&quot;Off\&quot;, 2291, \&quot;Standby\&quot;, 3664, \&quot;Emergency charge\&quot;, 2292, \&quot;Charging\&quot;, 2293, \&quot;Discharging\&quot;, 16777213, \&quot;Not available\&quot;, \&quot;Unknown\&quot;)&quot;}, {&quot;AttributeDefinition&quot;: {&quot;Name&quot;: &quot;Grid voltage L1&quot;}, &quot;ReadFormula&quot;: &quot;IF(MODBUSR(H, 30783, UInt32) = 4294967295, \&quot;n/a\&quot;, TOSTRING(MODBUSR(H, 30783, UInt32) / 100, \&quot;F1\&quot;) + \&quot; V\&quot;)&quot;}, {&quot;AttributeDefinition&quot;: {&quot;Name&quot;: &quot;Grid voltage L2&quot;}, &quot;ReadFormula&quot;: &quot;IF(MODBUSR(H, 30785, UInt32) = 4294967295, \&quot;n/a\&quot;, TOSTRING(MODBUSR(H, 30785, UInt32) / 100, \&quot;F1\&quot;) + \&quot; V\&quot;)&quot;}, {&quot;AttributeDefinition&quot;: {&quot;Name&quot;: &quot;Grid voltage L3&quot;}, &quot;ReadFormula&quot;: &quot;IF(MODBUSR(H, 30787, UInt32) = 4294967295, \&quot;n/a\&quot;, TOSTRING(MODBUSR(H, 30787, UInt32) / 100, \&quot;F1\&quot;) + \&quot; V\&quot;)&quot;}, {&quot;AttributeDefinition&quot;: {&quot;Name&quot;: &quot;Grid frequency&quot;}, &quot;ReadFormula&quot;: &quot;IF(MODBUSR(H, 30803, UInt32) = 4294967295, \&quot;n/a\&quot;, TOSTRING(MODBUSR(H, 30803, UInt32) / 100, \&quot;F2\&quot;) + \&quot; Hz\&quot;)&quot;}]</ServiceAttributesFormulas>
      </DeviceProperties>
      <Devices>
        <Device>
          <Name>${deviceType_PVProduction}</Name>
          <Id>-2</Id>
          <Model>ModbusElectricityMeter</Model>
          <DeviceProperties>
            <DeviceType>9002</DeviceType>
            <InternalPollInterval>15000</InternalPollInterval>
            <PrefetchModeId>0</PrefetchModeId>
            <ReadDemand>IF(MODBUSR(H, 30775, Int32) = -2147483648, 0, MODBUSR(H, 30775, Int32) / 1000)</ReadDemand>
            <ReadTotalConsumption>MODBUSR(H, 30529, UInt32) / 1000</ReadTotalConsumption>
          </DeviceProperties>
        </Device>
        <Device>
          <Name>${deviceType_PVFromGrid}</Name>
          <Id>-3</Id>
          <Model>ModbusElectricityMeter</Model>
          <DeviceProperties>
            <DeviceType>9004</DeviceType>
            <InternalPollInterval>15000</InternalPollInterval>
            <PrefetchModeId>0</PrefetchModeId>
            <ReadDemand>IF(MODBUSR(H, 30865, Int32) = -2147483648, 0, MODBUSR(H, 30865, Int32) / 1000)</ReadDemand>
            <ReadTotalConsumption>MODBUSR(H, 30581, UInt32) / 1000</ReadTotalConsumption>
          </DeviceProperties>
        </Device>
        <Device>
          <Name>${deviceType_PVToGrid}</Name>
          <Id>-4</Id>
          <Model>ModbusElectricityMeter</Model>
          <DeviceProperties>
            <DeviceType>9005</DeviceType>
            <InternalPollInterval>15000</InternalPollInterval>
            <PrefetchModeId>0</PrefetchModeId>
            <ReadDemand>IF(MODBUSR(H, 30867, Int32) = -2147483648, 0, MODBUSR(H, 30867, Int32) / 1000)</ReadDemand>
            <ReadTotalConsumption>MODBUSR(H, 30583, UInt32) / 1000</ReadTotalConsumption>
          </DeviceProperties>
        </Device>
        <Device>
          <Name>${deviceType_BatterySOC}</Name>
          <Id>-5</Id>
          <Model>ModbusAnalogInput</Model>
          <DeviceProperties>
            <DeviceType>11001</DeviceType>
            <InternalPollInterval>15000</InternalPollInterval>
            <PrefetchModeId>0</PrefetchModeId>
            <ReadInputLevel>IF(MODBUSR(H, 30845, UInt32) = 4294967295, 0, MODBUSR(H, 30845, UInt32) / 100)</ReadInputLevel>
          </DeviceProperties>
        </Device>
        <Device>
          <Name>Battery charging power</Name>
          <Id>-6</Id>
          <Model>ModbusVariable</Model>
          <DeviceProperties>
            <DeviceType>0</DeviceType>
            <InternalPollInterval>15000</InternalPollInterval>
            <PrefetchModeId>0</PrefetchModeId>
            <IsReadOnly>True</IsReadOnly>
            <ReadState>IF(MODBUSR(H, 31393, UInt32) = 4294967295, 0, MODBUSR(H, 31393, UInt32) / 1000)</ReadState>
          </DeviceProperties>
        </Device>
        <Device>
          <Name>Battery discharging power</Name>
          <Id>-7</Id>
          <Model>ModbusVariable</Model>
          <DeviceProperties>
            <DeviceType>0</DeviceType>
            <InternalPollInterval>15000</InternalPollInterval>
            <PrefetchModeId>0</PrefetchModeId>
            <IsReadOnly>True</IsReadOnly>
            <ReadState>IF(MODBUSR(H, 31395, UInt32) = 4294967295, 0, MODBUSR(H, 31395, UInt32) / 1000)</ReadState>
          </DeviceProperties>
        </Device>
      </Devices>
    </Module>
  </Template>
</Templates>
