<?xml version="1.0" encoding="utf-8"?>
<Templates format="2" protocolVersion="83">
  <Template id="d1a2723a-9ef4-4228-8afc-35f1111b34d2" revision="1.1">
    <SuggestedCCUParameters>
      <TcpPort>502</TcpPort>
      <ReadWriteTimeout>1000</ReadWriteTimeout>
    </SuggestedCCUParameters>
    <RevisionHistory>
      <Revision id="1.1">Split the single-line IF … END in the module ReadScript into separate lines — Core rejected the script (Unexpected character &apos;;&apos;) and never ran it, so power stage errors never showed. Nothing else changed. Verified on TapHome Core core_stable/32388 with a Modbus TCP simulator, error and healthy scenario.</Revision>
    </RevisionHistory>
    <Name>my-PV AC•THOR</Name>
    <CcuModel>ModbusTcpCCU</CcuModel>
    <Producer>my-PV</Producer>
    <Model>AC•THOR / AC•THOR 9s</Model>
    <Description>Photovoltaic power manager that converts surplus solar power into hot water or space heating. TapHome steers the heating power over Modbus TCP.</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>Modbus Slave ID</Name>
        <Value>1</Value>
      </Parameter>
    </ImportParameters>
    <Module>
      <Name>AC•THOR</Name>
      <Id>-1</Id>
      <Model>ModbusModule</Model>
      <DeviceProperties>
        <IpAddress>$[IpAddress]</IpAddress>
        <Port>502</Port>
        <SlaveId>$[SlaveId]</SlaveId>
        <MaxPrefetchGroupSize>100</MaxPrefetchGroupSize>
        <ReadScript>VAR Code := MODBUSR(H, 1003, UInt16);
IF(Code &gt;= 200)
  ADDERROR(0, &quot;Power stage error (status code &quot; + TOSTRING(Code) + &quot;)&quot;);
END</ReadScript>
        <ServiceAttributesFormulas>[{&quot;AttributeDefinition&quot;:{&quot;Name&quot;:&quot;Operating status&quot;},&quot;ReadFormula&quot;:&quot;IF(MODBUSR(H, 1003, UInt16) &gt;= 200, \&quot;Power stage error\&quot;, IF(MODBUSR(H, 1003, UInt16) = 0, \&quot;Off\&quot;, IF(MODBUSR(H, 1003, UInt16) = 9, \&quot;Operation\&quot;, \&quot;Starting up\&quot;)))&quot;},{&quot;AttributeDefinition&quot;:{&quot;Name&quot;:&quot;Voltage L1&quot;},&quot;ReadFormula&quot;:&quot;MODBUSR(H, 1061, UInt16) + \&quot; V\&quot;&quot;},{&quot;AttributeDefinition&quot;:{&quot;Name&quot;:&quot;Current L1&quot;},&quot;ReadFormula&quot;:&quot;MODBUSR(H, 1062, UInt16) / 10 + \&quot; A\&quot;&quot;},{&quot;AttributeDefinition&quot;:{&quot;Name&quot;:&quot;Grid frequency&quot;},&quot;ReadFormula&quot;:&quot;TOSTRING(MODBUSR(H, 1064, UInt16) / 1000, \&quot;F2\&quot;) + \&quot; Hz\&quot;&quot;},{&quot;AttributeDefinition&quot;:{&quot;Name&quot;:&quot;Grid meter power&quot;},&quot;ReadFormula&quot;:&quot;MODBUSR(H, 1069, Int16) + \&quot; W\&quot;&quot;},{&quot;AttributeDefinition&quot;:{&quot;Name&quot;:&quot;Maximum power currently possible&quot;},&quot;ReadFormula&quot;:&quot;MODBUSR(H, 1071, UInt16) + \&quot; W\&quot;&quot;}]</ServiceAttributesFormulas>
      </DeviceProperties>
      <Devices>
        <Device>
          <Name>Power Target</Name>
          <Id>-2</Id>
          <Model>ModbusVariable</Model>
          <DeviceProperties>
            <DeviceType>0</DeviceType>
            <InternalPollInterval>2500</InternalPollInterval>
            <PrefetchModeId>0</PrefetchModeId>
            <IsReadOnly>False</IsReadOnly>
            <ShouldDoPeriodicWrite>True</ShouldDoPeriodicWrite>
            <ReadState>MODBUSR(H, 1000, UInt16)</ReadState>
            <WriteState>MODBUSW(H, 1000, UInt16, Va)</WriteState>
          </DeviceProperties>
        </Device>
        <Device>
          <Name>Hot Water Temperature</Name>
          <Id>-3</Id>
          <Model>ModbusTemperatureSensor</Model>
          <DeviceProperties>
            <DeviceType>0</DeviceType>
            <InternalPollInterval>15000</InternalPollInterval>
            <PrefetchModeId>0</PrefetchModeId>
            <ReadTemperature>MODBUSR(H, 1001, UInt16) / 10</ReadTemperature>
          </DeviceProperties>
        </Device>
        <Device>
          <Name>Heating Power</Name>
          <Id>-4</Id>
          <Model>ModbusElectricityMeter</Model>
          <DeviceProperties>
            <DeviceType>0</DeviceType>
            <InternalPollInterval>5000</InternalPollInterval>
            <PrefetchModeId>0</PrefetchModeId>
            <ReadDemand>MODBUSR(H, 1082, UInt16) / 1000</ReadDemand>
            <ServiceAttributesFormulas>[{&quot;AttributeDefinition&quot;:{&quot;Name&quot;:&quot;Solar part of heating power&quot;},&quot;ReadFormula&quot;:&quot;MODBUSR(H, 1083, UInt16) + \&quot; W\&quot;&quot;},{&quot;AttributeDefinition&quot;:{&quot;Name&quot;:&quot;Grid part of heating power&quot;},&quot;ReadFormula&quot;:&quot;MODBUSR(H, 1084, UInt16) + \&quot; W\&quot;&quot;}]</ServiceAttributesFormulas>
          </DeviceProperties>
        </Device>
      </Devices>
    </Module>
  </Template>
</Templates>
