<?xml version="1.0" encoding="UTF-8"?>
<zabbix_export>
    <version>5.2</version>
    <date>2026-10-07T00:00:00Z</date>
    <groups>
        <group>
            <name>Templates/MiRCA</name>
        </group>
    </groups>
    <templates>
        <template>
            <template>MiRCA Device</template>
            <name>MiRCA Device</name>
            <description>MiRCA board: system OIDs and the DS18B20 board temperature. SNMP v2c, Ethernet interface only (W5500). Default community 'public' (set {$SNMP_COMMUNITY}). Link the 'MiRCA Port N &lt;protocol&gt;' templates for the devices on the serial ports.</description>
            <groups>
                <group>
                    <name>Templates/MiRCA</name>
                </group>
            </groups>
            <applications>
                <application>
                    <name>General</name>
                </application>
                <application>
                    <name>Temperature</name>
                </application>
            </applications>
            <items>
                <item>
                    <name>System name</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.2.1.1.5.0</snmp_oid>
                    <key>mirca.sysname</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>0</trends>
                    <value_type>CHAR</value_type>
                    <description>nodename setting</description>
                    <inventory_link>NAME</inventory_link>
                    <applications>
                        <application>
                            <name>General</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>DISCARD_UNCHANGED_HEARTBEAT</type>
                            <parameters>
                                <parameter>12h</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Firmware</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.2.1.1.1.0</snmp_oid>
                    <key>mirca.firmware</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>0</trends>
                    <value_type>CHAR</value_type>
                    <description>sysDescr: 'MiRCA &lt;FW_VERSION&gt;'</description>
                    <inventory_link>OS</inventory_link>
                    <applications>
                        <application>
                            <name>General</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>DISCARD_UNCHANGED_HEARTBEAT</type>
                            <parameters>
                                <parameter>12h</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Board temperature (DS18B20)</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.2.1.6540.1.0</snmp_oid>
                    <key>mirca.ds18b20</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>°C</units>
                    <description>-127 °C: sensor not connected</description>
                    <applications>
                        <application>
                            <name>Temperature</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.01</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
            </items>
            <macros>
                <macro>
                    <macro>{$MIRCA.INTERVAL}</macro>
                    <value>30s</value>
                    <description>Polling interval of live values</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.INTERVAL.SLOW}</macro>
                    <value>5m</value>
                    <description>Polling interval of slowly changing values (capacity, cycles, energy counters)</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.NODATA.TIME}</macro>
                    <value>5m</value>
                    <description>No SNMP answer for this long raises a problem</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.BOARD.TEMP.MAX}</macro>
                    <value>60</value>
                    <description>DS18B20 temperature threshold, °C</description>
                </macro>
            </macros>
        </template>
        <template>
            <template>MiRCA Port 1 JK BMS Modbus</template>
            <name>MiRCA Port 1 JK BMS Modbus</name>
            <description>MiRCA serial port 1 running the 'JK BMS Modbus' protocol (protocol id 5). SNMP v2c over the Ethernet interface, tree .1.3.6.1.4.1.2021.13.16.4.2.1 (doc/ports.md). Link 'MiRCA Device' too. JK-PB BMS polled over RS485 Modbus (protocol 001), address = DIP address 1-15.</description>
            <groups>
                <group>
                    <name>Templates/MiRCA</name>
                </group>
            </groups>
            <applications>
                <application>
                    <name>Port 1</name>
                </application>
                <application>
                    <name>Battery</name>
                </application>
                <application>
                    <name>Cells</name>
                </application>
                <application>
                    <name>Temperature</name>
                </application>
            </applications>
            <items>
                <item>
                    <name>Port 1: protocol</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.1</snmp_oid>
                    <key>mirca.p1.protocol</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>UNSIGNED</value_type>
                    <description>Protocol configured on the port</description>
                    <applications>
                        <application>
                            <name>Port 1</name>
                        </application>
                    </applications>
                    <valuemap>
                        <name>MiRCA protocol</name>
                    </valuemap>
                </item>
                <item>
                    <name>Port 1: online</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.2</snmp_oid>
                    <key>mirca.p1.online</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>UNSIGNED</value_type>
                    <description>1 while the device answers. All values read 0 while it is offline.</description>
                    <applications>
                        <application>
                            <name>Port 1</name>
                        </application>
                    </applications>
                    <valuemap>
                        <name>MiRCA online</name>
                    </valuemap>
                </item>
                <item>
                    <name>Port 1: seconds since last reply</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.3</snmp_oid>
                    <key>mirca.p1.age</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>s</units>
                    <description>-1: no reply since boot</description>
                    <applications>
                        <application>
                            <name>Port 1</name>
                        </application>
                    </applications>
                </item>
                <item>
                    <name>Port 1: voltage</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.10</snmp_oid>
                    <key>mirca.p1.voltage</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>V</units>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.01</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 1: current</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.11</snmp_oid>
                    <key>mirca.p1.current</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>A</units>
                    <description>+ charging, - discharging</description>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.01</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 1: power</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.12</snmp_oid>
                    <key>mirca.p1.power</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>W</units>
                    <description>+ charging, - discharging</description>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                </item>
                <item>
                    <name>Port 1: SOC</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.13</snmp_oid>
                    <key>mirca.p1.soc</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>%</units>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.1</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 1: cycles</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.14</snmp_oid>
                    <key>mirca.p1.cycles</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>UNSIGNED</value_type>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                </item>
                <item>
                    <name>Port 1: remaining capacity</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.15</snmp_oid>
                    <key>mirca.p1.cap_remain</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>Ah</units>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.01</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 1: full capacity</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.16</snmp_oid>
                    <key>mirca.p1.cap_full</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>Ah</units>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.01</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 1: cell count</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.17</snmp_oid>
                    <key>mirca.p1.cell_count</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>UNSIGNED</value_type>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                </item>
                <item>
                    <name>Port 1: MOSFET temperature</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.18</snmp_oid>
                    <key>mirca.p1.mos_temp</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>°C</units>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.1</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 1: alarm bits</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.19</snmp_oid>
                    <key>mirca.p1.alarms</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>UNSIGNED</value_type>
                    <description>JK alarm bit mask (register 0xA0), see doc/ports.md</description>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>JAVASCRIPT</type>
                            <parameters>
                                <parameter>return (parseInt(value, 10) &gt;&gt;&gt; 0).toString();</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 1: alarms</name>
                    <type>DEPENDENT</type>
                    <key>mirca.p1.alarms.text</key>
                    <delay>0</delay>
                    <history>14d</history>
                    <trends>0</trends>
                    <value_type>CHAR</value_type>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>JAVASCRIPT</type>
                            <parameters>
                                <parameter>var names = ['balance wire resistance too high', 'MOSFET overtemperature', 'cell count mismatch', 'current sensor fault', 'cell overvoltage', 'battery overvoltage', 'charge overcurrent', 'charge short circuit', 'charge overtemperature', 'charge undertemperature', 'internal communication fault', 'cell undervoltage', 'battery undervoltage', 'discharge overcurrent', 'discharge short circuit', 'discharge overtemperature', 'charge MOSFET fault', 'discharge MOSFET fault', 'GPS disconnected', 'change authorization password', 'discharge enable failed', 'battery overtemperature', 'temperature sensor fault'];
var v = parseInt(value, 10) &gt;&gt;&gt; 0, out = [];
for (var i = 0; i &lt; 32; i++)
  if ((v &gt;&gt;&gt; i) &amp; 1) out.push(i &lt; names.length ? names[i] : 'bit ' + i);
return out.length ? out.join(', ') : 'none';</parameter>
                            </parameters>
                        </step>
                        <step>
                            <type>DISCARD_UNCHANGED_HEARTBEAT</type>
                            <parameters>
                                <parameter>1h</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                    <master_item>
                        <key>mirca.p1.alarms</key>
                    </master_item>
                </item>
            </items>
            <discovery_rules>
                <discovery_rule>
                    <name>Port 1: cells discovery</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>discovery[{#SNMPVALUE},1.3.6.1.4.1.2021.13.16.4.2.1.20]</snmp_oid>
                    <key>mirca.p1.cells.discovery</key>
                    <delay>1h</delay>
                    <filter>
                        <evaltype>AND</evaltype>
                        <conditions>
                            <condition>
                                <macro>{#SNMPVALUE}</macro>
                                <value>^[1-9]</value>
                                <formulaid>A</formulaid>
                            </condition>
                        </conditions>
                    </filter>
                    <lifetime>7d</lifetime>
                    <description>Cells the BMS reports (cell voltage &gt; 0 at discovery time)</description>
                    <item_prototypes>
                        <item_prototype>
                            <name>Port 1: cell {#SNMPINDEX} voltage</name>
                            <type>SNMP_AGENT</type>
                            <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.20.{#SNMPINDEX}</snmp_oid>
                            <key>mirca.p1.cell[{#SNMPINDEX}]</key>
                            <delay>{$MIRCA.INTERVAL}</delay>
                            <history>14d</history>
                            <trends>365d</trends>
                            <value_type>FLOAT</value_type>
                            <units>V</units>
                            <applications>
                                <application>
                                    <name>Cells</name>
                                </application>
                            </applications>
                            <preprocessing>
                                <step>
                                    <type>MULTIPLIER</type>
                                    <parameters>
                                        <parameter>0.001</parameter>
                                    </parameters>
                                </step>
                            </preprocessing>
                        </item_prototype>
                    </item_prototypes>
                    <trigger_prototypes>
                        <trigger_prototype>
                            <expression>{MiRCA Port 1 JK BMS Modbus:mirca.p1.cell[{#SNMPINDEX}].max(2m)}&lt;{$MIRCA.CELL.UV:"p1"} and {MiRCA Port 1 JK BMS Modbus:mirca.p1.online.last()}=1</expression>
                            <name>Port 1: cell {#SNMPINDEX} undervoltage (&lt;{$MIRCA.CELL.UV:"p1"}V)</name>
                            <priority>HIGH</priority>
                        </trigger_prototype>
                        <trigger_prototype>
                            <expression>{MiRCA Port 1 JK BMS Modbus:mirca.p1.cell[{#SNMPINDEX}].min(2m)}&gt;{$MIRCA.CELL.OV:"p1"} and {MiRCA Port 1 JK BMS Modbus:mirca.p1.online.last()}=1</expression>
                            <name>Port 1: cell {#SNMPINDEX} overvoltage (&gt;{$MIRCA.CELL.OV:"p1"}V)</name>
                            <priority>HIGH</priority>
                        </trigger_prototype>
                    </trigger_prototypes>
                </discovery_rule>
                <discovery_rule>
                    <name>Port 1: temperature sensors discovery</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>discovery[{#SNMPVALUE},1.3.6.1.4.1.2021.13.16.4.2.1.21]</snmp_oid>
                    <key>mirca.p1.temps.discovery</key>
                    <delay>1h</delay>
                    <filter>
                        <evaltype>AND</evaltype>
                        <conditions>
                            <condition>
                                <macro>{#SNMPVALUE}</macro>
                                <value>^-?[1-9]</value>
                                <formulaid>A</formulaid>
                            </condition>
                        </conditions>
                    </filter>
                    <lifetime>7d</lifetime>
                    <description>Temperature sensors the BMS reports (non-zero at discovery time)</description>
                    <item_prototypes>
                        <item_prototype>
                            <name>Port 1: temperature T{#SNMPINDEX}</name>
                            <type>SNMP_AGENT</type>
                            <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.21.{#SNMPINDEX}</snmp_oid>
                            <key>mirca.p1.temp[{#SNMPINDEX}]</key>
                            <delay>{$MIRCA.INTERVAL}</delay>
                            <history>14d</history>
                            <trends>365d</trends>
                            <value_type>FLOAT</value_type>
                            <units>°C</units>
                            <applications>
                                <application>
                                    <name>Temperature</name>
                                </application>
                            </applications>
                            <preprocessing>
                                <step>
                                    <type>MULTIPLIER</type>
                                    <parameters>
                                        <parameter>0.1</parameter>
                                    </parameters>
                                </step>
                            </preprocessing>
                        </item_prototype>
                    </item_prototypes>
                    <trigger_prototypes>
                        <trigger_prototype>
                            <expression>{MiRCA Port 1 JK BMS Modbus:mirca.p1.temp[{#SNMPINDEX}].min(5m)}&gt;{$MIRCA.TEMP.MAX:"p1"} and {MiRCA Port 1 JK BMS Modbus:mirca.p1.online.last()}=1</expression>
                            <name>Port 1: temperature T{#SNMPINDEX} is high (&gt;{$MIRCA.TEMP.MAX:"p1"}°C)</name>
                            <priority>AVERAGE</priority>
                        </trigger_prototype>
                        <trigger_prototype>
                            <expression>{MiRCA Port 1 JK BMS Modbus:mirca.p1.temp[{#SNMPINDEX}].max(5m)}&lt;{$MIRCA.TEMP.MIN:"p1"} and {MiRCA Port 1 JK BMS Modbus:mirca.p1.online.last()}=1</expression>
                            <name>Port 1: temperature T{#SNMPINDEX} is low (&lt;{$MIRCA.TEMP.MIN:"p1"}°C)</name>
                            <priority>WARNING</priority>
                        </trigger_prototype>
                    </trigger_prototypes>
                </discovery_rule>
            </discovery_rules>
            <macros>
                <macro>
                    <macro>{$MIRCA.INTERVAL}</macro>
                    <value>30s</value>
                    <description>Polling interval of live values</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.INTERVAL.SLOW}</macro>
                    <value>5m</value>
                    <description>Polling interval of slowly changing values (capacity, cycles, energy counters)</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.OFFLINE.TIME}</macro>
                    <value>5m</value>
                    <description>How long the device may stay silent before a problem is raised</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.SOC.WARN}</macro>
                    <value>20</value>
                    <description>SOC below this, %, raises a warning. Per port: {$MIRCA.SOC.WARN:"p1"}</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.SOC.CRIT}</macro>
                    <value>10</value>
                    <description>SOC below this, %, raises a high problem. Per port: {$MIRCA.SOC.CRIT:"p1"}</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.CELL.UV}</macro>
                    <value>2.9</value>
                    <description>Cell undervoltage threshold, V (LiFePO4 default). Per port: {$MIRCA.CELL.UV:"p1"}</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.CELL.OV}</macro>
                    <value>3.65</value>
                    <description>Cell overvoltage threshold, V (LiFePO4 default). Per port: {$MIRCA.CELL.OV:"p1"}</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.TEMP.MAX}</macro>
                    <value>50</value>
                    <description>Battery temperature sensor high threshold, °C. Per port: {$MIRCA.TEMP.MAX:"p1"}</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.TEMP.MIN}</macro>
                    <value>0</value>
                    <description>Battery temperature sensor low threshold, °C. Per port: {$MIRCA.TEMP.MIN:"p1"}</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.MOS.TEMP.MAX}</macro>
                    <value>80</value>
                    <description>MOSFET temperature threshold, °C. Per port: {$MIRCA.MOS.TEMP.MAX:"p1"}</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.JK.ALARM.MASK}</macro>
                    <value>7602175</value>
                    <description>JK alarm bits that raise a problem (default: bits 0-22 without 18 'GPS disconnected' and 19 'change authorization password')</description>
                </macro>
            </macros>
        </template>
        <template>
            <template>MiRCA Port 2 JK BMS Modbus</template>
            <name>MiRCA Port 2 JK BMS Modbus</name>
            <description>MiRCA serial port 2 running the 'JK BMS Modbus' protocol (protocol id 5). SNMP v2c over the Ethernet interface, tree .1.3.6.1.4.1.2021.13.16.4.2.2 (doc/ports.md). Link 'MiRCA Device' too. JK-PB BMS polled over RS485 Modbus (protocol 001), address = DIP address 1-15.</description>
            <groups>
                <group>
                    <name>Templates/MiRCA</name>
                </group>
            </groups>
            <applications>
                <application>
                    <name>Port 2</name>
                </application>
                <application>
                    <name>Battery</name>
                </application>
                <application>
                    <name>Cells</name>
                </application>
                <application>
                    <name>Temperature</name>
                </application>
            </applications>
            <items>
                <item>
                    <name>Port 2: protocol</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.1</snmp_oid>
                    <key>mirca.p2.protocol</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>UNSIGNED</value_type>
                    <description>Protocol configured on the port</description>
                    <applications>
                        <application>
                            <name>Port 2</name>
                        </application>
                    </applications>
                    <valuemap>
                        <name>MiRCA protocol</name>
                    </valuemap>
                </item>
                <item>
                    <name>Port 2: online</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.2</snmp_oid>
                    <key>mirca.p2.online</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>UNSIGNED</value_type>
                    <description>1 while the device answers. All values read 0 while it is offline.</description>
                    <applications>
                        <application>
                            <name>Port 2</name>
                        </application>
                    </applications>
                    <valuemap>
                        <name>MiRCA online</name>
                    </valuemap>
                </item>
                <item>
                    <name>Port 2: seconds since last reply</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.3</snmp_oid>
                    <key>mirca.p2.age</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>s</units>
                    <description>-1: no reply since boot</description>
                    <applications>
                        <application>
                            <name>Port 2</name>
                        </application>
                    </applications>
                </item>
                <item>
                    <name>Port 2: voltage</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.10</snmp_oid>
                    <key>mirca.p2.voltage</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>V</units>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.01</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 2: current</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.11</snmp_oid>
                    <key>mirca.p2.current</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>A</units>
                    <description>+ charging, - discharging</description>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.01</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 2: power</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.12</snmp_oid>
                    <key>mirca.p2.power</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>W</units>
                    <description>+ charging, - discharging</description>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                </item>
                <item>
                    <name>Port 2: SOC</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.13</snmp_oid>
                    <key>mirca.p2.soc</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>%</units>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.1</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 2: cycles</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.14</snmp_oid>
                    <key>mirca.p2.cycles</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>UNSIGNED</value_type>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                </item>
                <item>
                    <name>Port 2: remaining capacity</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.15</snmp_oid>
                    <key>mirca.p2.cap_remain</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>Ah</units>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.01</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 2: full capacity</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.16</snmp_oid>
                    <key>mirca.p2.cap_full</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>Ah</units>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.01</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 2: cell count</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.17</snmp_oid>
                    <key>mirca.p2.cell_count</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>UNSIGNED</value_type>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                </item>
                <item>
                    <name>Port 2: MOSFET temperature</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.18</snmp_oid>
                    <key>mirca.p2.mos_temp</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>°C</units>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.1</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 2: alarm bits</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.19</snmp_oid>
                    <key>mirca.p2.alarms</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>UNSIGNED</value_type>
                    <description>JK alarm bit mask (register 0xA0), see doc/ports.md</description>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>JAVASCRIPT</type>
                            <parameters>
                                <parameter>return (parseInt(value, 10) &gt;&gt;&gt; 0).toString();</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 2: alarms</name>
                    <type>DEPENDENT</type>
                    <key>mirca.p2.alarms.text</key>
                    <delay>0</delay>
                    <history>14d</history>
                    <trends>0</trends>
                    <value_type>CHAR</value_type>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>JAVASCRIPT</type>
                            <parameters>
                                <parameter>var names = ['balance wire resistance too high', 'MOSFET overtemperature', 'cell count mismatch', 'current sensor fault', 'cell overvoltage', 'battery overvoltage', 'charge overcurrent', 'charge short circuit', 'charge overtemperature', 'charge undertemperature', 'internal communication fault', 'cell undervoltage', 'battery undervoltage', 'discharge overcurrent', 'discharge short circuit', 'discharge overtemperature', 'charge MOSFET fault', 'discharge MOSFET fault', 'GPS disconnected', 'change authorization password', 'discharge enable failed', 'battery overtemperature', 'temperature sensor fault'];
var v = parseInt(value, 10) &gt;&gt;&gt; 0, out = [];
for (var i = 0; i &lt; 32; i++)
  if ((v &gt;&gt;&gt; i) &amp; 1) out.push(i &lt; names.length ? names[i] : 'bit ' + i);
return out.length ? out.join(', ') : 'none';</parameter>
                            </parameters>
                        </step>
                        <step>
                            <type>DISCARD_UNCHANGED_HEARTBEAT</type>
                            <parameters>
                                <parameter>1h</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                    <master_item>
                        <key>mirca.p2.alarms</key>
                    </master_item>
                </item>
            </items>
            <discovery_rules>
                <discovery_rule>
                    <name>Port 2: cells discovery</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>discovery[{#SNMPVALUE},1.3.6.1.4.1.2021.13.16.4.2.2.20]</snmp_oid>
                    <key>mirca.p2.cells.discovery</key>
                    <delay>1h</delay>
                    <filter>
                        <evaltype>AND</evaltype>
                        <conditions>
                            <condition>
                                <macro>{#SNMPVALUE}</macro>
                                <value>^[1-9]</value>
                                <formulaid>A</formulaid>
                            </condition>
                        </conditions>
                    </filter>
                    <lifetime>7d</lifetime>
                    <description>Cells the BMS reports (cell voltage &gt; 0 at discovery time)</description>
                    <item_prototypes>
                        <item_prototype>
                            <name>Port 2: cell {#SNMPINDEX} voltage</name>
                            <type>SNMP_AGENT</type>
                            <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.20.{#SNMPINDEX}</snmp_oid>
                            <key>mirca.p2.cell[{#SNMPINDEX}]</key>
                            <delay>{$MIRCA.INTERVAL}</delay>
                            <history>14d</history>
                            <trends>365d</trends>
                            <value_type>FLOAT</value_type>
                            <units>V</units>
                            <applications>
                                <application>
                                    <name>Cells</name>
                                </application>
                            </applications>
                            <preprocessing>
                                <step>
                                    <type>MULTIPLIER</type>
                                    <parameters>
                                        <parameter>0.001</parameter>
                                    </parameters>
                                </step>
                            </preprocessing>
                        </item_prototype>
                    </item_prototypes>
                    <trigger_prototypes>
                        <trigger_prototype>
                            <expression>{MiRCA Port 2 JK BMS Modbus:mirca.p2.cell[{#SNMPINDEX}].max(2m)}&lt;{$MIRCA.CELL.UV:"p2"} and {MiRCA Port 2 JK BMS Modbus:mirca.p2.online.last()}=1</expression>
                            <name>Port 2: cell {#SNMPINDEX} undervoltage (&lt;{$MIRCA.CELL.UV:"p2"}V)</name>
                            <priority>HIGH</priority>
                        </trigger_prototype>
                        <trigger_prototype>
                            <expression>{MiRCA Port 2 JK BMS Modbus:mirca.p2.cell[{#SNMPINDEX}].min(2m)}&gt;{$MIRCA.CELL.OV:"p2"} and {MiRCA Port 2 JK BMS Modbus:mirca.p2.online.last()}=1</expression>
                            <name>Port 2: cell {#SNMPINDEX} overvoltage (&gt;{$MIRCA.CELL.OV:"p2"}V)</name>
                            <priority>HIGH</priority>
                        </trigger_prototype>
                    </trigger_prototypes>
                </discovery_rule>
                <discovery_rule>
                    <name>Port 2: temperature sensors discovery</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>discovery[{#SNMPVALUE},1.3.6.1.4.1.2021.13.16.4.2.2.21]</snmp_oid>
                    <key>mirca.p2.temps.discovery</key>
                    <delay>1h</delay>
                    <filter>
                        <evaltype>AND</evaltype>
                        <conditions>
                            <condition>
                                <macro>{#SNMPVALUE}</macro>
                                <value>^-?[1-9]</value>
                                <formulaid>A</formulaid>
                            </condition>
                        </conditions>
                    </filter>
                    <lifetime>7d</lifetime>
                    <description>Temperature sensors the BMS reports (non-zero at discovery time)</description>
                    <item_prototypes>
                        <item_prototype>
                            <name>Port 2: temperature T{#SNMPINDEX}</name>
                            <type>SNMP_AGENT</type>
                            <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.21.{#SNMPINDEX}</snmp_oid>
                            <key>mirca.p2.temp[{#SNMPINDEX}]</key>
                            <delay>{$MIRCA.INTERVAL}</delay>
                            <history>14d</history>
                            <trends>365d</trends>
                            <value_type>FLOAT</value_type>
                            <units>°C</units>
                            <applications>
                                <application>
                                    <name>Temperature</name>
                                </application>
                            </applications>
                            <preprocessing>
                                <step>
                                    <type>MULTIPLIER</type>
                                    <parameters>
                                        <parameter>0.1</parameter>
                                    </parameters>
                                </step>
                            </preprocessing>
                        </item_prototype>
                    </item_prototypes>
                    <trigger_prototypes>
                        <trigger_prototype>
                            <expression>{MiRCA Port 2 JK BMS Modbus:mirca.p2.temp[{#SNMPINDEX}].min(5m)}&gt;{$MIRCA.TEMP.MAX:"p2"} and {MiRCA Port 2 JK BMS Modbus:mirca.p2.online.last()}=1</expression>
                            <name>Port 2: temperature T{#SNMPINDEX} is high (&gt;{$MIRCA.TEMP.MAX:"p2"}°C)</name>
                            <priority>AVERAGE</priority>
                        </trigger_prototype>
                        <trigger_prototype>
                            <expression>{MiRCA Port 2 JK BMS Modbus:mirca.p2.temp[{#SNMPINDEX}].max(5m)}&lt;{$MIRCA.TEMP.MIN:"p2"} and {MiRCA Port 2 JK BMS Modbus:mirca.p2.online.last()}=1</expression>
                            <name>Port 2: temperature T{#SNMPINDEX} is low (&lt;{$MIRCA.TEMP.MIN:"p2"}°C)</name>
                            <priority>WARNING</priority>
                        </trigger_prototype>
                    </trigger_prototypes>
                </discovery_rule>
            </discovery_rules>
            <macros>
                <macro>
                    <macro>{$MIRCA.INTERVAL}</macro>
                    <value>30s</value>
                    <description>Polling interval of live values</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.INTERVAL.SLOW}</macro>
                    <value>5m</value>
                    <description>Polling interval of slowly changing values (capacity, cycles, energy counters)</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.OFFLINE.TIME}</macro>
                    <value>5m</value>
                    <description>How long the device may stay silent before a problem is raised</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.SOC.WARN}</macro>
                    <value>20</value>
                    <description>SOC below this, %, raises a warning. Per port: {$MIRCA.SOC.WARN:"p1"}</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.SOC.CRIT}</macro>
                    <value>10</value>
                    <description>SOC below this, %, raises a high problem. Per port: {$MIRCA.SOC.CRIT:"p1"}</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.CELL.UV}</macro>
                    <value>2.9</value>
                    <description>Cell undervoltage threshold, V (LiFePO4 default). Per port: {$MIRCA.CELL.UV:"p1"}</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.CELL.OV}</macro>
                    <value>3.65</value>
                    <description>Cell overvoltage threshold, V (LiFePO4 default). Per port: {$MIRCA.CELL.OV:"p1"}</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.TEMP.MAX}</macro>
                    <value>50</value>
                    <description>Battery temperature sensor high threshold, °C. Per port: {$MIRCA.TEMP.MAX:"p1"}</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.TEMP.MIN}</macro>
                    <value>0</value>
                    <description>Battery temperature sensor low threshold, °C. Per port: {$MIRCA.TEMP.MIN:"p1"}</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.MOS.TEMP.MAX}</macro>
                    <value>80</value>
                    <description>MOSFET temperature threshold, °C. Per port: {$MIRCA.MOS.TEMP.MAX:"p1"}</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.JK.ALARM.MASK}</macro>
                    <value>7602175</value>
                    <description>JK alarm bits that raise a problem (default: bits 0-22 without 18 'GPS disconnected' and 19 'change authorization password')</description>
                </macro>
            </macros>
        </template>
        <template>
            <template>MiRCA Port 1 JK BMS 4G-GPS</template>
            <name>MiRCA Port 1 JK BMS 4G-GPS</name>
            <description>MiRCA serial port 1 running the 'JK BMS 4G-GPS' protocol (protocol id 2). SNMP v2c over the Ethernet interface, tree .1.3.6.1.4.1.2021.13.16.4.2.1 (doc/ports.md). Link 'MiRCA Device' too. JK BMS over the 4G-GPS protocol (000).</description>
            <groups>
                <group>
                    <name>Templates/MiRCA</name>
                </group>
            </groups>
            <applications>
                <application>
                    <name>Port 1</name>
                </application>
                <application>
                    <name>Battery</name>
                </application>
                <application>
                    <name>Cells</name>
                </application>
                <application>
                    <name>Temperature</name>
                </application>
            </applications>
            <items>
                <item>
                    <name>Port 1: protocol</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.1</snmp_oid>
                    <key>mirca.p1.protocol</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>UNSIGNED</value_type>
                    <description>Protocol configured on the port</description>
                    <applications>
                        <application>
                            <name>Port 1</name>
                        </application>
                    </applications>
                    <valuemap>
                        <name>MiRCA protocol</name>
                    </valuemap>
                </item>
                <item>
                    <name>Port 1: online</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.2</snmp_oid>
                    <key>mirca.p1.online</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>UNSIGNED</value_type>
                    <description>1 while the device answers. All values read 0 while it is offline.</description>
                    <applications>
                        <application>
                            <name>Port 1</name>
                        </application>
                    </applications>
                    <valuemap>
                        <name>MiRCA online</name>
                    </valuemap>
                </item>
                <item>
                    <name>Port 1: seconds since last reply</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.3</snmp_oid>
                    <key>mirca.p1.age</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>s</units>
                    <description>-1: no reply since boot</description>
                    <applications>
                        <application>
                            <name>Port 1</name>
                        </application>
                    </applications>
                </item>
                <item>
                    <name>Port 1: voltage</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.10</snmp_oid>
                    <key>mirca.p1.voltage</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>V</units>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.01</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 1: current</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.11</snmp_oid>
                    <key>mirca.p1.current</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>A</units>
                    <description>+ charging, - discharging</description>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.01</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 1: SOC</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.13</snmp_oid>
                    <key>mirca.p1.soc</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>%</units>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.1</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 1: cycles</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.14</snmp_oid>
                    <key>mirca.p1.cycles</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>UNSIGNED</value_type>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                </item>
                <item>
                    <name>Port 1: cell count</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.17</snmp_oid>
                    <key>mirca.p1.cell_count</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>UNSIGNED</value_type>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                </item>
                <item>
                    <name>Port 1: power (calculated)</name>
                    <type>CALCULATED</type>
                    <key>mirca.p1.power.calc</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>W</units>
                    <params>last(mirca.p1.voltage)*last(mirca.p1.current)</params>
                    <description>Voltage x current; the protocol does not report power. + charging</description>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                </item>
            </items>
            <discovery_rules>
                <discovery_rule>
                    <name>Port 1: cells discovery</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>discovery[{#SNMPVALUE},1.3.6.1.4.1.2021.13.16.4.2.1.20]</snmp_oid>
                    <key>mirca.p1.cells.discovery</key>
                    <delay>1h</delay>
                    <filter>
                        <evaltype>AND</evaltype>
                        <conditions>
                            <condition>
                                <macro>{#SNMPVALUE}</macro>
                                <value>^[1-9]</value>
                                <formulaid>A</formulaid>
                            </condition>
                        </conditions>
                    </filter>
                    <lifetime>7d</lifetime>
                    <description>Cells the BMS reports (cell voltage &gt; 0 at discovery time)</description>
                    <item_prototypes>
                        <item_prototype>
                            <name>Port 1: cell {#SNMPINDEX} voltage</name>
                            <type>SNMP_AGENT</type>
                            <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.20.{#SNMPINDEX}</snmp_oid>
                            <key>mirca.p1.cell[{#SNMPINDEX}]</key>
                            <delay>{$MIRCA.INTERVAL}</delay>
                            <history>14d</history>
                            <trends>365d</trends>
                            <value_type>FLOAT</value_type>
                            <units>V</units>
                            <applications>
                                <application>
                                    <name>Cells</name>
                                </application>
                            </applications>
                            <preprocessing>
                                <step>
                                    <type>MULTIPLIER</type>
                                    <parameters>
                                        <parameter>0.001</parameter>
                                    </parameters>
                                </step>
                            </preprocessing>
                        </item_prototype>
                    </item_prototypes>
                    <trigger_prototypes>
                        <trigger_prototype>
                            <expression>{MiRCA Port 1 JK BMS 4G-GPS:mirca.p1.cell[{#SNMPINDEX}].max(2m)}&lt;{$MIRCA.CELL.UV:"p1"} and {MiRCA Port 1 JK BMS 4G-GPS:mirca.p1.online.last()}=1</expression>
                            <name>Port 1: cell {#SNMPINDEX} undervoltage (&lt;{$MIRCA.CELL.UV:"p1"}V)</name>
                            <priority>HIGH</priority>
                        </trigger_prototype>
                        <trigger_prototype>
                            <expression>{MiRCA Port 1 JK BMS 4G-GPS:mirca.p1.cell[{#SNMPINDEX}].min(2m)}&gt;{$MIRCA.CELL.OV:"p1"} and {MiRCA Port 1 JK BMS 4G-GPS:mirca.p1.online.last()}=1</expression>
                            <name>Port 1: cell {#SNMPINDEX} overvoltage (&gt;{$MIRCA.CELL.OV:"p1"}V)</name>
                            <priority>HIGH</priority>
                        </trigger_prototype>
                    </trigger_prototypes>
                </discovery_rule>
                <discovery_rule>
                    <name>Port 1: temperature sensors discovery</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>discovery[{#SNMPVALUE},1.3.6.1.4.1.2021.13.16.4.2.1.21]</snmp_oid>
                    <key>mirca.p1.temps.discovery</key>
                    <delay>1h</delay>
                    <filter>
                        <evaltype>AND</evaltype>
                        <conditions>
                            <condition>
                                <macro>{#SNMPVALUE}</macro>
                                <value>^-?[1-9]</value>
                                <formulaid>A</formulaid>
                            </condition>
                        </conditions>
                    </filter>
                    <lifetime>7d</lifetime>
                    <description>Temperature sensors the BMS reports (non-zero at discovery time)</description>
                    <item_prototypes>
                        <item_prototype>
                            <name>Port 1: temperature T{#SNMPINDEX}</name>
                            <type>SNMP_AGENT</type>
                            <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.21.{#SNMPINDEX}</snmp_oid>
                            <key>mirca.p1.temp[{#SNMPINDEX}]</key>
                            <delay>{$MIRCA.INTERVAL}</delay>
                            <history>14d</history>
                            <trends>365d</trends>
                            <value_type>FLOAT</value_type>
                            <units>°C</units>
                            <applications>
                                <application>
                                    <name>Temperature</name>
                                </application>
                            </applications>
                            <preprocessing>
                                <step>
                                    <type>MULTIPLIER</type>
                                    <parameters>
                                        <parameter>0.1</parameter>
                                    </parameters>
                                </step>
                            </preprocessing>
                        </item_prototype>
                    </item_prototypes>
                    <trigger_prototypes>
                        <trigger_prototype>
                            <expression>{MiRCA Port 1 JK BMS 4G-GPS:mirca.p1.temp[{#SNMPINDEX}].min(5m)}&gt;{$MIRCA.TEMP.MAX:"p1"} and {MiRCA Port 1 JK BMS 4G-GPS:mirca.p1.online.last()}=1</expression>
                            <name>Port 1: temperature T{#SNMPINDEX} is high (&gt;{$MIRCA.TEMP.MAX:"p1"}°C)</name>
                            <priority>AVERAGE</priority>
                        </trigger_prototype>
                        <trigger_prototype>
                            <expression>{MiRCA Port 1 JK BMS 4G-GPS:mirca.p1.temp[{#SNMPINDEX}].max(5m)}&lt;{$MIRCA.TEMP.MIN:"p1"} and {MiRCA Port 1 JK BMS 4G-GPS:mirca.p1.online.last()}=1</expression>
                            <name>Port 1: temperature T{#SNMPINDEX} is low (&lt;{$MIRCA.TEMP.MIN:"p1"}°C)</name>
                            <priority>WARNING</priority>
                        </trigger_prototype>
                    </trigger_prototypes>
                </discovery_rule>
            </discovery_rules>
            <macros>
                <macro>
                    <macro>{$MIRCA.INTERVAL}</macro>
                    <value>30s</value>
                    <description>Polling interval of live values</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.INTERVAL.SLOW}</macro>
                    <value>5m</value>
                    <description>Polling interval of slowly changing values (capacity, cycles, energy counters)</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.OFFLINE.TIME}</macro>
                    <value>5m</value>
                    <description>How long the device may stay silent before a problem is raised</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.SOC.WARN}</macro>
                    <value>20</value>
                    <description>SOC below this, %, raises a warning. Per port: {$MIRCA.SOC.WARN:"p1"}</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.SOC.CRIT}</macro>
                    <value>10</value>
                    <description>SOC below this, %, raises a high problem. Per port: {$MIRCA.SOC.CRIT:"p1"}</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.CELL.UV}</macro>
                    <value>2.9</value>
                    <description>Cell undervoltage threshold, V (LiFePO4 default). Per port: {$MIRCA.CELL.UV:"p1"}</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.CELL.OV}</macro>
                    <value>3.65</value>
                    <description>Cell overvoltage threshold, V (LiFePO4 default). Per port: {$MIRCA.CELL.OV:"p1"}</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.TEMP.MAX}</macro>
                    <value>50</value>
                    <description>Battery temperature sensor high threshold, °C. Per port: {$MIRCA.TEMP.MAX:"p1"}</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.TEMP.MIN}</macro>
                    <value>0</value>
                    <description>Battery temperature sensor low threshold, °C. Per port: {$MIRCA.TEMP.MIN:"p1"}</description>
                </macro>
            </macros>
        </template>
        <template>
            <template>MiRCA Port 2 JK BMS 4G-GPS</template>
            <name>MiRCA Port 2 JK BMS 4G-GPS</name>
            <description>MiRCA serial port 2 running the 'JK BMS 4G-GPS' protocol (protocol id 2). SNMP v2c over the Ethernet interface, tree .1.3.6.1.4.1.2021.13.16.4.2.2 (doc/ports.md). Link 'MiRCA Device' too. JK BMS over the 4G-GPS protocol (000).</description>
            <groups>
                <group>
                    <name>Templates/MiRCA</name>
                </group>
            </groups>
            <applications>
                <application>
                    <name>Port 2</name>
                </application>
                <application>
                    <name>Battery</name>
                </application>
                <application>
                    <name>Cells</name>
                </application>
                <application>
                    <name>Temperature</name>
                </application>
            </applications>
            <items>
                <item>
                    <name>Port 2: protocol</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.1</snmp_oid>
                    <key>mirca.p2.protocol</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>UNSIGNED</value_type>
                    <description>Protocol configured on the port</description>
                    <applications>
                        <application>
                            <name>Port 2</name>
                        </application>
                    </applications>
                    <valuemap>
                        <name>MiRCA protocol</name>
                    </valuemap>
                </item>
                <item>
                    <name>Port 2: online</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.2</snmp_oid>
                    <key>mirca.p2.online</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>UNSIGNED</value_type>
                    <description>1 while the device answers. All values read 0 while it is offline.</description>
                    <applications>
                        <application>
                            <name>Port 2</name>
                        </application>
                    </applications>
                    <valuemap>
                        <name>MiRCA online</name>
                    </valuemap>
                </item>
                <item>
                    <name>Port 2: seconds since last reply</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.3</snmp_oid>
                    <key>mirca.p2.age</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>s</units>
                    <description>-1: no reply since boot</description>
                    <applications>
                        <application>
                            <name>Port 2</name>
                        </application>
                    </applications>
                </item>
                <item>
                    <name>Port 2: voltage</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.10</snmp_oid>
                    <key>mirca.p2.voltage</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>V</units>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.01</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 2: current</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.11</snmp_oid>
                    <key>mirca.p2.current</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>A</units>
                    <description>+ charging, - discharging</description>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.01</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 2: SOC</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.13</snmp_oid>
                    <key>mirca.p2.soc</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>%</units>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.1</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 2: cycles</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.14</snmp_oid>
                    <key>mirca.p2.cycles</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>UNSIGNED</value_type>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                </item>
                <item>
                    <name>Port 2: cell count</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.17</snmp_oid>
                    <key>mirca.p2.cell_count</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>UNSIGNED</value_type>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                </item>
                <item>
                    <name>Port 2: power (calculated)</name>
                    <type>CALCULATED</type>
                    <key>mirca.p2.power.calc</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>W</units>
                    <params>last(mirca.p2.voltage)*last(mirca.p2.current)</params>
                    <description>Voltage x current; the protocol does not report power. + charging</description>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                </item>
            </items>
            <discovery_rules>
                <discovery_rule>
                    <name>Port 2: cells discovery</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>discovery[{#SNMPVALUE},1.3.6.1.4.1.2021.13.16.4.2.2.20]</snmp_oid>
                    <key>mirca.p2.cells.discovery</key>
                    <delay>1h</delay>
                    <filter>
                        <evaltype>AND</evaltype>
                        <conditions>
                            <condition>
                                <macro>{#SNMPVALUE}</macro>
                                <value>^[1-9]</value>
                                <formulaid>A</formulaid>
                            </condition>
                        </conditions>
                    </filter>
                    <lifetime>7d</lifetime>
                    <description>Cells the BMS reports (cell voltage &gt; 0 at discovery time)</description>
                    <item_prototypes>
                        <item_prototype>
                            <name>Port 2: cell {#SNMPINDEX} voltage</name>
                            <type>SNMP_AGENT</type>
                            <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.20.{#SNMPINDEX}</snmp_oid>
                            <key>mirca.p2.cell[{#SNMPINDEX}]</key>
                            <delay>{$MIRCA.INTERVAL}</delay>
                            <history>14d</history>
                            <trends>365d</trends>
                            <value_type>FLOAT</value_type>
                            <units>V</units>
                            <applications>
                                <application>
                                    <name>Cells</name>
                                </application>
                            </applications>
                            <preprocessing>
                                <step>
                                    <type>MULTIPLIER</type>
                                    <parameters>
                                        <parameter>0.001</parameter>
                                    </parameters>
                                </step>
                            </preprocessing>
                        </item_prototype>
                    </item_prototypes>
                    <trigger_prototypes>
                        <trigger_prototype>
                            <expression>{MiRCA Port 2 JK BMS 4G-GPS:mirca.p2.cell[{#SNMPINDEX}].max(2m)}&lt;{$MIRCA.CELL.UV:"p2"} and {MiRCA Port 2 JK BMS 4G-GPS:mirca.p2.online.last()}=1</expression>
                            <name>Port 2: cell {#SNMPINDEX} undervoltage (&lt;{$MIRCA.CELL.UV:"p2"}V)</name>
                            <priority>HIGH</priority>
                        </trigger_prototype>
                        <trigger_prototype>
                            <expression>{MiRCA Port 2 JK BMS 4G-GPS:mirca.p2.cell[{#SNMPINDEX}].min(2m)}&gt;{$MIRCA.CELL.OV:"p2"} and {MiRCA Port 2 JK BMS 4G-GPS:mirca.p2.online.last()}=1</expression>
                            <name>Port 2: cell {#SNMPINDEX} overvoltage (&gt;{$MIRCA.CELL.OV:"p2"}V)</name>
                            <priority>HIGH</priority>
                        </trigger_prototype>
                    </trigger_prototypes>
                </discovery_rule>
                <discovery_rule>
                    <name>Port 2: temperature sensors discovery</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>discovery[{#SNMPVALUE},1.3.6.1.4.1.2021.13.16.4.2.2.21]</snmp_oid>
                    <key>mirca.p2.temps.discovery</key>
                    <delay>1h</delay>
                    <filter>
                        <evaltype>AND</evaltype>
                        <conditions>
                            <condition>
                                <macro>{#SNMPVALUE}</macro>
                                <value>^-?[1-9]</value>
                                <formulaid>A</formulaid>
                            </condition>
                        </conditions>
                    </filter>
                    <lifetime>7d</lifetime>
                    <description>Temperature sensors the BMS reports (non-zero at discovery time)</description>
                    <item_prototypes>
                        <item_prototype>
                            <name>Port 2: temperature T{#SNMPINDEX}</name>
                            <type>SNMP_AGENT</type>
                            <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.21.{#SNMPINDEX}</snmp_oid>
                            <key>mirca.p2.temp[{#SNMPINDEX}]</key>
                            <delay>{$MIRCA.INTERVAL}</delay>
                            <history>14d</history>
                            <trends>365d</trends>
                            <value_type>FLOAT</value_type>
                            <units>°C</units>
                            <applications>
                                <application>
                                    <name>Temperature</name>
                                </application>
                            </applications>
                            <preprocessing>
                                <step>
                                    <type>MULTIPLIER</type>
                                    <parameters>
                                        <parameter>0.1</parameter>
                                    </parameters>
                                </step>
                            </preprocessing>
                        </item_prototype>
                    </item_prototypes>
                    <trigger_prototypes>
                        <trigger_prototype>
                            <expression>{MiRCA Port 2 JK BMS 4G-GPS:mirca.p2.temp[{#SNMPINDEX}].min(5m)}&gt;{$MIRCA.TEMP.MAX:"p2"} and {MiRCA Port 2 JK BMS 4G-GPS:mirca.p2.online.last()}=1</expression>
                            <name>Port 2: temperature T{#SNMPINDEX} is high (&gt;{$MIRCA.TEMP.MAX:"p2"}°C)</name>
                            <priority>AVERAGE</priority>
                        </trigger_prototype>
                        <trigger_prototype>
                            <expression>{MiRCA Port 2 JK BMS 4G-GPS:mirca.p2.temp[{#SNMPINDEX}].max(5m)}&lt;{$MIRCA.TEMP.MIN:"p2"} and {MiRCA Port 2 JK BMS 4G-GPS:mirca.p2.online.last()}=1</expression>
                            <name>Port 2: temperature T{#SNMPINDEX} is low (&lt;{$MIRCA.TEMP.MIN:"p2"}°C)</name>
                            <priority>WARNING</priority>
                        </trigger_prototype>
                    </trigger_prototypes>
                </discovery_rule>
            </discovery_rules>
            <macros>
                <macro>
                    <macro>{$MIRCA.INTERVAL}</macro>
                    <value>30s</value>
                    <description>Polling interval of live values</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.INTERVAL.SLOW}</macro>
                    <value>5m</value>
                    <description>Polling interval of slowly changing values (capacity, cycles, energy counters)</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.OFFLINE.TIME}</macro>
                    <value>5m</value>
                    <description>How long the device may stay silent before a problem is raised</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.SOC.WARN}</macro>
                    <value>20</value>
                    <description>SOC below this, %, raises a warning. Per port: {$MIRCA.SOC.WARN:"p1"}</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.SOC.CRIT}</macro>
                    <value>10</value>
                    <description>SOC below this, %, raises a high problem. Per port: {$MIRCA.SOC.CRIT:"p1"}</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.CELL.UV}</macro>
                    <value>2.9</value>
                    <description>Cell undervoltage threshold, V (LiFePO4 default). Per port: {$MIRCA.CELL.UV:"p1"}</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.CELL.OV}</macro>
                    <value>3.65</value>
                    <description>Cell overvoltage threshold, V (LiFePO4 default). Per port: {$MIRCA.CELL.OV:"p1"}</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.TEMP.MAX}</macro>
                    <value>50</value>
                    <description>Battery temperature sensor high threshold, °C. Per port: {$MIRCA.TEMP.MAX:"p1"}</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.TEMP.MIN}</macro>
                    <value>0</value>
                    <description>Battery temperature sensor low threshold, °C. Per port: {$MIRCA.TEMP.MIN:"p1"}</description>
                </macro>
            </macros>
        </template>
        <template>
            <template>MiRCA Port 1 JBD BMS</template>
            <name>MiRCA Port 1 JBD BMS</name>
            <description>MiRCA serial port 1 running the 'JBD BMS' protocol (protocol id 4). SNMP v2c over the Ethernet interface, tree .1.3.6.1.4.1.2021.13.16.4.2.1 (doc/ports.md). Link 'MiRCA Device' too. JBD / Xiaoxiang BMS over UART.</description>
            <groups>
                <group>
                    <name>Templates/MiRCA</name>
                </group>
            </groups>
            <applications>
                <application>
                    <name>Port 1</name>
                </application>
                <application>
                    <name>Battery</name>
                </application>
                <application>
                    <name>Cells</name>
                </application>
                <application>
                    <name>Temperature</name>
                </application>
            </applications>
            <items>
                <item>
                    <name>Port 1: protocol</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.1</snmp_oid>
                    <key>mirca.p1.protocol</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>UNSIGNED</value_type>
                    <description>Protocol configured on the port</description>
                    <applications>
                        <application>
                            <name>Port 1</name>
                        </application>
                    </applications>
                    <valuemap>
                        <name>MiRCA protocol</name>
                    </valuemap>
                </item>
                <item>
                    <name>Port 1: online</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.2</snmp_oid>
                    <key>mirca.p1.online</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>UNSIGNED</value_type>
                    <description>1 while the device answers. All values read 0 while it is offline.</description>
                    <applications>
                        <application>
                            <name>Port 1</name>
                        </application>
                    </applications>
                    <valuemap>
                        <name>MiRCA online</name>
                    </valuemap>
                </item>
                <item>
                    <name>Port 1: seconds since last reply</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.3</snmp_oid>
                    <key>mirca.p1.age</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>s</units>
                    <description>-1: no reply since boot</description>
                    <applications>
                        <application>
                            <name>Port 1</name>
                        </application>
                    </applications>
                </item>
                <item>
                    <name>Port 1: voltage</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.10</snmp_oid>
                    <key>mirca.p1.voltage</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>V</units>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.01</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 1: current</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.11</snmp_oid>
                    <key>mirca.p1.current</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>A</units>
                    <description>+ charging, - discharging</description>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.01</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 1: SOC</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.13</snmp_oid>
                    <key>mirca.p1.soc</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>%</units>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.1</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 1: cycles</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.14</snmp_oid>
                    <key>mirca.p1.cycles</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>UNSIGNED</value_type>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                </item>
                <item>
                    <name>Port 1: remaining capacity</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.15</snmp_oid>
                    <key>mirca.p1.cap_remain</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>Ah</units>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.01</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 1: full capacity</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.16</snmp_oid>
                    <key>mirca.p1.cap_full</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>Ah</units>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.01</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 1: cell count</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.17</snmp_oid>
                    <key>mirca.p1.cell_count</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>UNSIGNED</value_type>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                </item>
                <item>
                    <name>Port 1: power (calculated)</name>
                    <type>CALCULATED</type>
                    <key>mirca.p1.power.calc</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>W</units>
                    <params>last(mirca.p1.voltage)*last(mirca.p1.current)</params>
                    <description>Voltage x current; the protocol does not report power. + charging</description>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                </item>
            </items>
            <discovery_rules>
                <discovery_rule>
                    <name>Port 1: cells discovery</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>discovery[{#SNMPVALUE},1.3.6.1.4.1.2021.13.16.4.2.1.20]</snmp_oid>
                    <key>mirca.p1.cells.discovery</key>
                    <delay>1h</delay>
                    <filter>
                        <evaltype>AND</evaltype>
                        <conditions>
                            <condition>
                                <macro>{#SNMPVALUE}</macro>
                                <value>^[1-9]</value>
                                <formulaid>A</formulaid>
                            </condition>
                        </conditions>
                    </filter>
                    <lifetime>7d</lifetime>
                    <description>Cells the BMS reports (cell voltage &gt; 0 at discovery time)</description>
                    <item_prototypes>
                        <item_prototype>
                            <name>Port 1: cell {#SNMPINDEX} voltage</name>
                            <type>SNMP_AGENT</type>
                            <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.20.{#SNMPINDEX}</snmp_oid>
                            <key>mirca.p1.cell[{#SNMPINDEX}]</key>
                            <delay>{$MIRCA.INTERVAL}</delay>
                            <history>14d</history>
                            <trends>365d</trends>
                            <value_type>FLOAT</value_type>
                            <units>V</units>
                            <applications>
                                <application>
                                    <name>Cells</name>
                                </application>
                            </applications>
                            <preprocessing>
                                <step>
                                    <type>MULTIPLIER</type>
                                    <parameters>
                                        <parameter>0.001</parameter>
                                    </parameters>
                                </step>
                            </preprocessing>
                        </item_prototype>
                    </item_prototypes>
                    <trigger_prototypes>
                        <trigger_prototype>
                            <expression>{MiRCA Port 1 JBD BMS:mirca.p1.cell[{#SNMPINDEX}].max(2m)}&lt;{$MIRCA.CELL.UV:"p1"} and {MiRCA Port 1 JBD BMS:mirca.p1.online.last()}=1</expression>
                            <name>Port 1: cell {#SNMPINDEX} undervoltage (&lt;{$MIRCA.CELL.UV:"p1"}V)</name>
                            <priority>HIGH</priority>
                        </trigger_prototype>
                        <trigger_prototype>
                            <expression>{MiRCA Port 1 JBD BMS:mirca.p1.cell[{#SNMPINDEX}].min(2m)}&gt;{$MIRCA.CELL.OV:"p1"} and {MiRCA Port 1 JBD BMS:mirca.p1.online.last()}=1</expression>
                            <name>Port 1: cell {#SNMPINDEX} overvoltage (&gt;{$MIRCA.CELL.OV:"p1"}V)</name>
                            <priority>HIGH</priority>
                        </trigger_prototype>
                    </trigger_prototypes>
                </discovery_rule>
                <discovery_rule>
                    <name>Port 1: temperature sensors discovery</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>discovery[{#SNMPVALUE},1.3.6.1.4.1.2021.13.16.4.2.1.21]</snmp_oid>
                    <key>mirca.p1.temps.discovery</key>
                    <delay>1h</delay>
                    <filter>
                        <evaltype>AND</evaltype>
                        <conditions>
                            <condition>
                                <macro>{#SNMPVALUE}</macro>
                                <value>^-?[1-9]</value>
                                <formulaid>A</formulaid>
                            </condition>
                        </conditions>
                    </filter>
                    <lifetime>7d</lifetime>
                    <description>Temperature sensors the BMS reports (non-zero at discovery time)</description>
                    <item_prototypes>
                        <item_prototype>
                            <name>Port 1: temperature T{#SNMPINDEX}</name>
                            <type>SNMP_AGENT</type>
                            <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.21.{#SNMPINDEX}</snmp_oid>
                            <key>mirca.p1.temp[{#SNMPINDEX}]</key>
                            <delay>{$MIRCA.INTERVAL}</delay>
                            <history>14d</history>
                            <trends>365d</trends>
                            <value_type>FLOAT</value_type>
                            <units>°C</units>
                            <applications>
                                <application>
                                    <name>Temperature</name>
                                </application>
                            </applications>
                            <preprocessing>
                                <step>
                                    <type>MULTIPLIER</type>
                                    <parameters>
                                        <parameter>0.1</parameter>
                                    </parameters>
                                </step>
                            </preprocessing>
                        </item_prototype>
                    </item_prototypes>
                    <trigger_prototypes>
                        <trigger_prototype>
                            <expression>{MiRCA Port 1 JBD BMS:mirca.p1.temp[{#SNMPINDEX}].min(5m)}&gt;{$MIRCA.TEMP.MAX:"p1"} and {MiRCA Port 1 JBD BMS:mirca.p1.online.last()}=1</expression>
                            <name>Port 1: temperature T{#SNMPINDEX} is high (&gt;{$MIRCA.TEMP.MAX:"p1"}°C)</name>
                            <priority>AVERAGE</priority>
                        </trigger_prototype>
                        <trigger_prototype>
                            <expression>{MiRCA Port 1 JBD BMS:mirca.p1.temp[{#SNMPINDEX}].max(5m)}&lt;{$MIRCA.TEMP.MIN:"p1"} and {MiRCA Port 1 JBD BMS:mirca.p1.online.last()}=1</expression>
                            <name>Port 1: temperature T{#SNMPINDEX} is low (&lt;{$MIRCA.TEMP.MIN:"p1"}°C)</name>
                            <priority>WARNING</priority>
                        </trigger_prototype>
                    </trigger_prototypes>
                </discovery_rule>
            </discovery_rules>
            <macros>
                <macro>
                    <macro>{$MIRCA.INTERVAL}</macro>
                    <value>30s</value>
                    <description>Polling interval of live values</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.INTERVAL.SLOW}</macro>
                    <value>5m</value>
                    <description>Polling interval of slowly changing values (capacity, cycles, energy counters)</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.OFFLINE.TIME}</macro>
                    <value>5m</value>
                    <description>How long the device may stay silent before a problem is raised</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.SOC.WARN}</macro>
                    <value>20</value>
                    <description>SOC below this, %, raises a warning. Per port: {$MIRCA.SOC.WARN:"p1"}</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.SOC.CRIT}</macro>
                    <value>10</value>
                    <description>SOC below this, %, raises a high problem. Per port: {$MIRCA.SOC.CRIT:"p1"}</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.CELL.UV}</macro>
                    <value>2.9</value>
                    <description>Cell undervoltage threshold, V (LiFePO4 default). Per port: {$MIRCA.CELL.UV:"p1"}</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.CELL.OV}</macro>
                    <value>3.65</value>
                    <description>Cell overvoltage threshold, V (LiFePO4 default). Per port: {$MIRCA.CELL.OV:"p1"}</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.TEMP.MAX}</macro>
                    <value>50</value>
                    <description>Battery temperature sensor high threshold, °C. Per port: {$MIRCA.TEMP.MAX:"p1"}</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.TEMP.MIN}</macro>
                    <value>0</value>
                    <description>Battery temperature sensor low threshold, °C. Per port: {$MIRCA.TEMP.MIN:"p1"}</description>
                </macro>
            </macros>
        </template>
        <template>
            <template>MiRCA Port 2 JBD BMS</template>
            <name>MiRCA Port 2 JBD BMS</name>
            <description>MiRCA serial port 2 running the 'JBD BMS' protocol (protocol id 4). SNMP v2c over the Ethernet interface, tree .1.3.6.1.4.1.2021.13.16.4.2.2 (doc/ports.md). Link 'MiRCA Device' too. JBD / Xiaoxiang BMS over UART.</description>
            <groups>
                <group>
                    <name>Templates/MiRCA</name>
                </group>
            </groups>
            <applications>
                <application>
                    <name>Port 2</name>
                </application>
                <application>
                    <name>Battery</name>
                </application>
                <application>
                    <name>Cells</name>
                </application>
                <application>
                    <name>Temperature</name>
                </application>
            </applications>
            <items>
                <item>
                    <name>Port 2: protocol</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.1</snmp_oid>
                    <key>mirca.p2.protocol</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>UNSIGNED</value_type>
                    <description>Protocol configured on the port</description>
                    <applications>
                        <application>
                            <name>Port 2</name>
                        </application>
                    </applications>
                    <valuemap>
                        <name>MiRCA protocol</name>
                    </valuemap>
                </item>
                <item>
                    <name>Port 2: online</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.2</snmp_oid>
                    <key>mirca.p2.online</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>UNSIGNED</value_type>
                    <description>1 while the device answers. All values read 0 while it is offline.</description>
                    <applications>
                        <application>
                            <name>Port 2</name>
                        </application>
                    </applications>
                    <valuemap>
                        <name>MiRCA online</name>
                    </valuemap>
                </item>
                <item>
                    <name>Port 2: seconds since last reply</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.3</snmp_oid>
                    <key>mirca.p2.age</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>s</units>
                    <description>-1: no reply since boot</description>
                    <applications>
                        <application>
                            <name>Port 2</name>
                        </application>
                    </applications>
                </item>
                <item>
                    <name>Port 2: voltage</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.10</snmp_oid>
                    <key>mirca.p2.voltage</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>V</units>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.01</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 2: current</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.11</snmp_oid>
                    <key>mirca.p2.current</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>A</units>
                    <description>+ charging, - discharging</description>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.01</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 2: SOC</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.13</snmp_oid>
                    <key>mirca.p2.soc</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>%</units>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.1</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 2: cycles</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.14</snmp_oid>
                    <key>mirca.p2.cycles</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>UNSIGNED</value_type>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                </item>
                <item>
                    <name>Port 2: remaining capacity</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.15</snmp_oid>
                    <key>mirca.p2.cap_remain</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>Ah</units>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.01</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 2: full capacity</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.16</snmp_oid>
                    <key>mirca.p2.cap_full</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>Ah</units>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.01</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 2: cell count</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.17</snmp_oid>
                    <key>mirca.p2.cell_count</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>UNSIGNED</value_type>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                </item>
                <item>
                    <name>Port 2: power (calculated)</name>
                    <type>CALCULATED</type>
                    <key>mirca.p2.power.calc</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>W</units>
                    <params>last(mirca.p2.voltage)*last(mirca.p2.current)</params>
                    <description>Voltage x current; the protocol does not report power. + charging</description>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                </item>
            </items>
            <discovery_rules>
                <discovery_rule>
                    <name>Port 2: cells discovery</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>discovery[{#SNMPVALUE},1.3.6.1.4.1.2021.13.16.4.2.2.20]</snmp_oid>
                    <key>mirca.p2.cells.discovery</key>
                    <delay>1h</delay>
                    <filter>
                        <evaltype>AND</evaltype>
                        <conditions>
                            <condition>
                                <macro>{#SNMPVALUE}</macro>
                                <value>^[1-9]</value>
                                <formulaid>A</formulaid>
                            </condition>
                        </conditions>
                    </filter>
                    <lifetime>7d</lifetime>
                    <description>Cells the BMS reports (cell voltage &gt; 0 at discovery time)</description>
                    <item_prototypes>
                        <item_prototype>
                            <name>Port 2: cell {#SNMPINDEX} voltage</name>
                            <type>SNMP_AGENT</type>
                            <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.20.{#SNMPINDEX}</snmp_oid>
                            <key>mirca.p2.cell[{#SNMPINDEX}]</key>
                            <delay>{$MIRCA.INTERVAL}</delay>
                            <history>14d</history>
                            <trends>365d</trends>
                            <value_type>FLOAT</value_type>
                            <units>V</units>
                            <applications>
                                <application>
                                    <name>Cells</name>
                                </application>
                            </applications>
                            <preprocessing>
                                <step>
                                    <type>MULTIPLIER</type>
                                    <parameters>
                                        <parameter>0.001</parameter>
                                    </parameters>
                                </step>
                            </preprocessing>
                        </item_prototype>
                    </item_prototypes>
                    <trigger_prototypes>
                        <trigger_prototype>
                            <expression>{MiRCA Port 2 JBD BMS:mirca.p2.cell[{#SNMPINDEX}].max(2m)}&lt;{$MIRCA.CELL.UV:"p2"} and {MiRCA Port 2 JBD BMS:mirca.p2.online.last()}=1</expression>
                            <name>Port 2: cell {#SNMPINDEX} undervoltage (&lt;{$MIRCA.CELL.UV:"p2"}V)</name>
                            <priority>HIGH</priority>
                        </trigger_prototype>
                        <trigger_prototype>
                            <expression>{MiRCA Port 2 JBD BMS:mirca.p2.cell[{#SNMPINDEX}].min(2m)}&gt;{$MIRCA.CELL.OV:"p2"} and {MiRCA Port 2 JBD BMS:mirca.p2.online.last()}=1</expression>
                            <name>Port 2: cell {#SNMPINDEX} overvoltage (&gt;{$MIRCA.CELL.OV:"p2"}V)</name>
                            <priority>HIGH</priority>
                        </trigger_prototype>
                    </trigger_prototypes>
                </discovery_rule>
                <discovery_rule>
                    <name>Port 2: temperature sensors discovery</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>discovery[{#SNMPVALUE},1.3.6.1.4.1.2021.13.16.4.2.2.21]</snmp_oid>
                    <key>mirca.p2.temps.discovery</key>
                    <delay>1h</delay>
                    <filter>
                        <evaltype>AND</evaltype>
                        <conditions>
                            <condition>
                                <macro>{#SNMPVALUE}</macro>
                                <value>^-?[1-9]</value>
                                <formulaid>A</formulaid>
                            </condition>
                        </conditions>
                    </filter>
                    <lifetime>7d</lifetime>
                    <description>Temperature sensors the BMS reports (non-zero at discovery time)</description>
                    <item_prototypes>
                        <item_prototype>
                            <name>Port 2: temperature T{#SNMPINDEX}</name>
                            <type>SNMP_AGENT</type>
                            <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.21.{#SNMPINDEX}</snmp_oid>
                            <key>mirca.p2.temp[{#SNMPINDEX}]</key>
                            <delay>{$MIRCA.INTERVAL}</delay>
                            <history>14d</history>
                            <trends>365d</trends>
                            <value_type>FLOAT</value_type>
                            <units>°C</units>
                            <applications>
                                <application>
                                    <name>Temperature</name>
                                </application>
                            </applications>
                            <preprocessing>
                                <step>
                                    <type>MULTIPLIER</type>
                                    <parameters>
                                        <parameter>0.1</parameter>
                                    </parameters>
                                </step>
                            </preprocessing>
                        </item_prototype>
                    </item_prototypes>
                    <trigger_prototypes>
                        <trigger_prototype>
                            <expression>{MiRCA Port 2 JBD BMS:mirca.p2.temp[{#SNMPINDEX}].min(5m)}&gt;{$MIRCA.TEMP.MAX:"p2"} and {MiRCA Port 2 JBD BMS:mirca.p2.online.last()}=1</expression>
                            <name>Port 2: temperature T{#SNMPINDEX} is high (&gt;{$MIRCA.TEMP.MAX:"p2"}°C)</name>
                            <priority>AVERAGE</priority>
                        </trigger_prototype>
                        <trigger_prototype>
                            <expression>{MiRCA Port 2 JBD BMS:mirca.p2.temp[{#SNMPINDEX}].max(5m)}&lt;{$MIRCA.TEMP.MIN:"p2"} and {MiRCA Port 2 JBD BMS:mirca.p2.online.last()}=1</expression>
                            <name>Port 2: temperature T{#SNMPINDEX} is low (&lt;{$MIRCA.TEMP.MIN:"p2"}°C)</name>
                            <priority>WARNING</priority>
                        </trigger_prototype>
                    </trigger_prototypes>
                </discovery_rule>
            </discovery_rules>
            <macros>
                <macro>
                    <macro>{$MIRCA.INTERVAL}</macro>
                    <value>30s</value>
                    <description>Polling interval of live values</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.INTERVAL.SLOW}</macro>
                    <value>5m</value>
                    <description>Polling interval of slowly changing values (capacity, cycles, energy counters)</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.OFFLINE.TIME}</macro>
                    <value>5m</value>
                    <description>How long the device may stay silent before a problem is raised</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.SOC.WARN}</macro>
                    <value>20</value>
                    <description>SOC below this, %, raises a warning. Per port: {$MIRCA.SOC.WARN:"p1"}</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.SOC.CRIT}</macro>
                    <value>10</value>
                    <description>SOC below this, %, raises a high problem. Per port: {$MIRCA.SOC.CRIT:"p1"}</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.CELL.UV}</macro>
                    <value>2.9</value>
                    <description>Cell undervoltage threshold, V (LiFePO4 default). Per port: {$MIRCA.CELL.UV:"p1"}</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.CELL.OV}</macro>
                    <value>3.65</value>
                    <description>Cell overvoltage threshold, V (LiFePO4 default). Per port: {$MIRCA.CELL.OV:"p1"}</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.TEMP.MAX}</macro>
                    <value>50</value>
                    <description>Battery temperature sensor high threshold, °C. Per port: {$MIRCA.TEMP.MAX:"p1"}</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.TEMP.MIN}</macro>
                    <value>0</value>
                    <description>Battery temperature sensor low threshold, °C. Per port: {$MIRCA.TEMP.MIN:"p1"}</description>
                </macro>
            </macros>
        </template>
        <template>
            <template>MiRCA Port 1 PACE BMS</template>
            <name>MiRCA Port 1 PACE BMS</name>
            <description>MiRCA serial port 1 running the 'PACE BMS' protocol (protocol id 3). SNMP v2c over the Ethernet interface, tree .1.3.6.1.4.1.2021.13.16.4.2.1 (doc/ports.md). Link 'MiRCA Device' too. PACE BMS (Pylontech family ASCII protocol).</description>
            <groups>
                <group>
                    <name>Templates/MiRCA</name>
                </group>
            </groups>
            <applications>
                <application>
                    <name>Port 1</name>
                </application>
                <application>
                    <name>Battery</name>
                </application>
                <application>
                    <name>Cells</name>
                </application>
                <application>
                    <name>Temperature</name>
                </application>
            </applications>
            <items>
                <item>
                    <name>Port 1: protocol</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.1</snmp_oid>
                    <key>mirca.p1.protocol</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>UNSIGNED</value_type>
                    <description>Protocol configured on the port</description>
                    <applications>
                        <application>
                            <name>Port 1</name>
                        </application>
                    </applications>
                    <valuemap>
                        <name>MiRCA protocol</name>
                    </valuemap>
                </item>
                <item>
                    <name>Port 1: online</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.2</snmp_oid>
                    <key>mirca.p1.online</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>UNSIGNED</value_type>
                    <description>1 while the device answers. All values read 0 while it is offline.</description>
                    <applications>
                        <application>
                            <name>Port 1</name>
                        </application>
                    </applications>
                    <valuemap>
                        <name>MiRCA online</name>
                    </valuemap>
                </item>
                <item>
                    <name>Port 1: seconds since last reply</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.3</snmp_oid>
                    <key>mirca.p1.age</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>s</units>
                    <description>-1: no reply since boot</description>
                    <applications>
                        <application>
                            <name>Port 1</name>
                        </application>
                    </applications>
                </item>
                <item>
                    <name>Port 1: voltage</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.10</snmp_oid>
                    <key>mirca.p1.voltage</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>V</units>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.01</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 1: current</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.11</snmp_oid>
                    <key>mirca.p1.current</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>A</units>
                    <description>+ charging, - discharging</description>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.01</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 1: SOC</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.13</snmp_oid>
                    <key>mirca.p1.soc</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>%</units>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.1</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 1: cycles</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.14</snmp_oid>
                    <key>mirca.p1.cycles</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>UNSIGNED</value_type>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                </item>
                <item>
                    <name>Port 1: remaining capacity</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.15</snmp_oid>
                    <key>mirca.p1.cap_remain</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>Ah</units>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.01</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 1: full capacity</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.16</snmp_oid>
                    <key>mirca.p1.cap_full</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>Ah</units>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.01</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 1: cell count</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.17</snmp_oid>
                    <key>mirca.p1.cell_count</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>UNSIGNED</value_type>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                </item>
                <item>
                    <name>Port 1: power (calculated)</name>
                    <type>CALCULATED</type>
                    <key>mirca.p1.power.calc</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>W</units>
                    <params>last(mirca.p1.voltage)*last(mirca.p1.current)</params>
                    <description>Voltage x current; the protocol does not report power. + charging</description>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                </item>
            </items>
            <discovery_rules>
                <discovery_rule>
                    <name>Port 1: cells discovery</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>discovery[{#SNMPVALUE},1.3.6.1.4.1.2021.13.16.4.2.1.20]</snmp_oid>
                    <key>mirca.p1.cells.discovery</key>
                    <delay>1h</delay>
                    <filter>
                        <evaltype>AND</evaltype>
                        <conditions>
                            <condition>
                                <macro>{#SNMPVALUE}</macro>
                                <value>^[1-9]</value>
                                <formulaid>A</formulaid>
                            </condition>
                        </conditions>
                    </filter>
                    <lifetime>7d</lifetime>
                    <description>Cells the BMS reports (cell voltage &gt; 0 at discovery time)</description>
                    <item_prototypes>
                        <item_prototype>
                            <name>Port 1: cell {#SNMPINDEX} voltage</name>
                            <type>SNMP_AGENT</type>
                            <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.20.{#SNMPINDEX}</snmp_oid>
                            <key>mirca.p1.cell[{#SNMPINDEX}]</key>
                            <delay>{$MIRCA.INTERVAL}</delay>
                            <history>14d</history>
                            <trends>365d</trends>
                            <value_type>FLOAT</value_type>
                            <units>V</units>
                            <applications>
                                <application>
                                    <name>Cells</name>
                                </application>
                            </applications>
                            <preprocessing>
                                <step>
                                    <type>MULTIPLIER</type>
                                    <parameters>
                                        <parameter>0.001</parameter>
                                    </parameters>
                                </step>
                            </preprocessing>
                        </item_prototype>
                    </item_prototypes>
                    <trigger_prototypes>
                        <trigger_prototype>
                            <expression>{MiRCA Port 1 PACE BMS:mirca.p1.cell[{#SNMPINDEX}].max(2m)}&lt;{$MIRCA.CELL.UV:"p1"} and {MiRCA Port 1 PACE BMS:mirca.p1.online.last()}=1</expression>
                            <name>Port 1: cell {#SNMPINDEX} undervoltage (&lt;{$MIRCA.CELL.UV:"p1"}V)</name>
                            <priority>HIGH</priority>
                        </trigger_prototype>
                        <trigger_prototype>
                            <expression>{MiRCA Port 1 PACE BMS:mirca.p1.cell[{#SNMPINDEX}].min(2m)}&gt;{$MIRCA.CELL.OV:"p1"} and {MiRCA Port 1 PACE BMS:mirca.p1.online.last()}=1</expression>
                            <name>Port 1: cell {#SNMPINDEX} overvoltage (&gt;{$MIRCA.CELL.OV:"p1"}V)</name>
                            <priority>HIGH</priority>
                        </trigger_prototype>
                    </trigger_prototypes>
                </discovery_rule>
                <discovery_rule>
                    <name>Port 1: temperature sensors discovery</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>discovery[{#SNMPVALUE},1.3.6.1.4.1.2021.13.16.4.2.1.21]</snmp_oid>
                    <key>mirca.p1.temps.discovery</key>
                    <delay>1h</delay>
                    <filter>
                        <evaltype>AND</evaltype>
                        <conditions>
                            <condition>
                                <macro>{#SNMPVALUE}</macro>
                                <value>^-?[1-9]</value>
                                <formulaid>A</formulaid>
                            </condition>
                        </conditions>
                    </filter>
                    <lifetime>7d</lifetime>
                    <description>Temperature sensors the BMS reports (non-zero at discovery time)</description>
                    <item_prototypes>
                        <item_prototype>
                            <name>Port 1: temperature T{#SNMPINDEX}</name>
                            <type>SNMP_AGENT</type>
                            <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.21.{#SNMPINDEX}</snmp_oid>
                            <key>mirca.p1.temp[{#SNMPINDEX}]</key>
                            <delay>{$MIRCA.INTERVAL}</delay>
                            <history>14d</history>
                            <trends>365d</trends>
                            <value_type>FLOAT</value_type>
                            <units>°C</units>
                            <applications>
                                <application>
                                    <name>Temperature</name>
                                </application>
                            </applications>
                            <preprocessing>
                                <step>
                                    <type>MULTIPLIER</type>
                                    <parameters>
                                        <parameter>0.1</parameter>
                                    </parameters>
                                </step>
                            </preprocessing>
                        </item_prototype>
                    </item_prototypes>
                    <trigger_prototypes>
                        <trigger_prototype>
                            <expression>{MiRCA Port 1 PACE BMS:mirca.p1.temp[{#SNMPINDEX}].min(5m)}&gt;{$MIRCA.TEMP.MAX:"p1"} and {MiRCA Port 1 PACE BMS:mirca.p1.online.last()}=1</expression>
                            <name>Port 1: temperature T{#SNMPINDEX} is high (&gt;{$MIRCA.TEMP.MAX:"p1"}°C)</name>
                            <priority>AVERAGE</priority>
                        </trigger_prototype>
                        <trigger_prototype>
                            <expression>{MiRCA Port 1 PACE BMS:mirca.p1.temp[{#SNMPINDEX}].max(5m)}&lt;{$MIRCA.TEMP.MIN:"p1"} and {MiRCA Port 1 PACE BMS:mirca.p1.online.last()}=1</expression>
                            <name>Port 1: temperature T{#SNMPINDEX} is low (&lt;{$MIRCA.TEMP.MIN:"p1"}°C)</name>
                            <priority>WARNING</priority>
                        </trigger_prototype>
                    </trigger_prototypes>
                </discovery_rule>
            </discovery_rules>
            <macros>
                <macro>
                    <macro>{$MIRCA.INTERVAL}</macro>
                    <value>30s</value>
                    <description>Polling interval of live values</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.INTERVAL.SLOW}</macro>
                    <value>5m</value>
                    <description>Polling interval of slowly changing values (capacity, cycles, energy counters)</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.OFFLINE.TIME}</macro>
                    <value>5m</value>
                    <description>How long the device may stay silent before a problem is raised</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.SOC.WARN}</macro>
                    <value>20</value>
                    <description>SOC below this, %, raises a warning. Per port: {$MIRCA.SOC.WARN:"p1"}</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.SOC.CRIT}</macro>
                    <value>10</value>
                    <description>SOC below this, %, raises a high problem. Per port: {$MIRCA.SOC.CRIT:"p1"}</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.CELL.UV}</macro>
                    <value>2.9</value>
                    <description>Cell undervoltage threshold, V (LiFePO4 default). Per port: {$MIRCA.CELL.UV:"p1"}</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.CELL.OV}</macro>
                    <value>3.65</value>
                    <description>Cell overvoltage threshold, V (LiFePO4 default). Per port: {$MIRCA.CELL.OV:"p1"}</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.TEMP.MAX}</macro>
                    <value>50</value>
                    <description>Battery temperature sensor high threshold, °C. Per port: {$MIRCA.TEMP.MAX:"p1"}</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.TEMP.MIN}</macro>
                    <value>0</value>
                    <description>Battery temperature sensor low threshold, °C. Per port: {$MIRCA.TEMP.MIN:"p1"}</description>
                </macro>
            </macros>
        </template>
        <template>
            <template>MiRCA Port 2 PACE BMS</template>
            <name>MiRCA Port 2 PACE BMS</name>
            <description>MiRCA serial port 2 running the 'PACE BMS' protocol (protocol id 3). SNMP v2c over the Ethernet interface, tree .1.3.6.1.4.1.2021.13.16.4.2.2 (doc/ports.md). Link 'MiRCA Device' too. PACE BMS (Pylontech family ASCII protocol).</description>
            <groups>
                <group>
                    <name>Templates/MiRCA</name>
                </group>
            </groups>
            <applications>
                <application>
                    <name>Port 2</name>
                </application>
                <application>
                    <name>Battery</name>
                </application>
                <application>
                    <name>Cells</name>
                </application>
                <application>
                    <name>Temperature</name>
                </application>
            </applications>
            <items>
                <item>
                    <name>Port 2: protocol</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.1</snmp_oid>
                    <key>mirca.p2.protocol</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>UNSIGNED</value_type>
                    <description>Protocol configured on the port</description>
                    <applications>
                        <application>
                            <name>Port 2</name>
                        </application>
                    </applications>
                    <valuemap>
                        <name>MiRCA protocol</name>
                    </valuemap>
                </item>
                <item>
                    <name>Port 2: online</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.2</snmp_oid>
                    <key>mirca.p2.online</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>UNSIGNED</value_type>
                    <description>1 while the device answers. All values read 0 while it is offline.</description>
                    <applications>
                        <application>
                            <name>Port 2</name>
                        </application>
                    </applications>
                    <valuemap>
                        <name>MiRCA online</name>
                    </valuemap>
                </item>
                <item>
                    <name>Port 2: seconds since last reply</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.3</snmp_oid>
                    <key>mirca.p2.age</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>s</units>
                    <description>-1: no reply since boot</description>
                    <applications>
                        <application>
                            <name>Port 2</name>
                        </application>
                    </applications>
                </item>
                <item>
                    <name>Port 2: voltage</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.10</snmp_oid>
                    <key>mirca.p2.voltage</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>V</units>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.01</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 2: current</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.11</snmp_oid>
                    <key>mirca.p2.current</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>A</units>
                    <description>+ charging, - discharging</description>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.01</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 2: SOC</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.13</snmp_oid>
                    <key>mirca.p2.soc</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>%</units>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.1</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 2: cycles</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.14</snmp_oid>
                    <key>mirca.p2.cycles</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>UNSIGNED</value_type>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                </item>
                <item>
                    <name>Port 2: remaining capacity</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.15</snmp_oid>
                    <key>mirca.p2.cap_remain</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>Ah</units>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.01</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 2: full capacity</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.16</snmp_oid>
                    <key>mirca.p2.cap_full</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>Ah</units>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.01</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 2: cell count</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.17</snmp_oid>
                    <key>mirca.p2.cell_count</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>UNSIGNED</value_type>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                </item>
                <item>
                    <name>Port 2: power (calculated)</name>
                    <type>CALCULATED</type>
                    <key>mirca.p2.power.calc</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>W</units>
                    <params>last(mirca.p2.voltage)*last(mirca.p2.current)</params>
                    <description>Voltage x current; the protocol does not report power. + charging</description>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                </item>
            </items>
            <discovery_rules>
                <discovery_rule>
                    <name>Port 2: cells discovery</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>discovery[{#SNMPVALUE},1.3.6.1.4.1.2021.13.16.4.2.2.20]</snmp_oid>
                    <key>mirca.p2.cells.discovery</key>
                    <delay>1h</delay>
                    <filter>
                        <evaltype>AND</evaltype>
                        <conditions>
                            <condition>
                                <macro>{#SNMPVALUE}</macro>
                                <value>^[1-9]</value>
                                <formulaid>A</formulaid>
                            </condition>
                        </conditions>
                    </filter>
                    <lifetime>7d</lifetime>
                    <description>Cells the BMS reports (cell voltage &gt; 0 at discovery time)</description>
                    <item_prototypes>
                        <item_prototype>
                            <name>Port 2: cell {#SNMPINDEX} voltage</name>
                            <type>SNMP_AGENT</type>
                            <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.20.{#SNMPINDEX}</snmp_oid>
                            <key>mirca.p2.cell[{#SNMPINDEX}]</key>
                            <delay>{$MIRCA.INTERVAL}</delay>
                            <history>14d</history>
                            <trends>365d</trends>
                            <value_type>FLOAT</value_type>
                            <units>V</units>
                            <applications>
                                <application>
                                    <name>Cells</name>
                                </application>
                            </applications>
                            <preprocessing>
                                <step>
                                    <type>MULTIPLIER</type>
                                    <parameters>
                                        <parameter>0.001</parameter>
                                    </parameters>
                                </step>
                            </preprocessing>
                        </item_prototype>
                    </item_prototypes>
                    <trigger_prototypes>
                        <trigger_prototype>
                            <expression>{MiRCA Port 2 PACE BMS:mirca.p2.cell[{#SNMPINDEX}].max(2m)}&lt;{$MIRCA.CELL.UV:"p2"} and {MiRCA Port 2 PACE BMS:mirca.p2.online.last()}=1</expression>
                            <name>Port 2: cell {#SNMPINDEX} undervoltage (&lt;{$MIRCA.CELL.UV:"p2"}V)</name>
                            <priority>HIGH</priority>
                        </trigger_prototype>
                        <trigger_prototype>
                            <expression>{MiRCA Port 2 PACE BMS:mirca.p2.cell[{#SNMPINDEX}].min(2m)}&gt;{$MIRCA.CELL.OV:"p2"} and {MiRCA Port 2 PACE BMS:mirca.p2.online.last()}=1</expression>
                            <name>Port 2: cell {#SNMPINDEX} overvoltage (&gt;{$MIRCA.CELL.OV:"p2"}V)</name>
                            <priority>HIGH</priority>
                        </trigger_prototype>
                    </trigger_prototypes>
                </discovery_rule>
                <discovery_rule>
                    <name>Port 2: temperature sensors discovery</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>discovery[{#SNMPVALUE},1.3.6.1.4.1.2021.13.16.4.2.2.21]</snmp_oid>
                    <key>mirca.p2.temps.discovery</key>
                    <delay>1h</delay>
                    <filter>
                        <evaltype>AND</evaltype>
                        <conditions>
                            <condition>
                                <macro>{#SNMPVALUE}</macro>
                                <value>^-?[1-9]</value>
                                <formulaid>A</formulaid>
                            </condition>
                        </conditions>
                    </filter>
                    <lifetime>7d</lifetime>
                    <description>Temperature sensors the BMS reports (non-zero at discovery time)</description>
                    <item_prototypes>
                        <item_prototype>
                            <name>Port 2: temperature T{#SNMPINDEX}</name>
                            <type>SNMP_AGENT</type>
                            <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.21.{#SNMPINDEX}</snmp_oid>
                            <key>mirca.p2.temp[{#SNMPINDEX}]</key>
                            <delay>{$MIRCA.INTERVAL}</delay>
                            <history>14d</history>
                            <trends>365d</trends>
                            <value_type>FLOAT</value_type>
                            <units>°C</units>
                            <applications>
                                <application>
                                    <name>Temperature</name>
                                </application>
                            </applications>
                            <preprocessing>
                                <step>
                                    <type>MULTIPLIER</type>
                                    <parameters>
                                        <parameter>0.1</parameter>
                                    </parameters>
                                </step>
                            </preprocessing>
                        </item_prototype>
                    </item_prototypes>
                    <trigger_prototypes>
                        <trigger_prototype>
                            <expression>{MiRCA Port 2 PACE BMS:mirca.p2.temp[{#SNMPINDEX}].min(5m)}&gt;{$MIRCA.TEMP.MAX:"p2"} and {MiRCA Port 2 PACE BMS:mirca.p2.online.last()}=1</expression>
                            <name>Port 2: temperature T{#SNMPINDEX} is high (&gt;{$MIRCA.TEMP.MAX:"p2"}°C)</name>
                            <priority>AVERAGE</priority>
                        </trigger_prototype>
                        <trigger_prototype>
                            <expression>{MiRCA Port 2 PACE BMS:mirca.p2.temp[{#SNMPINDEX}].max(5m)}&lt;{$MIRCA.TEMP.MIN:"p2"} and {MiRCA Port 2 PACE BMS:mirca.p2.online.last()}=1</expression>
                            <name>Port 2: temperature T{#SNMPINDEX} is low (&lt;{$MIRCA.TEMP.MIN:"p2"}°C)</name>
                            <priority>WARNING</priority>
                        </trigger_prototype>
                    </trigger_prototypes>
                </discovery_rule>
            </discovery_rules>
            <macros>
                <macro>
                    <macro>{$MIRCA.INTERVAL}</macro>
                    <value>30s</value>
                    <description>Polling interval of live values</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.INTERVAL.SLOW}</macro>
                    <value>5m</value>
                    <description>Polling interval of slowly changing values (capacity, cycles, energy counters)</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.OFFLINE.TIME}</macro>
                    <value>5m</value>
                    <description>How long the device may stay silent before a problem is raised</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.SOC.WARN}</macro>
                    <value>20</value>
                    <description>SOC below this, %, raises a warning. Per port: {$MIRCA.SOC.WARN:"p1"}</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.SOC.CRIT}</macro>
                    <value>10</value>
                    <description>SOC below this, %, raises a high problem. Per port: {$MIRCA.SOC.CRIT:"p1"}</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.CELL.UV}</macro>
                    <value>2.9</value>
                    <description>Cell undervoltage threshold, V (LiFePO4 default). Per port: {$MIRCA.CELL.UV:"p1"}</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.CELL.OV}</macro>
                    <value>3.65</value>
                    <description>Cell overvoltage threshold, V (LiFePO4 default). Per port: {$MIRCA.CELL.OV:"p1"}</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.TEMP.MAX}</macro>
                    <value>50</value>
                    <description>Battery temperature sensor high threshold, °C. Per port: {$MIRCA.TEMP.MAX:"p1"}</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.TEMP.MIN}</macro>
                    <value>0</value>
                    <description>Battery temperature sensor low threshold, °C. Per port: {$MIRCA.TEMP.MIN:"p1"}</description>
                </macro>
            </macros>
        </template>
        <template>
            <template>MiRCA Port 1 Deye inverter Modbus</template>
            <name>MiRCA Port 1 Deye inverter Modbus</name>
            <description>MiRCA serial port 1 running the 'Deye inverter Modbus' protocol (protocol id 6). SNMP v2c over the Ethernet interface, tree .1.3.6.1.4.1.2021.13.16.4.2.1 (doc/ports.md). Link 'MiRCA Device' too. Deye / Sunsynk single-phase hybrid inverter, read only (Modbus FC 0x03). Signs: battery + discharging, grid + import, inverter + output.</description>
            <groups>
                <group>
                    <name>Templates/MiRCA</name>
                </group>
            </groups>
            <applications>
                <application>
                    <name>Port 1</name>
                </application>
                <application>
                    <name>Status</name>
                </application>
                <application>
                    <name>PV</name>
                </application>
                <application>
                    <name>Battery</name>
                </application>
                <application>
                    <name>Grid</name>
                </application>
                <application>
                    <name>Inverter</name>
                </application>
                <application>
                    <name>Load</name>
                </application>
                <application>
                    <name>Temperature</name>
                </application>
                <application>
                    <name>Energy</name>
                </application>
                <application>
                    <name>Device</name>
                </application>
            </applications>
            <items>
                <item>
                    <name>Port 1: protocol</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.1</snmp_oid>
                    <key>mirca.p1.protocol</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>UNSIGNED</value_type>
                    <description>Protocol configured on the port</description>
                    <applications>
                        <application>
                            <name>Port 1</name>
                        </application>
                    </applications>
                    <valuemap>
                        <name>MiRCA protocol</name>
                    </valuemap>
                </item>
                <item>
                    <name>Port 1: online</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.2</snmp_oid>
                    <key>mirca.p1.online</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>UNSIGNED</value_type>
                    <description>1 while the device answers. All values read 0 while it is offline.</description>
                    <applications>
                        <application>
                            <name>Port 1</name>
                        </application>
                    </applications>
                    <valuemap>
                        <name>MiRCA online</name>
                    </valuemap>
                </item>
                <item>
                    <name>Port 1: seconds since last reply</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.3</snmp_oid>
                    <key>mirca.p1.age</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>s</units>
                    <description>-1: no reply since boot</description>
                    <applications>
                        <application>
                            <name>Port 1</name>
                        </application>
                    </applications>
                </item>
                <item>
                    <name>Port 1: State code</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.40.1</snmp_oid>
                    <key>mirca.p1.m[state]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>UNSIGNED</value_type>
                    <description>Metric 1 'state'</description>
                    <applications>
                        <application>
                            <name>Status</name>
                        </application>
                    </applications>
                    <valuemap>
                        <name>MiRCA Deye state</name>
                    </valuemap>
                </item>
                <item>
                    <name>Port 1: Grid connected</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.40.2</snmp_oid>
                    <key>mirca.p1.m[grid_connected]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>UNSIGNED</value_type>
                    <description>Metric 2 'grid_connected'</description>
                    <applications>
                        <application>
                            <name>Status</name>
                        </application>
                    </applications>
                    <valuemap>
                        <name>MiRCA Deye grid</name>
                    </valuemap>
                </item>
                <item>
                    <name>Port 1: PV power</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.40.3</snmp_oid>
                    <key>mirca.p1.m[pv_power]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>W</units>
                    <description>Metric 3 'pv_power'</description>
                    <applications>
                        <application>
                            <name>PV</name>
                        </application>
                    </applications>
                </item>
                <item>
                    <name>Port 1: PV1 voltage</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.40.4</snmp_oid>
                    <key>mirca.p1.m[pv1_voltage]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>V</units>
                    <description>Metric 4 'pv1_voltage'</description>
                    <applications>
                        <application>
                            <name>PV</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.1</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 1: PV1 current</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.40.5</snmp_oid>
                    <key>mirca.p1.m[pv1_current]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>A</units>
                    <description>Metric 5 'pv1_current'</description>
                    <applications>
                        <application>
                            <name>PV</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.1</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 1: PV1 power</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.40.6</snmp_oid>
                    <key>mirca.p1.m[pv1_power]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>W</units>
                    <description>Metric 6 'pv1_power'</description>
                    <applications>
                        <application>
                            <name>PV</name>
                        </application>
                    </applications>
                </item>
                <item>
                    <name>Port 1: PV2 voltage</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.40.7</snmp_oid>
                    <key>mirca.p1.m[pv2_voltage]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>V</units>
                    <description>Metric 7 'pv2_voltage'</description>
                    <applications>
                        <application>
                            <name>PV</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.1</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 1: PV2 current</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.40.8</snmp_oid>
                    <key>mirca.p1.m[pv2_current]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>A</units>
                    <description>Metric 8 'pv2_current'</description>
                    <applications>
                        <application>
                            <name>PV</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.1</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 1: PV2 power</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.40.9</snmp_oid>
                    <key>mirca.p1.m[pv2_power]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>W</units>
                    <description>Metric 9 'pv2_power'</description>
                    <applications>
                        <application>
                            <name>PV</name>
                        </application>
                    </applications>
                </item>
                <item>
                    <name>Port 1: Battery voltage</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.40.10</snmp_oid>
                    <key>mirca.p1.m[battery_voltage]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>V</units>
                    <description>Metric 10 'battery_voltage'</description>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.01</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 1: Battery current (+ discharging)</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.40.11</snmp_oid>
                    <key>mirca.p1.m[battery_current]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>A</units>
                    <description>Metric 11 'battery_current'</description>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.01</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 1: Battery power (+ discharging)</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.40.12</snmp_oid>
                    <key>mirca.p1.m[battery_power]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>W</units>
                    <description>Metric 12 'battery_power'</description>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                </item>
                <item>
                    <name>Port 1: Battery SOC</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.40.13</snmp_oid>
                    <key>mirca.p1.m[battery_soc]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>%</units>
                    <description>Metric 13 'battery_soc'</description>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                </item>
                <item>
                    <name>Port 1: Battery temperature</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.40.14</snmp_oid>
                    <key>mirca.p1.m[battery_temp]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>°C</units>
                    <description>Metric 14 'battery_temp'</description>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.1</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 1: Charging voltage</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.40.15</snmp_oid>
                    <key>mirca.p1.m[battery_charge_voltage]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>V</units>
                    <description>Metric 15 'battery_charge_voltage'</description>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.01</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 1: Charge current limit</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.40.16</snmp_oid>
                    <key>mirca.p1.m[battery_charge_limit]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>A</units>
                    <description>Metric 16 'battery_charge_limit'</description>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                </item>
                <item>
                    <name>Port 1: Discharge current limit</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.40.17</snmp_oid>
                    <key>mirca.p1.m[battery_discharge_limit]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>A</units>
                    <description>Metric 17 'battery_discharge_limit'</description>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                </item>
                <item>
                    <name>Port 1: Grid voltage</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.40.18</snmp_oid>
                    <key>mirca.p1.m[grid_voltage]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>V</units>
                    <description>Metric 18 'grid_voltage'</description>
                    <applications>
                        <application>
                            <name>Grid</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.1</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 1: Grid frequency</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.40.19</snmp_oid>
                    <key>mirca.p1.m[grid_frequency]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>Hz</units>
                    <description>Metric 19 'grid_frequency'</description>
                    <applications>
                        <application>
                            <name>Grid</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.01</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 1: Grid current</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.40.20</snmp_oid>
                    <key>mirca.p1.m[grid_current]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>A</units>
                    <description>Metric 20 'grid_current'</description>
                    <applications>
                        <application>
                            <name>Grid</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.01</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 1: Grid power (+ import)</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.40.21</snmp_oid>
                    <key>mirca.p1.m[grid_power]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>W</units>
                    <description>Metric 21 'grid_power'</description>
                    <applications>
                        <application>
                            <name>Grid</name>
                        </application>
                    </applications>
                </item>
                <item>
                    <name>Port 1: Grid CT power</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.40.22</snmp_oid>
                    <key>mirca.p1.m[grid_ct_power]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>W</units>
                    <description>Metric 22 'grid_ct_power'</description>
                    <applications>
                        <application>
                            <name>Grid</name>
                        </application>
                    </applications>
                </item>
                <item>
                    <name>Port 1: Grid internal power</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.40.23</snmp_oid>
                    <key>mirca.p1.m[grid_internal_power]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>W</units>
                    <description>Metric 23 'grid_internal_power'</description>
                    <applications>
                        <application>
                            <name>Grid</name>
                        </application>
                    </applications>
                </item>
                <item>
                    <name>Port 1: Inverter voltage</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.40.24</snmp_oid>
                    <key>mirca.p1.m[inverter_voltage]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>V</units>
                    <description>Metric 24 'inverter_voltage'</description>
                    <applications>
                        <application>
                            <name>Inverter</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.1</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 1: Inverter current</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.40.25</snmp_oid>
                    <key>mirca.p1.m[inverter_current]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>A</units>
                    <description>Metric 25 'inverter_current'</description>
                    <applications>
                        <application>
                            <name>Inverter</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.01</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 1: Inverter power</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.40.26</snmp_oid>
                    <key>mirca.p1.m[inverter_power]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>W</units>
                    <description>Metric 26 'inverter_power'</description>
                    <applications>
                        <application>
                            <name>Inverter</name>
                        </application>
                    </applications>
                </item>
                <item>
                    <name>Port 1: Inverter frequency</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.40.27</snmp_oid>
                    <key>mirca.p1.m[inverter_frequency]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>Hz</units>
                    <description>Metric 27 'inverter_frequency'</description>
                    <applications>
                        <application>
                            <name>Inverter</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.01</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 1: Load power</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.40.28</snmp_oid>
                    <key>mirca.p1.m[load_power]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>W</units>
                    <description>Metric 28 'load_power'</description>
                    <applications>
                        <application>
                            <name>Load</name>
                        </application>
                    </applications>
                </item>
                <item>
                    <name>Port 1: Load frequency</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.40.29</snmp_oid>
                    <key>mirca.p1.m[load_frequency]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>Hz</units>
                    <description>Metric 29 'load_frequency'</description>
                    <applications>
                        <application>
                            <name>Load</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.01</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 1: Generator / AUX power</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.40.30</snmp_oid>
                    <key>mirca.p1.m[gen_power]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>W</units>
                    <description>Metric 30 'gen_power'</description>
                    <applications>
                        <application>
                            <name>Load</name>
                        </application>
                    </applications>
                </item>
                <item>
                    <name>Port 1: DC transformer temperature</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.40.31</snmp_oid>
                    <key>mirca.p1.m[dc_temp]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>°C</units>
                    <description>Metric 31 'dc_temp'</description>
                    <applications>
                        <application>
                            <name>Temperature</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.1</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 1: Radiator temperature</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.40.32</snmp_oid>
                    <key>mirca.p1.m[radiator_temp]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>°C</units>
                    <description>Metric 32 'radiator_temp'</description>
                    <applications>
                        <application>
                            <name>Temperature</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.1</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 1: Environment temperature</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.40.33</snmp_oid>
                    <key>mirca.p1.m[environment_temp]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>°C</units>
                    <description>Metric 33 'environment_temp'</description>
                    <applications>
                        <application>
                            <name>Temperature</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.1</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 1: PV today</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.40.34</snmp_oid>
                    <key>mirca.p1.m[day_pv]</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>kWh</units>
                    <description>Metric 34 'day_pv'</description>
                    <applications>
                        <application>
                            <name>Energy</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.1</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 1: Load today</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.40.35</snmp_oid>
                    <key>mirca.p1.m[day_load]</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>kWh</units>
                    <description>Metric 35 'day_load'</description>
                    <applications>
                        <application>
                            <name>Energy</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.1</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 1: Grid import today</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.40.36</snmp_oid>
                    <key>mirca.p1.m[day_grid_import]</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>kWh</units>
                    <description>Metric 36 'day_grid_import'</description>
                    <applications>
                        <application>
                            <name>Energy</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.1</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 1: Grid export today</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.40.37</snmp_oid>
                    <key>mirca.p1.m[day_grid_export]</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>kWh</units>
                    <description>Metric 37 'day_grid_export'</description>
                    <applications>
                        <application>
                            <name>Energy</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.1</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 1: Battery charge today</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.40.38</snmp_oid>
                    <key>mirca.p1.m[day_battery_charge]</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>kWh</units>
                    <description>Metric 38 'day_battery_charge'</description>
                    <applications>
                        <application>
                            <name>Energy</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.1</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 1: Battery discharge today</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.40.39</snmp_oid>
                    <key>mirca.p1.m[day_battery_discharge]</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>kWh</units>
                    <description>Metric 39 'day_battery_discharge'</description>
                    <applications>
                        <application>
                            <name>Energy</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.1</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 1: PV this month</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.40.40</snmp_oid>
                    <key>mirca.p1.m[month_pv]</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>kWh</units>
                    <description>Metric 40 'month_pv'</description>
                    <applications>
                        <application>
                            <name>Energy</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.1</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 1: Load this month</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.40.41</snmp_oid>
                    <key>mirca.p1.m[month_load]</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>kWh</units>
                    <description>Metric 41 'month_load'</description>
                    <applications>
                        <application>
                            <name>Energy</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.1</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 1: Grid this month</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.40.42</snmp_oid>
                    <key>mirca.p1.m[month_grid]</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>kWh</units>
                    <description>Metric 42 'month_grid'</description>
                    <applications>
                        <application>
                            <name>Energy</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.1</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 1: PV this year</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.40.43</snmp_oid>
                    <key>mirca.p1.m[year_pv]</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>kWh</units>
                    <description>Metric 43 'year_pv'</description>
                    <applications>
                        <application>
                            <name>Energy</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.1</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 1: Load this year</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.40.44</snmp_oid>
                    <key>mirca.p1.m[year_load]</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>kWh</units>
                    <description>Metric 44 'year_load'</description>
                    <applications>
                        <application>
                            <name>Energy</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.1</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 1: Grid export this year</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.40.45</snmp_oid>
                    <key>mirca.p1.m[year_grid_export]</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>kWh</units>
                    <description>Metric 45 'year_grid_export'</description>
                    <applications>
                        <application>
                            <name>Energy</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.1</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 1: PV total</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.40.46</snmp_oid>
                    <key>mirca.p1.m[total_pv]</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>kWh</units>
                    <description>Metric 46 'total_pv'</description>
                    <applications>
                        <application>
                            <name>Energy</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.1</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 1: Load total</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.40.47</snmp_oid>
                    <key>mirca.p1.m[total_load]</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>kWh</units>
                    <description>Metric 47 'total_load'</description>
                    <applications>
                        <application>
                            <name>Energy</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.1</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 1: Grid import total</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.40.48</snmp_oid>
                    <key>mirca.p1.m[total_grid_import]</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>kWh</units>
                    <description>Metric 48 'total_grid_import'</description>
                    <applications>
                        <application>
                            <name>Energy</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.1</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 1: Grid export total</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.40.49</snmp_oid>
                    <key>mirca.p1.m[total_grid_export]</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>kWh</units>
                    <description>Metric 49 'total_grid_export'</description>
                    <applications>
                        <application>
                            <name>Energy</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.1</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 1: Battery charge total</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.40.50</snmp_oid>
                    <key>mirca.p1.m[total_battery_charge]</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>kWh</units>
                    <description>Metric 50 'total_battery_charge'</description>
                    <applications>
                        <application>
                            <name>Energy</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.1</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 1: Battery discharge total</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.40.51</snmp_oid>
                    <key>mirca.p1.m[total_battery_discharge]</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>kWh</units>
                    <description>Metric 51 'total_battery_discharge'</description>
                    <applications>
                        <application>
                            <name>Energy</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.1</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 1: Rated power</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.40.52</snmp_oid>
                    <key>mirca.p1.m[rated_power]</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>W</units>
                    <description>Metric 52 'rated_power'</description>
                    <applications>
                        <application>
                            <name>Device</name>
                        </application>
                    </applications>
                </item>
                <item>
                    <name>Port 1: fault bits F01-F32</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.19</snmp_oid>
                    <key>mirca.p1.faults.lo</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>UNSIGNED</value_type>
                    <description>Registers 103-104, bit 0 = F01</description>
                    <applications>
                        <application>
                            <name>Status</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>JAVASCRIPT</type>
                            <parameters>
                                <parameter>return (parseInt(value, 10) &gt;&gt;&gt; 0).toString();</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 1: fault bits F33-F64</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.22</snmp_oid>
                    <key>mirca.p1.faults.hi</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>UNSIGNED</value_type>
                    <description>Registers 105-106, bit 0 = F33</description>
                    <applications>
                        <application>
                            <name>Status</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>JAVASCRIPT</type>
                            <parameters>
                                <parameter>return (parseInt(value, 10) &gt;&gt;&gt; 0).toString();</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 1: faults F01-F32</name>
                    <type>DEPENDENT</type>
                    <key>mirca.p1.faults.lo.text</key>
                    <delay>0</delay>
                    <history>14d</history>
                    <trends>0</trends>
                    <value_type>CHAR</value_type>
                    <applications>
                        <application>
                            <name>Status</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>JAVASCRIPT</type>
                            <parameters>
                                <parameter>var names = {13: 'Working mode change', 18: 'AC over current', 20: 'DC over current', 23: 'AC leak current or transient over current', 24: 'DC insulation impedance', 26: 'DC busbar imbalanced', 29: 'Parallel comms cable', 35: 'No AC grid', 42: 'AC line low voltage', 47: 'AC freq high/low', 56: 'DC busbar voltage low', 63: 'ARC fault', 64: 'Heat sink temperature failure'};
var v = parseInt(value, 10) &gt;&gt;&gt; 0, out = [];
for (var i = 0; i &lt; 32; i++) {
  if (!((v &gt;&gt;&gt; i) &amp; 1)) continue;
  var code = 1 + i;
  out.push('F' + (code &lt; 10 ? '0' : '') + code + (names[code] ? ' ' + names[code] : ''));
}
return out.length ? out.join(', ') : 'none';</parameter>
                            </parameters>
                        </step>
                        <step>
                            <type>DISCARD_UNCHANGED_HEARTBEAT</type>
                            <parameters>
                                <parameter>1h</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                    <master_item>
                        <key>mirca.p1.faults.lo</key>
                    </master_item>
                </item>
                <item>
                    <name>Port 1: faults F33-F64</name>
                    <type>DEPENDENT</type>
                    <key>mirca.p1.faults.hi.text</key>
                    <delay>0</delay>
                    <history>14d</history>
                    <trends>0</trends>
                    <value_type>CHAR</value_type>
                    <applications>
                        <application>
                            <name>Status</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>JAVASCRIPT</type>
                            <parameters>
                                <parameter>var names = {13: 'Working mode change', 18: 'AC over current', 20: 'DC over current', 23: 'AC leak current or transient over current', 24: 'DC insulation impedance', 26: 'DC busbar imbalanced', 29: 'Parallel comms cable', 35: 'No AC grid', 42: 'AC line low voltage', 47: 'AC freq high/low', 56: 'DC busbar voltage low', 63: 'ARC fault', 64: 'Heat sink temperature failure'};
var v = parseInt(value, 10) &gt;&gt;&gt; 0, out = [];
for (var i = 0; i &lt; 32; i++) {
  if (!((v &gt;&gt;&gt; i) &amp; 1)) continue;
  var code = 33 + i;
  out.push('F' + (code &lt; 10 ? '0' : '') + code + (names[code] ? ' ' + names[code] : ''));
}
return out.length ? out.join(', ') : 'none';</parameter>
                            </parameters>
                        </step>
                        <step>
                            <type>DISCARD_UNCHANGED_HEARTBEAT</type>
                            <parameters>
                                <parameter>1h</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                    <master_item>
                        <key>mirca.p1.faults.hi</key>
                    </master_item>
                </item>
            </items>
            <macros>
                <macro>
                    <macro>{$MIRCA.INTERVAL}</macro>
                    <value>30s</value>
                    <description>Polling interval of live values</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.INTERVAL.SLOW}</macro>
                    <value>5m</value>
                    <description>Polling interval of slowly changing values (capacity, cycles, energy counters)</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.OFFLINE.TIME}</macro>
                    <value>5m</value>
                    <description>How long the device may stay silent before a problem is raised</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.SOC.WARN}</macro>
                    <value>20</value>
                    <description>Battery SOC low threshold, %. Per port: {$MIRCA.SOC.WARN:"p1"}</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.DEYE.TEMP.MAX}</macro>
                    <value>75</value>
                    <description>Inverter DC transformer / radiator temperature threshold, °C</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.DEYE.GRID.EXPECTED}</macro>
                    <value>1</value>
                    <description>1: raise a problem when the grid is disconnected, 0: off-grid site</description>
                </macro>
            </macros>
        </template>
        <template>
            <template>MiRCA Port 2 Deye inverter Modbus</template>
            <name>MiRCA Port 2 Deye inverter Modbus</name>
            <description>MiRCA serial port 2 running the 'Deye inverter Modbus' protocol (protocol id 6). SNMP v2c over the Ethernet interface, tree .1.3.6.1.4.1.2021.13.16.4.2.2 (doc/ports.md). Link 'MiRCA Device' too. Deye / Sunsynk single-phase hybrid inverter, read only (Modbus FC 0x03). Signs: battery + discharging, grid + import, inverter + output.</description>
            <groups>
                <group>
                    <name>Templates/MiRCA</name>
                </group>
            </groups>
            <applications>
                <application>
                    <name>Port 2</name>
                </application>
                <application>
                    <name>Status</name>
                </application>
                <application>
                    <name>PV</name>
                </application>
                <application>
                    <name>Battery</name>
                </application>
                <application>
                    <name>Grid</name>
                </application>
                <application>
                    <name>Inverter</name>
                </application>
                <application>
                    <name>Load</name>
                </application>
                <application>
                    <name>Temperature</name>
                </application>
                <application>
                    <name>Energy</name>
                </application>
                <application>
                    <name>Device</name>
                </application>
            </applications>
            <items>
                <item>
                    <name>Port 2: protocol</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.1</snmp_oid>
                    <key>mirca.p2.protocol</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>UNSIGNED</value_type>
                    <description>Protocol configured on the port</description>
                    <applications>
                        <application>
                            <name>Port 2</name>
                        </application>
                    </applications>
                    <valuemap>
                        <name>MiRCA protocol</name>
                    </valuemap>
                </item>
                <item>
                    <name>Port 2: online</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.2</snmp_oid>
                    <key>mirca.p2.online</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>UNSIGNED</value_type>
                    <description>1 while the device answers. All values read 0 while it is offline.</description>
                    <applications>
                        <application>
                            <name>Port 2</name>
                        </application>
                    </applications>
                    <valuemap>
                        <name>MiRCA online</name>
                    </valuemap>
                </item>
                <item>
                    <name>Port 2: seconds since last reply</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.3</snmp_oid>
                    <key>mirca.p2.age</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>s</units>
                    <description>-1: no reply since boot</description>
                    <applications>
                        <application>
                            <name>Port 2</name>
                        </application>
                    </applications>
                </item>
                <item>
                    <name>Port 2: State code</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.40.1</snmp_oid>
                    <key>mirca.p2.m[state]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>UNSIGNED</value_type>
                    <description>Metric 1 'state'</description>
                    <applications>
                        <application>
                            <name>Status</name>
                        </application>
                    </applications>
                    <valuemap>
                        <name>MiRCA Deye state</name>
                    </valuemap>
                </item>
                <item>
                    <name>Port 2: Grid connected</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.40.2</snmp_oid>
                    <key>mirca.p2.m[grid_connected]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>UNSIGNED</value_type>
                    <description>Metric 2 'grid_connected'</description>
                    <applications>
                        <application>
                            <name>Status</name>
                        </application>
                    </applications>
                    <valuemap>
                        <name>MiRCA Deye grid</name>
                    </valuemap>
                </item>
                <item>
                    <name>Port 2: PV power</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.40.3</snmp_oid>
                    <key>mirca.p2.m[pv_power]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>W</units>
                    <description>Metric 3 'pv_power'</description>
                    <applications>
                        <application>
                            <name>PV</name>
                        </application>
                    </applications>
                </item>
                <item>
                    <name>Port 2: PV1 voltage</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.40.4</snmp_oid>
                    <key>mirca.p2.m[pv1_voltage]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>V</units>
                    <description>Metric 4 'pv1_voltage'</description>
                    <applications>
                        <application>
                            <name>PV</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.1</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 2: PV1 current</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.40.5</snmp_oid>
                    <key>mirca.p2.m[pv1_current]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>A</units>
                    <description>Metric 5 'pv1_current'</description>
                    <applications>
                        <application>
                            <name>PV</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.1</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 2: PV1 power</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.40.6</snmp_oid>
                    <key>mirca.p2.m[pv1_power]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>W</units>
                    <description>Metric 6 'pv1_power'</description>
                    <applications>
                        <application>
                            <name>PV</name>
                        </application>
                    </applications>
                </item>
                <item>
                    <name>Port 2: PV2 voltage</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.40.7</snmp_oid>
                    <key>mirca.p2.m[pv2_voltage]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>V</units>
                    <description>Metric 7 'pv2_voltage'</description>
                    <applications>
                        <application>
                            <name>PV</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.1</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 2: PV2 current</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.40.8</snmp_oid>
                    <key>mirca.p2.m[pv2_current]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>A</units>
                    <description>Metric 8 'pv2_current'</description>
                    <applications>
                        <application>
                            <name>PV</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.1</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 2: PV2 power</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.40.9</snmp_oid>
                    <key>mirca.p2.m[pv2_power]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>W</units>
                    <description>Metric 9 'pv2_power'</description>
                    <applications>
                        <application>
                            <name>PV</name>
                        </application>
                    </applications>
                </item>
                <item>
                    <name>Port 2: Battery voltage</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.40.10</snmp_oid>
                    <key>mirca.p2.m[battery_voltage]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>V</units>
                    <description>Metric 10 'battery_voltage'</description>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.01</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 2: Battery current (+ discharging)</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.40.11</snmp_oid>
                    <key>mirca.p2.m[battery_current]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>A</units>
                    <description>Metric 11 'battery_current'</description>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.01</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 2: Battery power (+ discharging)</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.40.12</snmp_oid>
                    <key>mirca.p2.m[battery_power]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>W</units>
                    <description>Metric 12 'battery_power'</description>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                </item>
                <item>
                    <name>Port 2: Battery SOC</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.40.13</snmp_oid>
                    <key>mirca.p2.m[battery_soc]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>%</units>
                    <description>Metric 13 'battery_soc'</description>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                </item>
                <item>
                    <name>Port 2: Battery temperature</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.40.14</snmp_oid>
                    <key>mirca.p2.m[battery_temp]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>°C</units>
                    <description>Metric 14 'battery_temp'</description>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.1</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 2: Charging voltage</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.40.15</snmp_oid>
                    <key>mirca.p2.m[battery_charge_voltage]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>V</units>
                    <description>Metric 15 'battery_charge_voltage'</description>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.01</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 2: Charge current limit</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.40.16</snmp_oid>
                    <key>mirca.p2.m[battery_charge_limit]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>A</units>
                    <description>Metric 16 'battery_charge_limit'</description>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                </item>
                <item>
                    <name>Port 2: Discharge current limit</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.40.17</snmp_oid>
                    <key>mirca.p2.m[battery_discharge_limit]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>A</units>
                    <description>Metric 17 'battery_discharge_limit'</description>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                </item>
                <item>
                    <name>Port 2: Grid voltage</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.40.18</snmp_oid>
                    <key>mirca.p2.m[grid_voltage]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>V</units>
                    <description>Metric 18 'grid_voltage'</description>
                    <applications>
                        <application>
                            <name>Grid</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.1</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 2: Grid frequency</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.40.19</snmp_oid>
                    <key>mirca.p2.m[grid_frequency]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>Hz</units>
                    <description>Metric 19 'grid_frequency'</description>
                    <applications>
                        <application>
                            <name>Grid</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.01</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 2: Grid current</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.40.20</snmp_oid>
                    <key>mirca.p2.m[grid_current]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>A</units>
                    <description>Metric 20 'grid_current'</description>
                    <applications>
                        <application>
                            <name>Grid</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.01</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 2: Grid power (+ import)</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.40.21</snmp_oid>
                    <key>mirca.p2.m[grid_power]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>W</units>
                    <description>Metric 21 'grid_power'</description>
                    <applications>
                        <application>
                            <name>Grid</name>
                        </application>
                    </applications>
                </item>
                <item>
                    <name>Port 2: Grid CT power</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.40.22</snmp_oid>
                    <key>mirca.p2.m[grid_ct_power]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>W</units>
                    <description>Metric 22 'grid_ct_power'</description>
                    <applications>
                        <application>
                            <name>Grid</name>
                        </application>
                    </applications>
                </item>
                <item>
                    <name>Port 2: Grid internal power</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.40.23</snmp_oid>
                    <key>mirca.p2.m[grid_internal_power]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>W</units>
                    <description>Metric 23 'grid_internal_power'</description>
                    <applications>
                        <application>
                            <name>Grid</name>
                        </application>
                    </applications>
                </item>
                <item>
                    <name>Port 2: Inverter voltage</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.40.24</snmp_oid>
                    <key>mirca.p2.m[inverter_voltage]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>V</units>
                    <description>Metric 24 'inverter_voltage'</description>
                    <applications>
                        <application>
                            <name>Inverter</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.1</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 2: Inverter current</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.40.25</snmp_oid>
                    <key>mirca.p2.m[inverter_current]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>A</units>
                    <description>Metric 25 'inverter_current'</description>
                    <applications>
                        <application>
                            <name>Inverter</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.01</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 2: Inverter power</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.40.26</snmp_oid>
                    <key>mirca.p2.m[inverter_power]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>W</units>
                    <description>Metric 26 'inverter_power'</description>
                    <applications>
                        <application>
                            <name>Inverter</name>
                        </application>
                    </applications>
                </item>
                <item>
                    <name>Port 2: Inverter frequency</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.40.27</snmp_oid>
                    <key>mirca.p2.m[inverter_frequency]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>Hz</units>
                    <description>Metric 27 'inverter_frequency'</description>
                    <applications>
                        <application>
                            <name>Inverter</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.01</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 2: Load power</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.40.28</snmp_oid>
                    <key>mirca.p2.m[load_power]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>W</units>
                    <description>Metric 28 'load_power'</description>
                    <applications>
                        <application>
                            <name>Load</name>
                        </application>
                    </applications>
                </item>
                <item>
                    <name>Port 2: Load frequency</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.40.29</snmp_oid>
                    <key>mirca.p2.m[load_frequency]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>Hz</units>
                    <description>Metric 29 'load_frequency'</description>
                    <applications>
                        <application>
                            <name>Load</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.01</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 2: Generator / AUX power</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.40.30</snmp_oid>
                    <key>mirca.p2.m[gen_power]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>W</units>
                    <description>Metric 30 'gen_power'</description>
                    <applications>
                        <application>
                            <name>Load</name>
                        </application>
                    </applications>
                </item>
                <item>
                    <name>Port 2: DC transformer temperature</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.40.31</snmp_oid>
                    <key>mirca.p2.m[dc_temp]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>°C</units>
                    <description>Metric 31 'dc_temp'</description>
                    <applications>
                        <application>
                            <name>Temperature</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.1</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 2: Radiator temperature</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.40.32</snmp_oid>
                    <key>mirca.p2.m[radiator_temp]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>°C</units>
                    <description>Metric 32 'radiator_temp'</description>
                    <applications>
                        <application>
                            <name>Temperature</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.1</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 2: Environment temperature</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.40.33</snmp_oid>
                    <key>mirca.p2.m[environment_temp]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>°C</units>
                    <description>Metric 33 'environment_temp'</description>
                    <applications>
                        <application>
                            <name>Temperature</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.1</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 2: PV today</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.40.34</snmp_oid>
                    <key>mirca.p2.m[day_pv]</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>kWh</units>
                    <description>Metric 34 'day_pv'</description>
                    <applications>
                        <application>
                            <name>Energy</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.1</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 2: Load today</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.40.35</snmp_oid>
                    <key>mirca.p2.m[day_load]</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>kWh</units>
                    <description>Metric 35 'day_load'</description>
                    <applications>
                        <application>
                            <name>Energy</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.1</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 2: Grid import today</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.40.36</snmp_oid>
                    <key>mirca.p2.m[day_grid_import]</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>kWh</units>
                    <description>Metric 36 'day_grid_import'</description>
                    <applications>
                        <application>
                            <name>Energy</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.1</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 2: Grid export today</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.40.37</snmp_oid>
                    <key>mirca.p2.m[day_grid_export]</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>kWh</units>
                    <description>Metric 37 'day_grid_export'</description>
                    <applications>
                        <application>
                            <name>Energy</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.1</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 2: Battery charge today</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.40.38</snmp_oid>
                    <key>mirca.p2.m[day_battery_charge]</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>kWh</units>
                    <description>Metric 38 'day_battery_charge'</description>
                    <applications>
                        <application>
                            <name>Energy</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.1</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 2: Battery discharge today</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.40.39</snmp_oid>
                    <key>mirca.p2.m[day_battery_discharge]</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>kWh</units>
                    <description>Metric 39 'day_battery_discharge'</description>
                    <applications>
                        <application>
                            <name>Energy</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.1</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 2: PV this month</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.40.40</snmp_oid>
                    <key>mirca.p2.m[month_pv]</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>kWh</units>
                    <description>Metric 40 'month_pv'</description>
                    <applications>
                        <application>
                            <name>Energy</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.1</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 2: Load this month</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.40.41</snmp_oid>
                    <key>mirca.p2.m[month_load]</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>kWh</units>
                    <description>Metric 41 'month_load'</description>
                    <applications>
                        <application>
                            <name>Energy</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.1</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 2: Grid this month</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.40.42</snmp_oid>
                    <key>mirca.p2.m[month_grid]</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>kWh</units>
                    <description>Metric 42 'month_grid'</description>
                    <applications>
                        <application>
                            <name>Energy</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.1</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 2: PV this year</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.40.43</snmp_oid>
                    <key>mirca.p2.m[year_pv]</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>kWh</units>
                    <description>Metric 43 'year_pv'</description>
                    <applications>
                        <application>
                            <name>Energy</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.1</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 2: Load this year</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.40.44</snmp_oid>
                    <key>mirca.p2.m[year_load]</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>kWh</units>
                    <description>Metric 44 'year_load'</description>
                    <applications>
                        <application>
                            <name>Energy</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.1</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 2: Grid export this year</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.40.45</snmp_oid>
                    <key>mirca.p2.m[year_grid_export]</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>kWh</units>
                    <description>Metric 45 'year_grid_export'</description>
                    <applications>
                        <application>
                            <name>Energy</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.1</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 2: PV total</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.40.46</snmp_oid>
                    <key>mirca.p2.m[total_pv]</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>kWh</units>
                    <description>Metric 46 'total_pv'</description>
                    <applications>
                        <application>
                            <name>Energy</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.1</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 2: Load total</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.40.47</snmp_oid>
                    <key>mirca.p2.m[total_load]</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>kWh</units>
                    <description>Metric 47 'total_load'</description>
                    <applications>
                        <application>
                            <name>Energy</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.1</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 2: Grid import total</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.40.48</snmp_oid>
                    <key>mirca.p2.m[total_grid_import]</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>kWh</units>
                    <description>Metric 48 'total_grid_import'</description>
                    <applications>
                        <application>
                            <name>Energy</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.1</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 2: Grid export total</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.40.49</snmp_oid>
                    <key>mirca.p2.m[total_grid_export]</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>kWh</units>
                    <description>Metric 49 'total_grid_export'</description>
                    <applications>
                        <application>
                            <name>Energy</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.1</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 2: Battery charge total</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.40.50</snmp_oid>
                    <key>mirca.p2.m[total_battery_charge]</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>kWh</units>
                    <description>Metric 50 'total_battery_charge'</description>
                    <applications>
                        <application>
                            <name>Energy</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.1</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 2: Battery discharge total</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.40.51</snmp_oid>
                    <key>mirca.p2.m[total_battery_discharge]</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>kWh</units>
                    <description>Metric 51 'total_battery_discharge'</description>
                    <applications>
                        <application>
                            <name>Energy</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.1</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 2: Rated power</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.40.52</snmp_oid>
                    <key>mirca.p2.m[rated_power]</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>W</units>
                    <description>Metric 52 'rated_power'</description>
                    <applications>
                        <application>
                            <name>Device</name>
                        </application>
                    </applications>
                </item>
                <item>
                    <name>Port 2: fault bits F01-F32</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.19</snmp_oid>
                    <key>mirca.p2.faults.lo</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>UNSIGNED</value_type>
                    <description>Registers 103-104, bit 0 = F01</description>
                    <applications>
                        <application>
                            <name>Status</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>JAVASCRIPT</type>
                            <parameters>
                                <parameter>return (parseInt(value, 10) &gt;&gt;&gt; 0).toString();</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 2: fault bits F33-F64</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.22</snmp_oid>
                    <key>mirca.p2.faults.hi</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>UNSIGNED</value_type>
                    <description>Registers 105-106, bit 0 = F33</description>
                    <applications>
                        <application>
                            <name>Status</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>JAVASCRIPT</type>
                            <parameters>
                                <parameter>return (parseInt(value, 10) &gt;&gt;&gt; 0).toString();</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 2: faults F01-F32</name>
                    <type>DEPENDENT</type>
                    <key>mirca.p2.faults.lo.text</key>
                    <delay>0</delay>
                    <history>14d</history>
                    <trends>0</trends>
                    <value_type>CHAR</value_type>
                    <applications>
                        <application>
                            <name>Status</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>JAVASCRIPT</type>
                            <parameters>
                                <parameter>var names = {13: 'Working mode change', 18: 'AC over current', 20: 'DC over current', 23: 'AC leak current or transient over current', 24: 'DC insulation impedance', 26: 'DC busbar imbalanced', 29: 'Parallel comms cable', 35: 'No AC grid', 42: 'AC line low voltage', 47: 'AC freq high/low', 56: 'DC busbar voltage low', 63: 'ARC fault', 64: 'Heat sink temperature failure'};
var v = parseInt(value, 10) &gt;&gt;&gt; 0, out = [];
for (var i = 0; i &lt; 32; i++) {
  if (!((v &gt;&gt;&gt; i) &amp; 1)) continue;
  var code = 1 + i;
  out.push('F' + (code &lt; 10 ? '0' : '') + code + (names[code] ? ' ' + names[code] : ''));
}
return out.length ? out.join(', ') : 'none';</parameter>
                            </parameters>
                        </step>
                        <step>
                            <type>DISCARD_UNCHANGED_HEARTBEAT</type>
                            <parameters>
                                <parameter>1h</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                    <master_item>
                        <key>mirca.p2.faults.lo</key>
                    </master_item>
                </item>
                <item>
                    <name>Port 2: faults F33-F64</name>
                    <type>DEPENDENT</type>
                    <key>mirca.p2.faults.hi.text</key>
                    <delay>0</delay>
                    <history>14d</history>
                    <trends>0</trends>
                    <value_type>CHAR</value_type>
                    <applications>
                        <application>
                            <name>Status</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>JAVASCRIPT</type>
                            <parameters>
                                <parameter>var names = {13: 'Working mode change', 18: 'AC over current', 20: 'DC over current', 23: 'AC leak current or transient over current', 24: 'DC insulation impedance', 26: 'DC busbar imbalanced', 29: 'Parallel comms cable', 35: 'No AC grid', 42: 'AC line low voltage', 47: 'AC freq high/low', 56: 'DC busbar voltage low', 63: 'ARC fault', 64: 'Heat sink temperature failure'};
var v = parseInt(value, 10) &gt;&gt;&gt; 0, out = [];
for (var i = 0; i &lt; 32; i++) {
  if (!((v &gt;&gt;&gt; i) &amp; 1)) continue;
  var code = 33 + i;
  out.push('F' + (code &lt; 10 ? '0' : '') + code + (names[code] ? ' ' + names[code] : ''));
}
return out.length ? out.join(', ') : 'none';</parameter>
                            </parameters>
                        </step>
                        <step>
                            <type>DISCARD_UNCHANGED_HEARTBEAT</type>
                            <parameters>
                                <parameter>1h</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                    <master_item>
                        <key>mirca.p2.faults.hi</key>
                    </master_item>
                </item>
            </items>
            <macros>
                <macro>
                    <macro>{$MIRCA.INTERVAL}</macro>
                    <value>30s</value>
                    <description>Polling interval of live values</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.INTERVAL.SLOW}</macro>
                    <value>5m</value>
                    <description>Polling interval of slowly changing values (capacity, cycles, energy counters)</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.OFFLINE.TIME}</macro>
                    <value>5m</value>
                    <description>How long the device may stay silent before a problem is raised</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.SOC.WARN}</macro>
                    <value>20</value>
                    <description>Battery SOC low threshold, %. Per port: {$MIRCA.SOC.WARN:"p1"}</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.DEYE.TEMP.MAX}</macro>
                    <value>75</value>
                    <description>Inverter DC transformer / radiator temperature threshold, °C</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.DEYE.GRID.EXPECTED}</macro>
                    <value>1</value>
                    <description>1: raise a problem when the grid is disconnected, 0: off-grid site</description>
                </macro>
            </macros>
        </template>
        <template>
            <template>MiRCA Port 1 Victron VE.Bus</template>
            <name>MiRCA Port 1 Victron VE.Bus</name>
            <description>MiRCA serial port 1 running the 'Victron VE.Bus' protocol (protocol id 1). SNMP v2c over the Ethernet interface, tree .1.3.6.1.4.1.2021.13.16.4.2.1 (doc/ports.md). Link 'MiRCA Device' too. Victron Multiplus / Quattro, passive listening on VE.Bus.</description>
            <groups>
                <group>
                    <name>Templates/MiRCA</name>
                </group>
            </groups>
            <applications>
                <application>
                    <name>Port 1</name>
                </application>
                <application>
                    <name>Inverter</name>
                </application>
            </applications>
            <items>
                <item>
                    <name>Port 1: protocol</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.1</snmp_oid>
                    <key>mirca.p1.protocol</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>UNSIGNED</value_type>
                    <description>Protocol configured on the port</description>
                    <applications>
                        <application>
                            <name>Port 1</name>
                        </application>
                    </applications>
                    <valuemap>
                        <name>MiRCA protocol</name>
                    </valuemap>
                </item>
                <item>
                    <name>Port 1: online</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.2</snmp_oid>
                    <key>mirca.p1.online</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>UNSIGNED</value_type>
                    <description>1 while the device answers. All values read 0 while it is offline.</description>
                    <applications>
                        <application>
                            <name>Port 1</name>
                        </application>
                    </applications>
                    <valuemap>
                        <name>MiRCA online</name>
                    </valuemap>
                </item>
                <item>
                    <name>Port 1: seconds since last reply</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.3</snmp_oid>
                    <key>mirca.p1.age</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>s</units>
                    <description>-1: no reply since boot</description>
                    <applications>
                        <application>
                            <name>Port 1</name>
                        </application>
                    </applications>
                </item>
                <item>
                    <name>Port 1: DC voltage</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.30</snmp_oid>
                    <key>mirca.p1.dc_voltage</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>V</units>
                    <applications>
                        <application>
                            <name>Inverter</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.01</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 1: DC current</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.31</snmp_oid>
                    <key>mirca.p1.dc_current</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>A</units>
                    <applications>
                        <application>
                            <name>Inverter</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.01</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 1: AC frequency</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.32</snmp_oid>
                    <key>mirca.p1.ac_frequency</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>Hz</units>
                    <applications>
                        <application>
                            <name>Inverter</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.01</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 1: power factor</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.33</snmp_oid>
                    <key>mirca.p1.power_factor</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <applications>
                        <application>
                            <name>Inverter</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.01</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 1: DC power (calculated)</name>
                    <type>CALCULATED</type>
                    <key>mirca.p1.dc_power.calc</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>W</units>
                    <params>last(mirca.p1.dc_voltage)*last(mirca.p1.dc_current)</params>
                    <applications>
                        <application>
                            <name>Inverter</name>
                        </application>
                    </applications>
                </item>
            </items>
            <macros>
                <macro>
                    <macro>{$MIRCA.INTERVAL}</macro>
                    <value>30s</value>
                    <description>Polling interval of live values</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.INTERVAL.SLOW}</macro>
                    <value>5m</value>
                    <description>Polling interval of slowly changing values (capacity, cycles, energy counters)</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.OFFLINE.TIME}</macro>
                    <value>5m</value>
                    <description>How long the device may stay silent before a problem is raised</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.AC.FREQ.MIN}</macro>
                    <value>49</value>
                    <description>AC frequency low threshold, Hz</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.AC.FREQ.MAX}</macro>
                    <value>51</value>
                    <description>AC frequency high threshold, Hz</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.DC.VOLTAGE.MIN}</macro>
                    <value>0</value>
                    <description>DC voltage low threshold, V (0 = disabled). Per port: {$MIRCA.DC.VOLTAGE.MIN:"p1"}</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.DC.VOLTAGE.MAX}</macro>
                    <value>0</value>
                    <description>DC voltage high threshold, V (0 = disabled). Per port: {$MIRCA.DC.VOLTAGE.MAX:"p1"}</description>
                </macro>
            </macros>
        </template>
        <template>
            <template>MiRCA Port 2 Victron VE.Bus</template>
            <name>MiRCA Port 2 Victron VE.Bus</name>
            <description>MiRCA serial port 2 running the 'Victron VE.Bus' protocol (protocol id 1). SNMP v2c over the Ethernet interface, tree .1.3.6.1.4.1.2021.13.16.4.2.2 (doc/ports.md). Link 'MiRCA Device' too. Victron Multiplus / Quattro, passive listening on VE.Bus.</description>
            <groups>
                <group>
                    <name>Templates/MiRCA</name>
                </group>
            </groups>
            <applications>
                <application>
                    <name>Port 2</name>
                </application>
                <application>
                    <name>Inverter</name>
                </application>
            </applications>
            <items>
                <item>
                    <name>Port 2: protocol</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.1</snmp_oid>
                    <key>mirca.p2.protocol</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>UNSIGNED</value_type>
                    <description>Protocol configured on the port</description>
                    <applications>
                        <application>
                            <name>Port 2</name>
                        </application>
                    </applications>
                    <valuemap>
                        <name>MiRCA protocol</name>
                    </valuemap>
                </item>
                <item>
                    <name>Port 2: online</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.2</snmp_oid>
                    <key>mirca.p2.online</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>UNSIGNED</value_type>
                    <description>1 while the device answers. All values read 0 while it is offline.</description>
                    <applications>
                        <application>
                            <name>Port 2</name>
                        </application>
                    </applications>
                    <valuemap>
                        <name>MiRCA online</name>
                    </valuemap>
                </item>
                <item>
                    <name>Port 2: seconds since last reply</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.3</snmp_oid>
                    <key>mirca.p2.age</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>s</units>
                    <description>-1: no reply since boot</description>
                    <applications>
                        <application>
                            <name>Port 2</name>
                        </application>
                    </applications>
                </item>
                <item>
                    <name>Port 2: DC voltage</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.30</snmp_oid>
                    <key>mirca.p2.dc_voltage</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>V</units>
                    <applications>
                        <application>
                            <name>Inverter</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.01</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 2: DC current</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.31</snmp_oid>
                    <key>mirca.p2.dc_current</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>A</units>
                    <applications>
                        <application>
                            <name>Inverter</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.01</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 2: AC frequency</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.32</snmp_oid>
                    <key>mirca.p2.ac_frequency</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>Hz</units>
                    <applications>
                        <application>
                            <name>Inverter</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.01</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 2: power factor</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.33</snmp_oid>
                    <key>mirca.p2.power_factor</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <applications>
                        <application>
                            <name>Inverter</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.01</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 2: DC power (calculated)</name>
                    <type>CALCULATED</type>
                    <key>mirca.p2.dc_power.calc</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>W</units>
                    <params>last(mirca.p2.dc_voltage)*last(mirca.p2.dc_current)</params>
                    <applications>
                        <application>
                            <name>Inverter</name>
                        </application>
                    </applications>
                </item>
            </items>
            <macros>
                <macro>
                    <macro>{$MIRCA.INTERVAL}</macro>
                    <value>30s</value>
                    <description>Polling interval of live values</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.INTERVAL.SLOW}</macro>
                    <value>5m</value>
                    <description>Polling interval of slowly changing values (capacity, cycles, energy counters)</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.OFFLINE.TIME}</macro>
                    <value>5m</value>
                    <description>How long the device may stay silent before a problem is raised</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.AC.FREQ.MIN}</macro>
                    <value>49</value>
                    <description>AC frequency low threshold, Hz</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.AC.FREQ.MAX}</macro>
                    <value>51</value>
                    <description>AC frequency high threshold, Hz</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.DC.VOLTAGE.MIN}</macro>
                    <value>0</value>
                    <description>DC voltage low threshold, V (0 = disabled). Per port: {$MIRCA.DC.VOLTAGE.MIN:"p1"}</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.DC.VOLTAGE.MAX}</macro>
                    <value>0</value>
                    <description>DC voltage high threshold, V (0 = disabled). Per port: {$MIRCA.DC.VOLTAGE.MAX:"p1"}</description>
                </macro>
            </macros>
        </template>
        <template>
            <template>MiRCA Port 1 JK BMS parallel bus</template>
            <name>MiRCA Port 1 JK BMS parallel bus</name>
            <description>MiRCA serial port 1 running the 'JK BMS parallel bus' protocol (protocol id 8). SNMP v2c over the Ethernet interface, tree .1.3.6.1.4.1.2021.13.16.4.2.1 (doc/ports.md). Link 'MiRCA Device' too. Listens on the RS485 parallel bus of JK-PB batteries (never transmits). Port values are the group summary; every battery on the bus is discovered (.50.&lt;address+1&gt;). Battery N+1 = bus address N, Battery 1 = master.</description>
            <groups>
                <group>
                    <name>Templates/MiRCA</name>
                </group>
            </groups>
            <applications>
                <application>
                    <name>Port 1</name>
                </application>
                <application>
                    <name>Battery</name>
                </application>
                <application>
                    <name>Batteries</name>
                </application>
                <application>
                    <name>Cells</name>
                </application>
                <application>
                    <name>Temperature</name>
                </application>
            </applications>
            <items>
                <item>
                    <name>Port 1: protocol</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.1</snmp_oid>
                    <key>mirca.p1.protocol</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>UNSIGNED</value_type>
                    <description>Protocol configured on the port</description>
                    <applications>
                        <application>
                            <name>Port 1</name>
                        </application>
                    </applications>
                    <valuemap>
                        <name>MiRCA protocol</name>
                    </valuemap>
                </item>
                <item>
                    <name>Port 1: online</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.2</snmp_oid>
                    <key>mirca.p1.online</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>UNSIGNED</value_type>
                    <description>1 while the device answers. All values read 0 while it is offline.</description>
                    <applications>
                        <application>
                            <name>Port 1</name>
                        </application>
                    </applications>
                    <valuemap>
                        <name>MiRCA online</name>
                    </valuemap>
                </item>
                <item>
                    <name>Port 1: seconds since last reply</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.3</snmp_oid>
                    <key>mirca.p1.age</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>s</units>
                    <description>-1: no reply since boot</description>
                    <applications>
                        <application>
                            <name>Port 1</name>
                        </application>
                    </applications>
                </item>
                <item>
                    <name>Port 1: voltage</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.10</snmp_oid>
                    <key>mirca.p1.voltage</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>V</units>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.01</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 1: current</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.11</snmp_oid>
                    <key>mirca.p1.current</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>A</units>
                    <description>+ charging, - discharging</description>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.01</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 1: power</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.12</snmp_oid>
                    <key>mirca.p1.power</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>W</units>
                    <description>+ charging, - discharging</description>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                </item>
                <item>
                    <name>Port 1: SOC</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.13</snmp_oid>
                    <key>mirca.p1.soc</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>%</units>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.1</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 1: remaining capacity</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.15</snmp_oid>
                    <key>mirca.p1.cap_remain</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>Ah</units>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.01</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 1: full capacity</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.16</snmp_oid>
                    <key>mirca.p1.cap_full</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>Ah</units>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.01</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 1: MOSFET temperature</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.18</snmp_oid>
                    <key>mirca.p1.mos_temp</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>°C</units>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.1</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 1: alarm bits</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.19</snmp_oid>
                    <key>mirca.p1.alarms</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>UNSIGNED</value_type>
                    <description>JK alarm bit mask (register 0xA0), see doc/ports.md</description>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>JAVASCRIPT</type>
                            <parameters>
                                <parameter>return (parseInt(value, 10) &gt;&gt;&gt; 0).toString();</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 1: alarms</name>
                    <type>DEPENDENT</type>
                    <key>mirca.p1.alarms.text</key>
                    <delay>0</delay>
                    <history>14d</history>
                    <trends>0</trends>
                    <value_type>CHAR</value_type>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>JAVASCRIPT</type>
                            <parameters>
                                <parameter>var names = ['balance wire resistance too high', 'MOSFET overtemperature', 'cell count mismatch', 'current sensor fault', 'cell overvoltage', 'battery overvoltage', 'charge overcurrent', 'charge short circuit', 'charge overtemperature', 'charge undertemperature', 'internal communication fault', 'cell undervoltage', 'battery undervoltage', 'discharge overcurrent', 'discharge short circuit', 'discharge overtemperature', 'charge MOSFET fault', 'discharge MOSFET fault', 'GPS disconnected', 'change authorization password', 'discharge enable failed', 'battery overtemperature', 'temperature sensor fault'];
var v = parseInt(value, 10) &gt;&gt;&gt; 0, out = [];
for (var i = 0; i &lt; 32; i++)
  if ((v &gt;&gt;&gt; i) &amp; 1) out.push(i &lt; names.length ? names[i] : 'bit ' + i);
return out.length ? out.join(', ') : 'none';</parameter>
                            </parameters>
                        </step>
                        <step>
                            <type>DISCARD_UNCHANGED_HEARTBEAT</type>
                            <parameters>
                                <parameter>1h</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                    <master_item>
                        <key>mirca.p1.alarms</key>
                    </master_item>
                </item>
            </items>
            <discovery_rules>
                <discovery_rule>
                    <name>Port 1: batteries discovery</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>discovery[{#SNMPVALUE},1.3.6.1.4.1.2021.13.16.4.2.1.50]</snmp_oid>
                    <key>mirca.p1.bat.discovery</key>
                    <delay>10m</delay>
                    <lifetime>7d</lifetime>
                    <description>Batteries seen on the parallel bus (the firmware registers their OIDs on the first frame)</description>
                    <item_prototypes>
                        <item_prototype>
                            <name>Port 1: battery {#BAT}: online</name>
                            <type>SNMP_AGENT</type>
                            <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.50.{#BAT}.2</snmp_oid>
                            <key>mirca.p1.bat.online[{#BAT}]</key>
                            <delay>{$MIRCA.INTERVAL}</delay>
                            <history>14d</history>
                            <trends>365d</trends>
                            <value_type>UNSIGNED</value_type>
                            <applications>
                                <application>
                                    <name>Batteries</name>
                                </application>
                            </applications>
                            <valuemap>
                                <name>MiRCA online</name>
                            </valuemap>
                        </item_prototype>
                        <item_prototype>
                            <name>Port 1: battery {#BAT}: seconds since last frame</name>
                            <type>SNMP_AGENT</type>
                            <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.50.{#BAT}.3</snmp_oid>
                            <key>mirca.p1.bat.age[{#BAT}]</key>
                            <delay>{$MIRCA.INTERVAL}</delay>
                            <history>14d</history>
                            <trends>365d</trends>
                            <value_type>FLOAT</value_type>
                            <units>s</units>
                            <applications>
                                <application>
                                    <name>Batteries</name>
                                </application>
                            </applications>
                        </item_prototype>
                        <item_prototype>
                            <name>Port 1: battery {#BAT}: voltage</name>
                            <type>SNMP_AGENT</type>
                            <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.50.{#BAT}.10</snmp_oid>
                            <key>mirca.p1.bat.voltage[{#BAT}]</key>
                            <delay>{$MIRCA.INTERVAL}</delay>
                            <history>14d</history>
                            <trends>365d</trends>
                            <value_type>FLOAT</value_type>
                            <units>V</units>
                            <applications>
                                <application>
                                    <name>Batteries</name>
                                </application>
                            </applications>
                            <preprocessing>
                                <step>
                                    <type>MULTIPLIER</type>
                                    <parameters>
                                        <parameter>0.01</parameter>
                                    </parameters>
                                </step>
                            </preprocessing>
                        </item_prototype>
                        <item_prototype>
                            <name>Port 1: battery {#BAT}: current</name>
                            <type>SNMP_AGENT</type>
                            <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.50.{#BAT}.11</snmp_oid>
                            <key>mirca.p1.bat.current[{#BAT}]</key>
                            <delay>{$MIRCA.INTERVAL}</delay>
                            <history>14d</history>
                            <trends>365d</trends>
                            <value_type>FLOAT</value_type>
                            <units>A</units>
                            <description>+ charging</description>
                            <applications>
                                <application>
                                    <name>Batteries</name>
                                </application>
                            </applications>
                            <preprocessing>
                                <step>
                                    <type>MULTIPLIER</type>
                                    <parameters>
                                        <parameter>0.01</parameter>
                                    </parameters>
                                </step>
                            </preprocessing>
                        </item_prototype>
                        <item_prototype>
                            <name>Port 1: battery {#BAT}: power</name>
                            <type>SNMP_AGENT</type>
                            <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.50.{#BAT}.12</snmp_oid>
                            <key>mirca.p1.bat.power[{#BAT}]</key>
                            <delay>{$MIRCA.INTERVAL}</delay>
                            <history>14d</history>
                            <trends>365d</trends>
                            <value_type>FLOAT</value_type>
                            <units>W</units>
                            <description>+ charging</description>
                            <applications>
                                <application>
                                    <name>Batteries</name>
                                </application>
                            </applications>
                        </item_prototype>
                        <item_prototype>
                            <name>Port 1: battery {#BAT}: SOC</name>
                            <type>SNMP_AGENT</type>
                            <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.50.{#BAT}.13</snmp_oid>
                            <key>mirca.p1.bat.soc[{#BAT}]</key>
                            <delay>{$MIRCA.INTERVAL}</delay>
                            <history>14d</history>
                            <trends>365d</trends>
                            <value_type>FLOAT</value_type>
                            <units>%</units>
                            <applications>
                                <application>
                                    <name>Batteries</name>
                                </application>
                            </applications>
                            <preprocessing>
                                <step>
                                    <type>MULTIPLIER</type>
                                    <parameters>
                                        <parameter>0.1</parameter>
                                    </parameters>
                                </step>
                            </preprocessing>
                        </item_prototype>
                        <item_prototype>
                            <name>Port 1: battery {#BAT}: cycles</name>
                            <type>SNMP_AGENT</type>
                            <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.50.{#BAT}.14</snmp_oid>
                            <key>mirca.p1.bat.cycles[{#BAT}]</key>
                            <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                            <history>14d</history>
                            <trends>365d</trends>
                            <value_type>UNSIGNED</value_type>
                            <applications>
                                <application>
                                    <name>Batteries</name>
                                </application>
                            </applications>
                        </item_prototype>
                        <item_prototype>
                            <name>Port 1: battery {#BAT}: remaining capacity</name>
                            <type>SNMP_AGENT</type>
                            <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.50.{#BAT}.15</snmp_oid>
                            <key>mirca.p1.bat.cap_remain[{#BAT}]</key>
                            <delay>{$MIRCA.INTERVAL}</delay>
                            <history>14d</history>
                            <trends>365d</trends>
                            <value_type>FLOAT</value_type>
                            <units>Ah</units>
                            <applications>
                                <application>
                                    <name>Batteries</name>
                                </application>
                            </applications>
                            <preprocessing>
                                <step>
                                    <type>MULTIPLIER</type>
                                    <parameters>
                                        <parameter>0.01</parameter>
                                    </parameters>
                                </step>
                            </preprocessing>
                        </item_prototype>
                        <item_prototype>
                            <name>Port 1: battery {#BAT}: full capacity</name>
                            <type>SNMP_AGENT</type>
                            <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.50.{#BAT}.16</snmp_oid>
                            <key>mirca.p1.bat.cap_full[{#BAT}]</key>
                            <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                            <history>14d</history>
                            <trends>365d</trends>
                            <value_type>FLOAT</value_type>
                            <units>Ah</units>
                            <applications>
                                <application>
                                    <name>Batteries</name>
                                </application>
                            </applications>
                            <preprocessing>
                                <step>
                                    <type>MULTIPLIER</type>
                                    <parameters>
                                        <parameter>0.01</parameter>
                                    </parameters>
                                </step>
                            </preprocessing>
                        </item_prototype>
                        <item_prototype>
                            <name>Port 1: battery {#BAT}: cell count</name>
                            <type>SNMP_AGENT</type>
                            <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.50.{#BAT}.17</snmp_oid>
                            <key>mirca.p1.bat.cell_count[{#BAT}]</key>
                            <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                            <history>14d</history>
                            <trends>365d</trends>
                            <value_type>UNSIGNED</value_type>
                            <applications>
                                <application>
                                    <name>Batteries</name>
                                </application>
                            </applications>
                        </item_prototype>
                        <item_prototype>
                            <name>Port 1: battery {#BAT}: MOSFET temperature</name>
                            <type>SNMP_AGENT</type>
                            <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.50.{#BAT}.18</snmp_oid>
                            <key>mirca.p1.bat.mos_temp[{#BAT}]</key>
                            <delay>{$MIRCA.INTERVAL}</delay>
                            <history>14d</history>
                            <trends>365d</trends>
                            <value_type>FLOAT</value_type>
                            <units>°C</units>
                            <applications>
                                <application>
                                    <name>Batteries</name>
                                </application>
                            </applications>
                            <preprocessing>
                                <step>
                                    <type>MULTIPLIER</type>
                                    <parameters>
                                        <parameter>0.1</parameter>
                                    </parameters>
                                </step>
                            </preprocessing>
                        </item_prototype>
                        <item_prototype>
                            <name>Port 1: battery {#BAT}: alarm bits</name>
                            <type>SNMP_AGENT</type>
                            <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.50.{#BAT}.19</snmp_oid>
                            <key>mirca.p1.bat.alarms[{#BAT}]</key>
                            <delay>{$MIRCA.INTERVAL}</delay>
                            <history>14d</history>
                            <trends>365d</trends>
                            <value_type>UNSIGNED</value_type>
                            <applications>
                                <application>
                                    <name>Batteries</name>
                                </application>
                            </applications>
                            <preprocessing>
                                <step>
                                    <type>JAVASCRIPT</type>
                                    <parameters>
                                        <parameter>return (parseInt(value, 10) &gt;&gt;&gt; 0).toString();</parameter>
                                    </parameters>
                                </step>
                            </preprocessing>
                        </item_prototype>
                        <item_prototype>
                            <name>Port 1: battery {#BAT}: alarms</name>
                            <type>DEPENDENT</type>
                            <key>mirca.p1.bat.alarms.text[{#BAT}]</key>
                            <delay>0</delay>
                            <history>14d</history>
                            <trends>0</trends>
                            <value_type>CHAR</value_type>
                            <applications>
                                <application>
                                    <name>Batteries</name>
                                </application>
                            </applications>
                            <preprocessing>
                                <step>
                                    <type>JAVASCRIPT</type>
                                    <parameters>
                                        <parameter>var names = ['balance wire resistance too high', 'MOSFET overtemperature', 'cell count mismatch', 'current sensor fault', 'cell overvoltage', 'battery overvoltage', 'charge overcurrent', 'charge short circuit', 'charge overtemperature', 'charge undertemperature', 'internal communication fault', 'cell undervoltage', 'battery undervoltage', 'discharge overcurrent', 'discharge short circuit', 'discharge overtemperature', 'charge MOSFET fault', 'discharge MOSFET fault', 'GPS disconnected', 'change authorization password', 'discharge enable failed', 'battery overtemperature', 'temperature sensor fault'];
var v = parseInt(value, 10) &gt;&gt;&gt; 0, out = [];
for (var i = 0; i &lt; 32; i++)
  if ((v &gt;&gt;&gt; i) &amp; 1) out.push(i &lt; names.length ? names[i] : 'bit ' + i);
return out.length ? out.join(', ') : 'none';</parameter>
                                    </parameters>
                                </step>
                                <step>
                                    <type>DISCARD_UNCHANGED_HEARTBEAT</type>
                                    <parameters>
                                        <parameter>1h</parameter>
                                    </parameters>
                                </step>
                            </preprocessing>
                            <master_item>
                                <key>mirca.p1.bat.alarms[{#BAT}]</key>
                            </master_item>
                        </item_prototype>
                    </item_prototypes>
                    <trigger_prototypes>
                        <trigger_prototype>
                            <expression>{MiRCA Port 1 JK BMS parallel bus:mirca.p1.bat.online[{#BAT}].max({$MIRCA.OFFLINE.TIME})}=0</expression>
                            <name>Port 1: battery {#BAT}: no frames on the parallel bus</name>
                            <priority>AVERAGE</priority>
                            <description>The battery stopped answering the bus master for {$MIRCA.OFFLINE.TIME}.</description>
                        </trigger_prototype>
                        <trigger_prototype>
                            <expression>{MiRCA Port 1 JK BMS parallel bus:mirca.p1.bat.soc[{#BAT}].max(5m)}&lt;{$MIRCA.SOC.CRIT:"p1"} and {MiRCA Port 1 JK BMS parallel bus:mirca.p1.bat.online[{#BAT}].last()}=1</expression>
                            <name>Port 1: battery {#BAT}: SOC is critically low (&lt;{$MIRCA.SOC.CRIT:"p1"}%)</name>
                            <priority>HIGH</priority>
                        </trigger_prototype>
                        <trigger_prototype>
                            <expression>{MiRCA Port 1 JK BMS parallel bus:mirca.p1.bat.soc[{#BAT}].max(5m)}&lt;{$MIRCA.SOC.WARN:"p1"} and {MiRCA Port 1 JK BMS parallel bus:mirca.p1.bat.online[{#BAT}].last()}=1</expression>
                            <name>Port 1: battery {#BAT}: SOC is low (&lt;{$MIRCA.SOC.WARN:"p1"}%)</name>
                            <priority>WARNING</priority>
                            <dependencies>
                                <dependency>
                                    <name>Port 1: battery {#BAT}: SOC is critically low (&lt;{$MIRCA.SOC.CRIT:"p1"}%)</name>
                                    <expression>{MiRCA Port 1 JK BMS parallel bus:mirca.p1.bat.soc[{#BAT}].max(5m)}&lt;{$MIRCA.SOC.CRIT:"p1"} and {MiRCA Port 1 JK BMS parallel bus:mirca.p1.bat.online[{#BAT}].last()}=1</expression>
                                </dependency>
                            </dependencies>
                        </trigger_prototype>
                        <trigger_prototype>
                            <expression>{MiRCA Port 1 JK BMS parallel bus:mirca.p1.bat.mos_temp[{#BAT}].min(5m)}&gt;{$MIRCA.MOS.TEMP.MAX:"p1"} and {MiRCA Port 1 JK BMS parallel bus:mirca.p1.bat.online[{#BAT}].last()}=1</expression>
                            <name>Port 1: battery {#BAT}: MOSFET temperature is high (&gt;{$MIRCA.MOS.TEMP.MAX:"p1"}°C)</name>
                            <priority>AVERAGE</priority>
                        </trigger_prototype>
                        <trigger_prototype>
                            <expression>{MiRCA Port 1 JK BMS parallel bus:mirca.p1.bat.alarms[{#BAT}].band(#1,{$MIRCA.JK.ALARM.MASK})}&lt;&gt;0 and {MiRCA Port 1 JK BMS parallel bus:mirca.p1.bat.alarms.text[{#BAT}].strlen()}&gt;0 and {MiRCA Port 1 JK BMS parallel bus:mirca.p1.bat.online[{#BAT}].last()}=1</expression>
                            <name>Port 1: battery {#BAT}: BMS alarm: {ITEM.LASTVALUE2}</name>
                            <priority>AVERAGE</priority>
                        </trigger_prototype>
                    </trigger_prototypes>
                    <graph_prototypes>
                        <graph_prototype>
                            <name>Port 1: battery {#BAT}: voltage and current</name>
                            <graph_items>
                                <graph_item>
                                    <sortorder>0</sortorder>
                                    <color>1A7C11</color>
                                    <item>
                                        <host>MiRCA Port 1 JK BMS parallel bus</host>
                                        <key>mirca.p1.bat.voltage[{#BAT}]</key>
                                    </item>
                                </graph_item>
                                <graph_item>
                                    <sortorder>1</sortorder>
                                    <color>F63100</color>
                                    <yaxisside>RIGHT</yaxisside>
                                    <item>
                                        <host>MiRCA Port 1 JK BMS parallel bus</host>
                                        <key>mirca.p1.bat.current[{#BAT}]</key>
                                    </item>
                                </graph_item>
                            </graph_items>
                        </graph_prototype>
                        <graph_prototype>
                            <name>Port 1: battery {#BAT}: SOC</name>
                            <graph_items>
                                <graph_item>
                                    <sortorder>0</sortorder>
                                    <color>1A7C11</color>
                                    <item>
                                        <host>MiRCA Port 1 JK BMS parallel bus</host>
                                        <key>mirca.p1.bat.soc[{#BAT}]</key>
                                    </item>
                                </graph_item>
                            </graph_items>
                        </graph_prototype>
                    </graph_prototypes>
                    <preprocessing>
                        <step>
                            <type>JAVASCRIPT</type>
                            <parameters>
                                <parameter>var rows = JSON.parse(value), out = [];
if (!Array.isArray(rows)) rows = rows.data || [];
for (var i = 0; i &lt; rows.length; i++) {
  var m = /^(\d+)\.2$/.exec(rows[i]['{#SNMPINDEX}']);
  if (!m) continue;
  var o = {'{#BAT}': m[1], '{#ADDR}': String(m[1] - 1)};
  out.push(o);
}
return JSON.stringify(out);</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </discovery_rule>
                <discovery_rule>
                    <name>Port 1: battery cells discovery</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>discovery[{#SNMPVALUE},1.3.6.1.4.1.2021.13.16.4.2.1.50]</snmp_oid>
                    <key>mirca.p1.bat.cells.discovery</key>
                    <delay>1h</delay>
                    <lifetime>7d</lifetime>
                    <description>Cells of every battery on the parallel bus</description>
                    <item_prototypes>
                        <item_prototype>
                            <name>Port 1: battery {#BAT}: cell {#CELL} voltage</name>
                            <type>SNMP_AGENT</type>
                            <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.50.{#BAT}.20.{#CELL}</snmp_oid>
                            <key>mirca.p1.bat.cell[{#BAT},{#CELL}]</key>
                            <delay>{$MIRCA.INTERVAL}</delay>
                            <history>14d</history>
                            <trends>365d</trends>
                            <value_type>FLOAT</value_type>
                            <units>V</units>
                            <applications>
                                <application>
                                    <name>Cells</name>
                                </application>
                            </applications>
                            <preprocessing>
                                <step>
                                    <type>MULTIPLIER</type>
                                    <parameters>
                                        <parameter>0.001</parameter>
                                    </parameters>
                                </step>
                            </preprocessing>
                        </item_prototype>
                    </item_prototypes>
                    <trigger_prototypes>
                        <trigger_prototype>
                            <expression>{MiRCA Port 1 JK BMS parallel bus:mirca.p1.bat.cell[{#BAT},{#CELL}].max(2m)}&lt;{$MIRCA.CELL.UV:"p1"} and {MiRCA Port 1 JK BMS parallel bus:mirca.p1.bat.cell[{#BAT},{#CELL}].last()}&gt;0</expression>
                            <name>Port 1: battery {#BAT}: cell {#CELL} undervoltage (&lt;{$MIRCA.CELL.UV:"p1"}V)</name>
                            <priority>HIGH</priority>
                        </trigger_prototype>
                        <trigger_prototype>
                            <expression>{MiRCA Port 1 JK BMS parallel bus:mirca.p1.bat.cell[{#BAT},{#CELL}].min(2m)}&gt;{$MIRCA.CELL.OV:"p1"}</expression>
                            <name>Port 1: battery {#BAT}: cell {#CELL} overvoltage (&gt;{$MIRCA.CELL.OV:"p1"}V)</name>
                            <priority>HIGH</priority>
                        </trigger_prototype>
                    </trigger_prototypes>
                    <preprocessing>
                        <step>
                            <type>JAVASCRIPT</type>
                            <parameters>
                                <parameter>var rows = JSON.parse(value), out = [];
if (!Array.isArray(rows)) rows = rows.data || [];
for (var i = 0; i &lt; rows.length; i++) {
  var m = /^(\d+)\.20\.(\d+)$/.exec(rows[i]['{#SNMPINDEX}']);
  if (!m || rows[i]['{#SNMPVALUE}'] === '0') continue;
  var o = {'{#BAT}': m[1], '{#ADDR}': String(m[1] - 1), '{#CELL}': m[2]};
  out.push(o);
}
return JSON.stringify(out);</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </discovery_rule>
                <discovery_rule>
                    <name>Port 1: battery temperature sensors discovery</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>discovery[{#SNMPVALUE},1.3.6.1.4.1.2021.13.16.4.2.1.50]</snmp_oid>
                    <key>mirca.p1.bat.temps.discovery</key>
                    <delay>1h</delay>
                    <lifetime>7d</lifetime>
                    <description>Temperature sensors of every battery on the parallel bus (non-zero at discovery time)</description>
                    <item_prototypes>
                        <item_prototype>
                            <name>Port 1: battery {#BAT}: temperature T{#SENSOR}</name>
                            <type>SNMP_AGENT</type>
                            <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.50.{#BAT}.21.{#SENSOR}</snmp_oid>
                            <key>mirca.p1.bat.temp[{#BAT},{#SENSOR}]</key>
                            <delay>{$MIRCA.INTERVAL}</delay>
                            <history>14d</history>
                            <trends>365d</trends>
                            <value_type>FLOAT</value_type>
                            <units>°C</units>
                            <applications>
                                <application>
                                    <name>Temperature</name>
                                </application>
                            </applications>
                            <preprocessing>
                                <step>
                                    <type>MULTIPLIER</type>
                                    <parameters>
                                        <parameter>0.1</parameter>
                                    </parameters>
                                </step>
                            </preprocessing>
                        </item_prototype>
                    </item_prototypes>
                    <trigger_prototypes>
                        <trigger_prototype>
                            <expression>{MiRCA Port 1 JK BMS parallel bus:mirca.p1.bat.temp[{#BAT},{#SENSOR}].min(5m)}&gt;{$MIRCA.TEMP.MAX:"p1"}</expression>
                            <name>Port 1: battery {#BAT}: temperature T{#SENSOR} is high (&gt;{$MIRCA.TEMP.MAX:"p1"}°C)</name>
                            <priority>AVERAGE</priority>
                        </trigger_prototype>
                        <trigger_prototype>
                            <expression>{MiRCA Port 1 JK BMS parallel bus:mirca.p1.bat.temp[{#BAT},{#SENSOR}].max(5m)}&lt;{$MIRCA.TEMP.MIN:"p1"} and {MiRCA Port 1 JK BMS parallel bus:mirca.p1.bat.temp[{#BAT},{#SENSOR}].last()}&lt;&gt;0</expression>
                            <name>Port 1: battery {#BAT}: temperature T{#SENSOR} is low (&lt;{$MIRCA.TEMP.MIN:"p1"}°C)</name>
                            <priority>WARNING</priority>
                        </trigger_prototype>
                    </trigger_prototypes>
                    <preprocessing>
                        <step>
                            <type>JAVASCRIPT</type>
                            <parameters>
                                <parameter>var rows = JSON.parse(value), out = [];
if (!Array.isArray(rows)) rows = rows.data || [];
for (var i = 0; i &lt; rows.length; i++) {
  var m = /^(\d+)\.21\.(\d+)$/.exec(rows[i]['{#SNMPINDEX}']);
  if (!m || rows[i]['{#SNMPVALUE}'] === '0') continue;
  var o = {'{#BAT}': m[1], '{#ADDR}': String(m[1] - 1), '{#SENSOR}': m[2]};
  out.push(o);
}
return JSON.stringify(out);</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </discovery_rule>
            </discovery_rules>
            <macros>
                <macro>
                    <macro>{$MIRCA.INTERVAL}</macro>
                    <value>30s</value>
                    <description>Polling interval of live values</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.INTERVAL.SLOW}</macro>
                    <value>5m</value>
                    <description>Polling interval of slowly changing values (capacity, cycles, energy counters)</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.OFFLINE.TIME}</macro>
                    <value>5m</value>
                    <description>How long the device may stay silent before a problem is raised</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.SOC.WARN}</macro>
                    <value>20</value>
                    <description>SOC below this, %, raises a warning. Per port: {$MIRCA.SOC.WARN:"p1"}</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.SOC.CRIT}</macro>
                    <value>10</value>
                    <description>SOC below this, %, raises a high problem. Per port: {$MIRCA.SOC.CRIT:"p1"}</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.CELL.UV}</macro>
                    <value>2.9</value>
                    <description>Cell undervoltage threshold, V (LiFePO4 default). Per port: {$MIRCA.CELL.UV:"p1"}</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.CELL.OV}</macro>
                    <value>3.65</value>
                    <description>Cell overvoltage threshold, V (LiFePO4 default). Per port: {$MIRCA.CELL.OV:"p1"}</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.TEMP.MAX}</macro>
                    <value>50</value>
                    <description>Battery temperature sensor high threshold, °C. Per port: {$MIRCA.TEMP.MAX:"p1"}</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.TEMP.MIN}</macro>
                    <value>0</value>
                    <description>Battery temperature sensor low threshold, °C. Per port: {$MIRCA.TEMP.MIN:"p1"}</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.MOS.TEMP.MAX}</macro>
                    <value>80</value>
                    <description>MOSFET temperature threshold, °C. Per port: {$MIRCA.MOS.TEMP.MAX:"p1"}</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.JK.ALARM.MASK}</macro>
                    <value>7602175</value>
                    <description>JK alarm bits that raise a problem (default: bits 0-22 without 18 'GPS disconnected' and 19 'change authorization password')</description>
                </macro>
            </macros>
        </template>
        <template>
            <template>MiRCA Port 2 JK BMS parallel bus</template>
            <name>MiRCA Port 2 JK BMS parallel bus</name>
            <description>MiRCA serial port 2 running the 'JK BMS parallel bus' protocol (protocol id 8). SNMP v2c over the Ethernet interface, tree .1.3.6.1.4.1.2021.13.16.4.2.2 (doc/ports.md). Link 'MiRCA Device' too. Listens on the RS485 parallel bus of JK-PB batteries (never transmits). Port values are the group summary; every battery on the bus is discovered (.50.&lt;address+1&gt;). Battery N+1 = bus address N, Battery 1 = master.</description>
            <groups>
                <group>
                    <name>Templates/MiRCA</name>
                </group>
            </groups>
            <applications>
                <application>
                    <name>Port 2</name>
                </application>
                <application>
                    <name>Battery</name>
                </application>
                <application>
                    <name>Batteries</name>
                </application>
                <application>
                    <name>Cells</name>
                </application>
                <application>
                    <name>Temperature</name>
                </application>
            </applications>
            <items>
                <item>
                    <name>Port 2: protocol</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.1</snmp_oid>
                    <key>mirca.p2.protocol</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>UNSIGNED</value_type>
                    <description>Protocol configured on the port</description>
                    <applications>
                        <application>
                            <name>Port 2</name>
                        </application>
                    </applications>
                    <valuemap>
                        <name>MiRCA protocol</name>
                    </valuemap>
                </item>
                <item>
                    <name>Port 2: online</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.2</snmp_oid>
                    <key>mirca.p2.online</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>UNSIGNED</value_type>
                    <description>1 while the device answers. All values read 0 while it is offline.</description>
                    <applications>
                        <application>
                            <name>Port 2</name>
                        </application>
                    </applications>
                    <valuemap>
                        <name>MiRCA online</name>
                    </valuemap>
                </item>
                <item>
                    <name>Port 2: seconds since last reply</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.3</snmp_oid>
                    <key>mirca.p2.age</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>s</units>
                    <description>-1: no reply since boot</description>
                    <applications>
                        <application>
                            <name>Port 2</name>
                        </application>
                    </applications>
                </item>
                <item>
                    <name>Port 2: voltage</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.10</snmp_oid>
                    <key>mirca.p2.voltage</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>V</units>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.01</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 2: current</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.11</snmp_oid>
                    <key>mirca.p2.current</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>A</units>
                    <description>+ charging, - discharging</description>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.01</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 2: power</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.12</snmp_oid>
                    <key>mirca.p2.power</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>W</units>
                    <description>+ charging, - discharging</description>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                </item>
                <item>
                    <name>Port 2: SOC</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.13</snmp_oid>
                    <key>mirca.p2.soc</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>%</units>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.1</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 2: remaining capacity</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.15</snmp_oid>
                    <key>mirca.p2.cap_remain</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>Ah</units>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.01</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 2: full capacity</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.16</snmp_oid>
                    <key>mirca.p2.cap_full</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>Ah</units>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.01</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 2: MOSFET temperature</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.18</snmp_oid>
                    <key>mirca.p2.mos_temp</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>°C</units>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>MULTIPLIER</type>
                            <parameters>
                                <parameter>0.1</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 2: alarm bits</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.19</snmp_oid>
                    <key>mirca.p2.alarms</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>UNSIGNED</value_type>
                    <description>JK alarm bit mask (register 0xA0), see doc/ports.md</description>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>JAVASCRIPT</type>
                            <parameters>
                                <parameter>return (parseInt(value, 10) &gt;&gt;&gt; 0).toString();</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </item>
                <item>
                    <name>Port 2: alarms</name>
                    <type>DEPENDENT</type>
                    <key>mirca.p2.alarms.text</key>
                    <delay>0</delay>
                    <history>14d</history>
                    <trends>0</trends>
                    <value_type>CHAR</value_type>
                    <applications>
                        <application>
                            <name>Battery</name>
                        </application>
                    </applications>
                    <preprocessing>
                        <step>
                            <type>JAVASCRIPT</type>
                            <parameters>
                                <parameter>var names = ['balance wire resistance too high', 'MOSFET overtemperature', 'cell count mismatch', 'current sensor fault', 'cell overvoltage', 'battery overvoltage', 'charge overcurrent', 'charge short circuit', 'charge overtemperature', 'charge undertemperature', 'internal communication fault', 'cell undervoltage', 'battery undervoltage', 'discharge overcurrent', 'discharge short circuit', 'discharge overtemperature', 'charge MOSFET fault', 'discharge MOSFET fault', 'GPS disconnected', 'change authorization password', 'discharge enable failed', 'battery overtemperature', 'temperature sensor fault'];
var v = parseInt(value, 10) &gt;&gt;&gt; 0, out = [];
for (var i = 0; i &lt; 32; i++)
  if ((v &gt;&gt;&gt; i) &amp; 1) out.push(i &lt; names.length ? names[i] : 'bit ' + i);
return out.length ? out.join(', ') : 'none';</parameter>
                            </parameters>
                        </step>
                        <step>
                            <type>DISCARD_UNCHANGED_HEARTBEAT</type>
                            <parameters>
                                <parameter>1h</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                    <master_item>
                        <key>mirca.p2.alarms</key>
                    </master_item>
                </item>
            </items>
            <discovery_rules>
                <discovery_rule>
                    <name>Port 2: batteries discovery</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>discovery[{#SNMPVALUE},1.3.6.1.4.1.2021.13.16.4.2.2.50]</snmp_oid>
                    <key>mirca.p2.bat.discovery</key>
                    <delay>10m</delay>
                    <lifetime>7d</lifetime>
                    <description>Batteries seen on the parallel bus (the firmware registers their OIDs on the first frame)</description>
                    <item_prototypes>
                        <item_prototype>
                            <name>Port 2: battery {#BAT}: online</name>
                            <type>SNMP_AGENT</type>
                            <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.50.{#BAT}.2</snmp_oid>
                            <key>mirca.p2.bat.online[{#BAT}]</key>
                            <delay>{$MIRCA.INTERVAL}</delay>
                            <history>14d</history>
                            <trends>365d</trends>
                            <value_type>UNSIGNED</value_type>
                            <applications>
                                <application>
                                    <name>Batteries</name>
                                </application>
                            </applications>
                            <valuemap>
                                <name>MiRCA online</name>
                            </valuemap>
                        </item_prototype>
                        <item_prototype>
                            <name>Port 2: battery {#BAT}: seconds since last frame</name>
                            <type>SNMP_AGENT</type>
                            <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.50.{#BAT}.3</snmp_oid>
                            <key>mirca.p2.bat.age[{#BAT}]</key>
                            <delay>{$MIRCA.INTERVAL}</delay>
                            <history>14d</history>
                            <trends>365d</trends>
                            <value_type>FLOAT</value_type>
                            <units>s</units>
                            <applications>
                                <application>
                                    <name>Batteries</name>
                                </application>
                            </applications>
                        </item_prototype>
                        <item_prototype>
                            <name>Port 2: battery {#BAT}: voltage</name>
                            <type>SNMP_AGENT</type>
                            <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.50.{#BAT}.10</snmp_oid>
                            <key>mirca.p2.bat.voltage[{#BAT}]</key>
                            <delay>{$MIRCA.INTERVAL}</delay>
                            <history>14d</history>
                            <trends>365d</trends>
                            <value_type>FLOAT</value_type>
                            <units>V</units>
                            <applications>
                                <application>
                                    <name>Batteries</name>
                                </application>
                            </applications>
                            <preprocessing>
                                <step>
                                    <type>MULTIPLIER</type>
                                    <parameters>
                                        <parameter>0.01</parameter>
                                    </parameters>
                                </step>
                            </preprocessing>
                        </item_prototype>
                        <item_prototype>
                            <name>Port 2: battery {#BAT}: current</name>
                            <type>SNMP_AGENT</type>
                            <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.50.{#BAT}.11</snmp_oid>
                            <key>mirca.p2.bat.current[{#BAT}]</key>
                            <delay>{$MIRCA.INTERVAL}</delay>
                            <history>14d</history>
                            <trends>365d</trends>
                            <value_type>FLOAT</value_type>
                            <units>A</units>
                            <description>+ charging</description>
                            <applications>
                                <application>
                                    <name>Batteries</name>
                                </application>
                            </applications>
                            <preprocessing>
                                <step>
                                    <type>MULTIPLIER</type>
                                    <parameters>
                                        <parameter>0.01</parameter>
                                    </parameters>
                                </step>
                            </preprocessing>
                        </item_prototype>
                        <item_prototype>
                            <name>Port 2: battery {#BAT}: power</name>
                            <type>SNMP_AGENT</type>
                            <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.50.{#BAT}.12</snmp_oid>
                            <key>mirca.p2.bat.power[{#BAT}]</key>
                            <delay>{$MIRCA.INTERVAL}</delay>
                            <history>14d</history>
                            <trends>365d</trends>
                            <value_type>FLOAT</value_type>
                            <units>W</units>
                            <description>+ charging</description>
                            <applications>
                                <application>
                                    <name>Batteries</name>
                                </application>
                            </applications>
                        </item_prototype>
                        <item_prototype>
                            <name>Port 2: battery {#BAT}: SOC</name>
                            <type>SNMP_AGENT</type>
                            <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.50.{#BAT}.13</snmp_oid>
                            <key>mirca.p2.bat.soc[{#BAT}]</key>
                            <delay>{$MIRCA.INTERVAL}</delay>
                            <history>14d</history>
                            <trends>365d</trends>
                            <value_type>FLOAT</value_type>
                            <units>%</units>
                            <applications>
                                <application>
                                    <name>Batteries</name>
                                </application>
                            </applications>
                            <preprocessing>
                                <step>
                                    <type>MULTIPLIER</type>
                                    <parameters>
                                        <parameter>0.1</parameter>
                                    </parameters>
                                </step>
                            </preprocessing>
                        </item_prototype>
                        <item_prototype>
                            <name>Port 2: battery {#BAT}: cycles</name>
                            <type>SNMP_AGENT</type>
                            <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.50.{#BAT}.14</snmp_oid>
                            <key>mirca.p2.bat.cycles[{#BAT}]</key>
                            <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                            <history>14d</history>
                            <trends>365d</trends>
                            <value_type>UNSIGNED</value_type>
                            <applications>
                                <application>
                                    <name>Batteries</name>
                                </application>
                            </applications>
                        </item_prototype>
                        <item_prototype>
                            <name>Port 2: battery {#BAT}: remaining capacity</name>
                            <type>SNMP_AGENT</type>
                            <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.50.{#BAT}.15</snmp_oid>
                            <key>mirca.p2.bat.cap_remain[{#BAT}]</key>
                            <delay>{$MIRCA.INTERVAL}</delay>
                            <history>14d</history>
                            <trends>365d</trends>
                            <value_type>FLOAT</value_type>
                            <units>Ah</units>
                            <applications>
                                <application>
                                    <name>Batteries</name>
                                </application>
                            </applications>
                            <preprocessing>
                                <step>
                                    <type>MULTIPLIER</type>
                                    <parameters>
                                        <parameter>0.01</parameter>
                                    </parameters>
                                </step>
                            </preprocessing>
                        </item_prototype>
                        <item_prototype>
                            <name>Port 2: battery {#BAT}: full capacity</name>
                            <type>SNMP_AGENT</type>
                            <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.50.{#BAT}.16</snmp_oid>
                            <key>mirca.p2.bat.cap_full[{#BAT}]</key>
                            <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                            <history>14d</history>
                            <trends>365d</trends>
                            <value_type>FLOAT</value_type>
                            <units>Ah</units>
                            <applications>
                                <application>
                                    <name>Batteries</name>
                                </application>
                            </applications>
                            <preprocessing>
                                <step>
                                    <type>MULTIPLIER</type>
                                    <parameters>
                                        <parameter>0.01</parameter>
                                    </parameters>
                                </step>
                            </preprocessing>
                        </item_prototype>
                        <item_prototype>
                            <name>Port 2: battery {#BAT}: cell count</name>
                            <type>SNMP_AGENT</type>
                            <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.50.{#BAT}.17</snmp_oid>
                            <key>mirca.p2.bat.cell_count[{#BAT}]</key>
                            <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                            <history>14d</history>
                            <trends>365d</trends>
                            <value_type>UNSIGNED</value_type>
                            <applications>
                                <application>
                                    <name>Batteries</name>
                                </application>
                            </applications>
                        </item_prototype>
                        <item_prototype>
                            <name>Port 2: battery {#BAT}: MOSFET temperature</name>
                            <type>SNMP_AGENT</type>
                            <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.50.{#BAT}.18</snmp_oid>
                            <key>mirca.p2.bat.mos_temp[{#BAT}]</key>
                            <delay>{$MIRCA.INTERVAL}</delay>
                            <history>14d</history>
                            <trends>365d</trends>
                            <value_type>FLOAT</value_type>
                            <units>°C</units>
                            <applications>
                                <application>
                                    <name>Batteries</name>
                                </application>
                            </applications>
                            <preprocessing>
                                <step>
                                    <type>MULTIPLIER</type>
                                    <parameters>
                                        <parameter>0.1</parameter>
                                    </parameters>
                                </step>
                            </preprocessing>
                        </item_prototype>
                        <item_prototype>
                            <name>Port 2: battery {#BAT}: alarm bits</name>
                            <type>SNMP_AGENT</type>
                            <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.50.{#BAT}.19</snmp_oid>
                            <key>mirca.p2.bat.alarms[{#BAT}]</key>
                            <delay>{$MIRCA.INTERVAL}</delay>
                            <history>14d</history>
                            <trends>365d</trends>
                            <value_type>UNSIGNED</value_type>
                            <applications>
                                <application>
                                    <name>Batteries</name>
                                </application>
                            </applications>
                            <preprocessing>
                                <step>
                                    <type>JAVASCRIPT</type>
                                    <parameters>
                                        <parameter>return (parseInt(value, 10) &gt;&gt;&gt; 0).toString();</parameter>
                                    </parameters>
                                </step>
                            </preprocessing>
                        </item_prototype>
                        <item_prototype>
                            <name>Port 2: battery {#BAT}: alarms</name>
                            <type>DEPENDENT</type>
                            <key>mirca.p2.bat.alarms.text[{#BAT}]</key>
                            <delay>0</delay>
                            <history>14d</history>
                            <trends>0</trends>
                            <value_type>CHAR</value_type>
                            <applications>
                                <application>
                                    <name>Batteries</name>
                                </application>
                            </applications>
                            <preprocessing>
                                <step>
                                    <type>JAVASCRIPT</type>
                                    <parameters>
                                        <parameter>var names = ['balance wire resistance too high', 'MOSFET overtemperature', 'cell count mismatch', 'current sensor fault', 'cell overvoltage', 'battery overvoltage', 'charge overcurrent', 'charge short circuit', 'charge overtemperature', 'charge undertemperature', 'internal communication fault', 'cell undervoltage', 'battery undervoltage', 'discharge overcurrent', 'discharge short circuit', 'discharge overtemperature', 'charge MOSFET fault', 'discharge MOSFET fault', 'GPS disconnected', 'change authorization password', 'discharge enable failed', 'battery overtemperature', 'temperature sensor fault'];
var v = parseInt(value, 10) &gt;&gt;&gt; 0, out = [];
for (var i = 0; i &lt; 32; i++)
  if ((v &gt;&gt;&gt; i) &amp; 1) out.push(i &lt; names.length ? names[i] : 'bit ' + i);
return out.length ? out.join(', ') : 'none';</parameter>
                                    </parameters>
                                </step>
                                <step>
                                    <type>DISCARD_UNCHANGED_HEARTBEAT</type>
                                    <parameters>
                                        <parameter>1h</parameter>
                                    </parameters>
                                </step>
                            </preprocessing>
                            <master_item>
                                <key>mirca.p2.bat.alarms[{#BAT}]</key>
                            </master_item>
                        </item_prototype>
                    </item_prototypes>
                    <trigger_prototypes>
                        <trigger_prototype>
                            <expression>{MiRCA Port 2 JK BMS parallel bus:mirca.p2.bat.online[{#BAT}].max({$MIRCA.OFFLINE.TIME})}=0</expression>
                            <name>Port 2: battery {#BAT}: no frames on the parallel bus</name>
                            <priority>AVERAGE</priority>
                            <description>The battery stopped answering the bus master for {$MIRCA.OFFLINE.TIME}.</description>
                        </trigger_prototype>
                        <trigger_prototype>
                            <expression>{MiRCA Port 2 JK BMS parallel bus:mirca.p2.bat.soc[{#BAT}].max(5m)}&lt;{$MIRCA.SOC.CRIT:"p2"} and {MiRCA Port 2 JK BMS parallel bus:mirca.p2.bat.online[{#BAT}].last()}=1</expression>
                            <name>Port 2: battery {#BAT}: SOC is critically low (&lt;{$MIRCA.SOC.CRIT:"p2"}%)</name>
                            <priority>HIGH</priority>
                        </trigger_prototype>
                        <trigger_prototype>
                            <expression>{MiRCA Port 2 JK BMS parallel bus:mirca.p2.bat.soc[{#BAT}].max(5m)}&lt;{$MIRCA.SOC.WARN:"p2"} and {MiRCA Port 2 JK BMS parallel bus:mirca.p2.bat.online[{#BAT}].last()}=1</expression>
                            <name>Port 2: battery {#BAT}: SOC is low (&lt;{$MIRCA.SOC.WARN:"p2"}%)</name>
                            <priority>WARNING</priority>
                            <dependencies>
                                <dependency>
                                    <name>Port 2: battery {#BAT}: SOC is critically low (&lt;{$MIRCA.SOC.CRIT:"p2"}%)</name>
                                    <expression>{MiRCA Port 2 JK BMS parallel bus:mirca.p2.bat.soc[{#BAT}].max(5m)}&lt;{$MIRCA.SOC.CRIT:"p2"} and {MiRCA Port 2 JK BMS parallel bus:mirca.p2.bat.online[{#BAT}].last()}=1</expression>
                                </dependency>
                            </dependencies>
                        </trigger_prototype>
                        <trigger_prototype>
                            <expression>{MiRCA Port 2 JK BMS parallel bus:mirca.p2.bat.mos_temp[{#BAT}].min(5m)}&gt;{$MIRCA.MOS.TEMP.MAX:"p2"} and {MiRCA Port 2 JK BMS parallel bus:mirca.p2.bat.online[{#BAT}].last()}=1</expression>
                            <name>Port 2: battery {#BAT}: MOSFET temperature is high (&gt;{$MIRCA.MOS.TEMP.MAX:"p2"}°C)</name>
                            <priority>AVERAGE</priority>
                        </trigger_prototype>
                        <trigger_prototype>
                            <expression>{MiRCA Port 2 JK BMS parallel bus:mirca.p2.bat.alarms[{#BAT}].band(#1,{$MIRCA.JK.ALARM.MASK})}&lt;&gt;0 and {MiRCA Port 2 JK BMS parallel bus:mirca.p2.bat.alarms.text[{#BAT}].strlen()}&gt;0 and {MiRCA Port 2 JK BMS parallel bus:mirca.p2.bat.online[{#BAT}].last()}=1</expression>
                            <name>Port 2: battery {#BAT}: BMS alarm: {ITEM.LASTVALUE2}</name>
                            <priority>AVERAGE</priority>
                        </trigger_prototype>
                    </trigger_prototypes>
                    <graph_prototypes>
                        <graph_prototype>
                            <name>Port 2: battery {#BAT}: voltage and current</name>
                            <graph_items>
                                <graph_item>
                                    <sortorder>0</sortorder>
                                    <color>1A7C11</color>
                                    <item>
                                        <host>MiRCA Port 2 JK BMS parallel bus</host>
                                        <key>mirca.p2.bat.voltage[{#BAT}]</key>
                                    </item>
                                </graph_item>
                                <graph_item>
                                    <sortorder>1</sortorder>
                                    <color>F63100</color>
                                    <yaxisside>RIGHT</yaxisside>
                                    <item>
                                        <host>MiRCA Port 2 JK BMS parallel bus</host>
                                        <key>mirca.p2.bat.current[{#BAT}]</key>
                                    </item>
                                </graph_item>
                            </graph_items>
                        </graph_prototype>
                        <graph_prototype>
                            <name>Port 2: battery {#BAT}: SOC</name>
                            <graph_items>
                                <graph_item>
                                    <sortorder>0</sortorder>
                                    <color>1A7C11</color>
                                    <item>
                                        <host>MiRCA Port 2 JK BMS parallel bus</host>
                                        <key>mirca.p2.bat.soc[{#BAT}]</key>
                                    </item>
                                </graph_item>
                            </graph_items>
                        </graph_prototype>
                    </graph_prototypes>
                    <preprocessing>
                        <step>
                            <type>JAVASCRIPT</type>
                            <parameters>
                                <parameter>var rows = JSON.parse(value), out = [];
if (!Array.isArray(rows)) rows = rows.data || [];
for (var i = 0; i &lt; rows.length; i++) {
  var m = /^(\d+)\.2$/.exec(rows[i]['{#SNMPINDEX}']);
  if (!m) continue;
  var o = {'{#BAT}': m[1], '{#ADDR}': String(m[1] - 1)};
  out.push(o);
}
return JSON.stringify(out);</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </discovery_rule>
                <discovery_rule>
                    <name>Port 2: battery cells discovery</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>discovery[{#SNMPVALUE},1.3.6.1.4.1.2021.13.16.4.2.2.50]</snmp_oid>
                    <key>mirca.p2.bat.cells.discovery</key>
                    <delay>1h</delay>
                    <lifetime>7d</lifetime>
                    <description>Cells of every battery on the parallel bus</description>
                    <item_prototypes>
                        <item_prototype>
                            <name>Port 2: battery {#BAT}: cell {#CELL} voltage</name>
                            <type>SNMP_AGENT</type>
                            <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.50.{#BAT}.20.{#CELL}</snmp_oid>
                            <key>mirca.p2.bat.cell[{#BAT},{#CELL}]</key>
                            <delay>{$MIRCA.INTERVAL}</delay>
                            <history>14d</history>
                            <trends>365d</trends>
                            <value_type>FLOAT</value_type>
                            <units>V</units>
                            <applications>
                                <application>
                                    <name>Cells</name>
                                </application>
                            </applications>
                            <preprocessing>
                                <step>
                                    <type>MULTIPLIER</type>
                                    <parameters>
                                        <parameter>0.001</parameter>
                                    </parameters>
                                </step>
                            </preprocessing>
                        </item_prototype>
                    </item_prototypes>
                    <trigger_prototypes>
                        <trigger_prototype>
                            <expression>{MiRCA Port 2 JK BMS parallel bus:mirca.p2.bat.cell[{#BAT},{#CELL}].max(2m)}&lt;{$MIRCA.CELL.UV:"p2"} and {MiRCA Port 2 JK BMS parallel bus:mirca.p2.bat.cell[{#BAT},{#CELL}].last()}&gt;0</expression>
                            <name>Port 2: battery {#BAT}: cell {#CELL} undervoltage (&lt;{$MIRCA.CELL.UV:"p2"}V)</name>
                            <priority>HIGH</priority>
                        </trigger_prototype>
                        <trigger_prototype>
                            <expression>{MiRCA Port 2 JK BMS parallel bus:mirca.p2.bat.cell[{#BAT},{#CELL}].min(2m)}&gt;{$MIRCA.CELL.OV:"p2"}</expression>
                            <name>Port 2: battery {#BAT}: cell {#CELL} overvoltage (&gt;{$MIRCA.CELL.OV:"p2"}V)</name>
                            <priority>HIGH</priority>
                        </trigger_prototype>
                    </trigger_prototypes>
                    <preprocessing>
                        <step>
                            <type>JAVASCRIPT</type>
                            <parameters>
                                <parameter>var rows = JSON.parse(value), out = [];
if (!Array.isArray(rows)) rows = rows.data || [];
for (var i = 0; i &lt; rows.length; i++) {
  var m = /^(\d+)\.20\.(\d+)$/.exec(rows[i]['{#SNMPINDEX}']);
  if (!m || rows[i]['{#SNMPVALUE}'] === '0') continue;
  var o = {'{#BAT}': m[1], '{#ADDR}': String(m[1] - 1), '{#CELL}': m[2]};
  out.push(o);
}
return JSON.stringify(out);</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </discovery_rule>
                <discovery_rule>
                    <name>Port 2: battery temperature sensors discovery</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>discovery[{#SNMPVALUE},1.3.6.1.4.1.2021.13.16.4.2.2.50]</snmp_oid>
                    <key>mirca.p2.bat.temps.discovery</key>
                    <delay>1h</delay>
                    <lifetime>7d</lifetime>
                    <description>Temperature sensors of every battery on the parallel bus (non-zero at discovery time)</description>
                    <item_prototypes>
                        <item_prototype>
                            <name>Port 2: battery {#BAT}: temperature T{#SENSOR}</name>
                            <type>SNMP_AGENT</type>
                            <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.50.{#BAT}.21.{#SENSOR}</snmp_oid>
                            <key>mirca.p2.bat.temp[{#BAT},{#SENSOR}]</key>
                            <delay>{$MIRCA.INTERVAL}</delay>
                            <history>14d</history>
                            <trends>365d</trends>
                            <value_type>FLOAT</value_type>
                            <units>°C</units>
                            <applications>
                                <application>
                                    <name>Temperature</name>
                                </application>
                            </applications>
                            <preprocessing>
                                <step>
                                    <type>MULTIPLIER</type>
                                    <parameters>
                                        <parameter>0.1</parameter>
                                    </parameters>
                                </step>
                            </preprocessing>
                        </item_prototype>
                    </item_prototypes>
                    <trigger_prototypes>
                        <trigger_prototype>
                            <expression>{MiRCA Port 2 JK BMS parallel bus:mirca.p2.bat.temp[{#BAT},{#SENSOR}].min(5m)}&gt;{$MIRCA.TEMP.MAX:"p2"}</expression>
                            <name>Port 2: battery {#BAT}: temperature T{#SENSOR} is high (&gt;{$MIRCA.TEMP.MAX:"p2"}°C)</name>
                            <priority>AVERAGE</priority>
                        </trigger_prototype>
                        <trigger_prototype>
                            <expression>{MiRCA Port 2 JK BMS parallel bus:mirca.p2.bat.temp[{#BAT},{#SENSOR}].max(5m)}&lt;{$MIRCA.TEMP.MIN:"p2"} and {MiRCA Port 2 JK BMS parallel bus:mirca.p2.bat.temp[{#BAT},{#SENSOR}].last()}&lt;&gt;0</expression>
                            <name>Port 2: battery {#BAT}: temperature T{#SENSOR} is low (&lt;{$MIRCA.TEMP.MIN:"p2"}°C)</name>
                            <priority>WARNING</priority>
                        </trigger_prototype>
                    </trigger_prototypes>
                    <preprocessing>
                        <step>
                            <type>JAVASCRIPT</type>
                            <parameters>
                                <parameter>var rows = JSON.parse(value), out = [];
if (!Array.isArray(rows)) rows = rows.data || [];
for (var i = 0; i &lt; rows.length; i++) {
  var m = /^(\d+)\.21\.(\d+)$/.exec(rows[i]['{#SNMPINDEX}']);
  if (!m || rows[i]['{#SNMPVALUE}'] === '0') continue;
  var o = {'{#BAT}': m[1], '{#ADDR}': String(m[1] - 1), '{#SENSOR}': m[2]};
  out.push(o);
}
return JSON.stringify(out);</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                </discovery_rule>
            </discovery_rules>
            <macros>
                <macro>
                    <macro>{$MIRCA.INTERVAL}</macro>
                    <value>30s</value>
                    <description>Polling interval of live values</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.INTERVAL.SLOW}</macro>
                    <value>5m</value>
                    <description>Polling interval of slowly changing values (capacity, cycles, energy counters)</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.OFFLINE.TIME}</macro>
                    <value>5m</value>
                    <description>How long the device may stay silent before a problem is raised</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.SOC.WARN}</macro>
                    <value>20</value>
                    <description>SOC below this, %, raises a warning. Per port: {$MIRCA.SOC.WARN:"p1"}</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.SOC.CRIT}</macro>
                    <value>10</value>
                    <description>SOC below this, %, raises a high problem. Per port: {$MIRCA.SOC.CRIT:"p1"}</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.CELL.UV}</macro>
                    <value>2.9</value>
                    <description>Cell undervoltage threshold, V (LiFePO4 default). Per port: {$MIRCA.CELL.UV:"p1"}</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.CELL.OV}</macro>
                    <value>3.65</value>
                    <description>Cell overvoltage threshold, V (LiFePO4 default). Per port: {$MIRCA.CELL.OV:"p1"}</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.TEMP.MAX}</macro>
                    <value>50</value>
                    <description>Battery temperature sensor high threshold, °C. Per port: {$MIRCA.TEMP.MAX:"p1"}</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.TEMP.MIN}</macro>
                    <value>0</value>
                    <description>Battery temperature sensor low threshold, °C. Per port: {$MIRCA.TEMP.MIN:"p1"}</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.MOS.TEMP.MAX}</macro>
                    <value>80</value>
                    <description>MOSFET temperature threshold, °C. Per port: {$MIRCA.MOS.TEMP.MAX:"p1"}</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.JK.ALARM.MASK}</macro>
                    <value>7602175</value>
                    <description>JK alarm bits that raise a problem (default: bits 0-22 without 18 'GPS disconnected' and 19 'change authorization password')</description>
                </macro>
            </macros>
        </template>
        <template>
            <template>MiRCA Port 1 Serial capture</template>
            <name>MiRCA Port 1 Serial capture</name>
            <description>MiRCA serial port 1 running the 'Serial capture' protocol (protocol id 7). SNMP v2c over the Ethernet interface, tree .1.3.6.1.4.1.2021.13.16.4.2.1 (doc/ports.md). Link 'MiRCA Device' too. Diagnostic recording of raw serial traffic (listen only). The recording itself is downloaded from /api/capture?port=N.</description>
            <groups>
                <group>
                    <name>Templates/MiRCA</name>
                </group>
            </groups>
            <applications>
                <application>
                    <name>Port 1</name>
                </application>
                <application>
                    <name>Capture</name>
                </application>
            </applications>
            <items>
                <item>
                    <name>Port 1: protocol</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.1</snmp_oid>
                    <key>mirca.p1.protocol</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>UNSIGNED</value_type>
                    <description>Protocol configured on the port</description>
                    <applications>
                        <application>
                            <name>Port 1</name>
                        </application>
                    </applications>
                    <valuemap>
                        <name>MiRCA protocol</name>
                    </valuemap>
                </item>
                <item>
                    <name>Port 1: online</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.2</snmp_oid>
                    <key>mirca.p1.online</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>UNSIGNED</value_type>
                    <description>1 while the device answers. All values read 0 while it is offline.</description>
                    <applications>
                        <application>
                            <name>Port 1</name>
                        </application>
                    </applications>
                    <valuemap>
                        <name>MiRCA online</name>
                    </valuemap>
                </item>
                <item>
                    <name>Port 1: seconds since last reply</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.3</snmp_oid>
                    <key>mirca.p1.age</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>s</units>
                    <description>-1: no reply since boot</description>
                    <applications>
                        <application>
                            <name>Port 1</name>
                        </application>
                    </applications>
                </item>
                <item>
                    <name>Port 1: Bytes received</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.40.1</snmp_oid>
                    <key>mirca.p1.m[bytes]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <description>Metric 1 'bytes'</description>
                    <applications>
                        <application>
                            <name>Capture</name>
                        </application>
                    </applications>
                </item>
                <item>
                    <name>Port 1: Frames recorded</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.40.2</snmp_oid>
                    <key>mirca.p1.m[frames]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <description>Metric 2 'frames'</description>
                    <applications>
                        <application>
                            <name>Capture</name>
                        </application>
                    </applications>
                </item>
                <item>
                    <name>Port 1: Buffer used</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.40.3</snmp_oid>
                    <key>mirca.p1.m[buffer_used]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>%</units>
                    <description>Metric 3 'buffer_used'</description>
                    <applications>
                        <application>
                            <name>Capture</name>
                        </application>
                    </applications>
                </item>
                <item>
                    <name>Port 1: Frames not recorded (buffer full)</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.1.40.4</snmp_oid>
                    <key>mirca.p1.m[frames_dropped]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <description>Metric 4 'frames_dropped'</description>
                    <applications>
                        <application>
                            <name>Capture</name>
                        </application>
                    </applications>
                </item>
            </items>
            <macros>
                <macro>
                    <macro>{$MIRCA.INTERVAL}</macro>
                    <value>30s</value>
                    <description>Polling interval of live values</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.INTERVAL.SLOW}</macro>
                    <value>5m</value>
                    <description>Polling interval of slowly changing values (capacity, cycles, energy counters)</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.OFFLINE.TIME}</macro>
                    <value>5m</value>
                    <description>How long the device may stay silent before a problem is raised</description>
                </macro>
            </macros>
        </template>
        <template>
            <template>MiRCA Port 2 Serial capture</template>
            <name>MiRCA Port 2 Serial capture</name>
            <description>MiRCA serial port 2 running the 'Serial capture' protocol (protocol id 7). SNMP v2c over the Ethernet interface, tree .1.3.6.1.4.1.2021.13.16.4.2.2 (doc/ports.md). Link 'MiRCA Device' too. Diagnostic recording of raw serial traffic (listen only). The recording itself is downloaded from /api/capture?port=N.</description>
            <groups>
                <group>
                    <name>Templates/MiRCA</name>
                </group>
            </groups>
            <applications>
                <application>
                    <name>Port 2</name>
                </application>
                <application>
                    <name>Capture</name>
                </application>
            </applications>
            <items>
                <item>
                    <name>Port 2: protocol</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.1</snmp_oid>
                    <key>mirca.p2.protocol</key>
                    <delay>{$MIRCA.INTERVAL.SLOW}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>UNSIGNED</value_type>
                    <description>Protocol configured on the port</description>
                    <applications>
                        <application>
                            <name>Port 2</name>
                        </application>
                    </applications>
                    <valuemap>
                        <name>MiRCA protocol</name>
                    </valuemap>
                </item>
                <item>
                    <name>Port 2: online</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.2</snmp_oid>
                    <key>mirca.p2.online</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>UNSIGNED</value_type>
                    <description>1 while the device answers. All values read 0 while it is offline.</description>
                    <applications>
                        <application>
                            <name>Port 2</name>
                        </application>
                    </applications>
                    <valuemap>
                        <name>MiRCA online</name>
                    </valuemap>
                </item>
                <item>
                    <name>Port 2: seconds since last reply</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.3</snmp_oid>
                    <key>mirca.p2.age</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>s</units>
                    <description>-1: no reply since boot</description>
                    <applications>
                        <application>
                            <name>Port 2</name>
                        </application>
                    </applications>
                </item>
                <item>
                    <name>Port 2: Bytes received</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.40.1</snmp_oid>
                    <key>mirca.p2.m[bytes]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <description>Metric 1 'bytes'</description>
                    <applications>
                        <application>
                            <name>Capture</name>
                        </application>
                    </applications>
                </item>
                <item>
                    <name>Port 2: Frames recorded</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.40.2</snmp_oid>
                    <key>mirca.p2.m[frames]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <description>Metric 2 'frames'</description>
                    <applications>
                        <application>
                            <name>Capture</name>
                        </application>
                    </applications>
                </item>
                <item>
                    <name>Port 2: Buffer used</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.40.3</snmp_oid>
                    <key>mirca.p2.m[buffer_used]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <units>%</units>
                    <description>Metric 3 'buffer_used'</description>
                    <applications>
                        <application>
                            <name>Capture</name>
                        </application>
                    </applications>
                </item>
                <item>
                    <name>Port 2: Frames not recorded (buffer full)</name>
                    <type>SNMP_AGENT</type>
                    <snmp_oid>1.3.6.1.4.1.2021.13.16.4.2.2.40.4</snmp_oid>
                    <key>mirca.p2.m[frames_dropped]</key>
                    <delay>{$MIRCA.INTERVAL}</delay>
                    <history>14d</history>
                    <trends>365d</trends>
                    <value_type>FLOAT</value_type>
                    <description>Metric 4 'frames_dropped'</description>
                    <applications>
                        <application>
                            <name>Capture</name>
                        </application>
                    </applications>
                </item>
            </items>
            <macros>
                <macro>
                    <macro>{$MIRCA.INTERVAL}</macro>
                    <value>30s</value>
                    <description>Polling interval of live values</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.INTERVAL.SLOW}</macro>
                    <value>5m</value>
                    <description>Polling interval of slowly changing values (capacity, cycles, energy counters)</description>
                </macro>
                <macro>
                    <macro>{$MIRCA.OFFLINE.TIME}</macro>
                    <value>5m</value>
                    <description>How long the device may stay silent before a problem is raised</description>
                </macro>
            </macros>
        </template>
    </templates>
    <triggers>
        <trigger>
            <expression>{MiRCA Device:mirca.ds18b20.nodata({$MIRCA.NODATA.TIME})}=1</expression>
            <name>MiRCA: no SNMP data for {$MIRCA.NODATA.TIME}</name>
            <priority>AVERAGE</priority>
            <description>SNMP is served on the Ethernet port only. Check the cable, the IP address, the community and that SNMP is enabled in the settings.</description>
        </trigger>
        <trigger>
            <expression>{MiRCA Device:mirca.ds18b20.last()}&lt;=-127</expression>
            <name>MiRCA: DS18B20 sensor not connected</name>
            <priority>WARNING</priority>
        </trigger>
        <trigger>
            <expression>{MiRCA Device:mirca.ds18b20.min(5m)}&gt;{$MIRCA.BOARD.TEMP.MAX}</expression>
            <name>MiRCA: board temperature is high (&gt;{$MIRCA.BOARD.TEMP.MAX}°C)</name>
            <priority>AVERAGE</priority>
        </trigger>
        <trigger>
            <expression>{MiRCA Device:mirca.firmware.diff()}=1 and {MiRCA Device:mirca.firmware.strlen()}&gt;0</expression>
            <name>MiRCA: firmware changed to {ITEM.LASTVALUE}</name>
            <priority>INFO</priority>
            <manual_close>YES</manual_close>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 1 JK BMS Modbus:mirca.p1.protocol.last()}&lt;&gt;5</expression>
            <name>Port 1: protocol is not JK BMS Modbus (template does not match port settings)</name>
            <priority>WARNING</priority>
            <description>The port runs protocol {ITEM.LASTVALUE}. Change the port settings or link another template.</description>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 1 JK BMS Modbus:mirca.p1.online.max({$MIRCA.OFFLINE.TIME})}=0 and {MiRCA Port 1 JK BMS Modbus:mirca.p1.protocol.last()}=5</expression>
            <name>Port 1: JK BMS Modbus not responding</name>
            <priority>AVERAGE</priority>
            <description>No valid reply from the device for {$MIRCA.OFFLINE.TIME}. Check wiring, interface module, baud rate and device address.</description>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 1 JK BMS Modbus:mirca.p1.soc.max(5m)}&lt;{$MIRCA.SOC.CRIT:"p1"} and {MiRCA Port 1 JK BMS Modbus:mirca.p1.online.last()}=1</expression>
            <name>Port 1: battery SOC is critically low (&lt;{$MIRCA.SOC.CRIT:"p1"}%)</name>
            <priority>HIGH</priority>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 1 JK BMS Modbus:mirca.p1.soc.max(5m)}&lt;{$MIRCA.SOC.WARN:"p1"} and {MiRCA Port 1 JK BMS Modbus:mirca.p1.online.last()}=1</expression>
            <name>Port 1: battery SOC is low (&lt;{$MIRCA.SOC.WARN:"p1"}%)</name>
            <priority>WARNING</priority>
            <dependencies>
                <dependency>
                    <name>Port 1: battery SOC is critically low (&lt;{$MIRCA.SOC.CRIT:"p1"}%)</name>
                    <expression>{MiRCA Port 1 JK BMS Modbus:mirca.p1.soc.max(5m)}&lt;{$MIRCA.SOC.CRIT:"p1"} and {MiRCA Port 1 JK BMS Modbus:mirca.p1.online.last()}=1</expression>
                </dependency>
            </dependencies>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 1 JK BMS Modbus:mirca.p1.mos_temp.min(5m)}&gt;{$MIRCA.MOS.TEMP.MAX:"p1"} and {MiRCA Port 1 JK BMS Modbus:mirca.p1.online.last()}=1</expression>
            <name>Port 1: MOSFET temperature is high (&gt;{$MIRCA.MOS.TEMP.MAX:"p1"}°C)</name>
            <priority>AVERAGE</priority>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 1 JK BMS Modbus:mirca.p1.alarms.band(#1,{$MIRCA.JK.ALARM.MASK})}&lt;&gt;0 and {MiRCA Port 1 JK BMS Modbus:mirca.p1.alarms.text.strlen()}&gt;0 and {MiRCA Port 1 JK BMS Modbus:mirca.p1.online.last()}=1</expression>
            <name>Port 1: BMS alarm: {ITEM.LASTVALUE2}</name>
            <priority>AVERAGE</priority>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 2 JK BMS Modbus:mirca.p2.protocol.last()}&lt;&gt;5</expression>
            <name>Port 2: protocol is not JK BMS Modbus (template does not match port settings)</name>
            <priority>WARNING</priority>
            <description>The port runs protocol {ITEM.LASTVALUE}. Change the port settings or link another template.</description>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 2 JK BMS Modbus:mirca.p2.online.max({$MIRCA.OFFLINE.TIME})}=0 and {MiRCA Port 2 JK BMS Modbus:mirca.p2.protocol.last()}=5</expression>
            <name>Port 2: JK BMS Modbus not responding</name>
            <priority>AVERAGE</priority>
            <description>No valid reply from the device for {$MIRCA.OFFLINE.TIME}. Check wiring, interface module, baud rate and device address.</description>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 2 JK BMS Modbus:mirca.p2.soc.max(5m)}&lt;{$MIRCA.SOC.CRIT:"p2"} and {MiRCA Port 2 JK BMS Modbus:mirca.p2.online.last()}=1</expression>
            <name>Port 2: battery SOC is critically low (&lt;{$MIRCA.SOC.CRIT:"p2"}%)</name>
            <priority>HIGH</priority>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 2 JK BMS Modbus:mirca.p2.soc.max(5m)}&lt;{$MIRCA.SOC.WARN:"p2"} and {MiRCA Port 2 JK BMS Modbus:mirca.p2.online.last()}=1</expression>
            <name>Port 2: battery SOC is low (&lt;{$MIRCA.SOC.WARN:"p2"}%)</name>
            <priority>WARNING</priority>
            <dependencies>
                <dependency>
                    <name>Port 2: battery SOC is critically low (&lt;{$MIRCA.SOC.CRIT:"p2"}%)</name>
                    <expression>{MiRCA Port 2 JK BMS Modbus:mirca.p2.soc.max(5m)}&lt;{$MIRCA.SOC.CRIT:"p2"} and {MiRCA Port 2 JK BMS Modbus:mirca.p2.online.last()}=1</expression>
                </dependency>
            </dependencies>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 2 JK BMS Modbus:mirca.p2.mos_temp.min(5m)}&gt;{$MIRCA.MOS.TEMP.MAX:"p2"} and {MiRCA Port 2 JK BMS Modbus:mirca.p2.online.last()}=1</expression>
            <name>Port 2: MOSFET temperature is high (&gt;{$MIRCA.MOS.TEMP.MAX:"p2"}°C)</name>
            <priority>AVERAGE</priority>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 2 JK BMS Modbus:mirca.p2.alarms.band(#1,{$MIRCA.JK.ALARM.MASK})}&lt;&gt;0 and {MiRCA Port 2 JK BMS Modbus:mirca.p2.alarms.text.strlen()}&gt;0 and {MiRCA Port 2 JK BMS Modbus:mirca.p2.online.last()}=1</expression>
            <name>Port 2: BMS alarm: {ITEM.LASTVALUE2}</name>
            <priority>AVERAGE</priority>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 1 JK BMS 4G-GPS:mirca.p1.protocol.last()}&lt;&gt;2</expression>
            <name>Port 1: protocol is not JK BMS 4G-GPS (template does not match port settings)</name>
            <priority>WARNING</priority>
            <description>The port runs protocol {ITEM.LASTVALUE}. Change the port settings or link another template.</description>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 1 JK BMS 4G-GPS:mirca.p1.online.max({$MIRCA.OFFLINE.TIME})}=0 and {MiRCA Port 1 JK BMS 4G-GPS:mirca.p1.protocol.last()}=2</expression>
            <name>Port 1: JK BMS 4G-GPS not responding</name>
            <priority>AVERAGE</priority>
            <description>No valid reply from the device for {$MIRCA.OFFLINE.TIME}. Check wiring, interface module, baud rate and device address.</description>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 1 JK BMS 4G-GPS:mirca.p1.soc.max(5m)}&lt;{$MIRCA.SOC.CRIT:"p1"} and {MiRCA Port 1 JK BMS 4G-GPS:mirca.p1.online.last()}=1</expression>
            <name>Port 1: battery SOC is critically low (&lt;{$MIRCA.SOC.CRIT:"p1"}%)</name>
            <priority>HIGH</priority>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 1 JK BMS 4G-GPS:mirca.p1.soc.max(5m)}&lt;{$MIRCA.SOC.WARN:"p1"} and {MiRCA Port 1 JK BMS 4G-GPS:mirca.p1.online.last()}=1</expression>
            <name>Port 1: battery SOC is low (&lt;{$MIRCA.SOC.WARN:"p1"}%)</name>
            <priority>WARNING</priority>
            <dependencies>
                <dependency>
                    <name>Port 1: battery SOC is critically low (&lt;{$MIRCA.SOC.CRIT:"p1"}%)</name>
                    <expression>{MiRCA Port 1 JK BMS 4G-GPS:mirca.p1.soc.max(5m)}&lt;{$MIRCA.SOC.CRIT:"p1"} and {MiRCA Port 1 JK BMS 4G-GPS:mirca.p1.online.last()}=1</expression>
                </dependency>
            </dependencies>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 2 JK BMS 4G-GPS:mirca.p2.protocol.last()}&lt;&gt;2</expression>
            <name>Port 2: protocol is not JK BMS 4G-GPS (template does not match port settings)</name>
            <priority>WARNING</priority>
            <description>The port runs protocol {ITEM.LASTVALUE}. Change the port settings or link another template.</description>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 2 JK BMS 4G-GPS:mirca.p2.online.max({$MIRCA.OFFLINE.TIME})}=0 and {MiRCA Port 2 JK BMS 4G-GPS:mirca.p2.protocol.last()}=2</expression>
            <name>Port 2: JK BMS 4G-GPS not responding</name>
            <priority>AVERAGE</priority>
            <description>No valid reply from the device for {$MIRCA.OFFLINE.TIME}. Check wiring, interface module, baud rate and device address.</description>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 2 JK BMS 4G-GPS:mirca.p2.soc.max(5m)}&lt;{$MIRCA.SOC.CRIT:"p2"} and {MiRCA Port 2 JK BMS 4G-GPS:mirca.p2.online.last()}=1</expression>
            <name>Port 2: battery SOC is critically low (&lt;{$MIRCA.SOC.CRIT:"p2"}%)</name>
            <priority>HIGH</priority>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 2 JK BMS 4G-GPS:mirca.p2.soc.max(5m)}&lt;{$MIRCA.SOC.WARN:"p2"} and {MiRCA Port 2 JK BMS 4G-GPS:mirca.p2.online.last()}=1</expression>
            <name>Port 2: battery SOC is low (&lt;{$MIRCA.SOC.WARN:"p2"}%)</name>
            <priority>WARNING</priority>
            <dependencies>
                <dependency>
                    <name>Port 2: battery SOC is critically low (&lt;{$MIRCA.SOC.CRIT:"p2"}%)</name>
                    <expression>{MiRCA Port 2 JK BMS 4G-GPS:mirca.p2.soc.max(5m)}&lt;{$MIRCA.SOC.CRIT:"p2"} and {MiRCA Port 2 JK BMS 4G-GPS:mirca.p2.online.last()}=1</expression>
                </dependency>
            </dependencies>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 1 JBD BMS:mirca.p1.protocol.last()}&lt;&gt;4</expression>
            <name>Port 1: protocol is not JBD BMS (template does not match port settings)</name>
            <priority>WARNING</priority>
            <description>The port runs protocol {ITEM.LASTVALUE}. Change the port settings or link another template.</description>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 1 JBD BMS:mirca.p1.online.max({$MIRCA.OFFLINE.TIME})}=0 and {MiRCA Port 1 JBD BMS:mirca.p1.protocol.last()}=4</expression>
            <name>Port 1: JBD BMS not responding</name>
            <priority>AVERAGE</priority>
            <description>No valid reply from the device for {$MIRCA.OFFLINE.TIME}. Check wiring, interface module, baud rate and device address.</description>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 1 JBD BMS:mirca.p1.soc.max(5m)}&lt;{$MIRCA.SOC.CRIT:"p1"} and {MiRCA Port 1 JBD BMS:mirca.p1.online.last()}=1</expression>
            <name>Port 1: battery SOC is critically low (&lt;{$MIRCA.SOC.CRIT:"p1"}%)</name>
            <priority>HIGH</priority>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 1 JBD BMS:mirca.p1.soc.max(5m)}&lt;{$MIRCA.SOC.WARN:"p1"} and {MiRCA Port 1 JBD BMS:mirca.p1.online.last()}=1</expression>
            <name>Port 1: battery SOC is low (&lt;{$MIRCA.SOC.WARN:"p1"}%)</name>
            <priority>WARNING</priority>
            <dependencies>
                <dependency>
                    <name>Port 1: battery SOC is critically low (&lt;{$MIRCA.SOC.CRIT:"p1"}%)</name>
                    <expression>{MiRCA Port 1 JBD BMS:mirca.p1.soc.max(5m)}&lt;{$MIRCA.SOC.CRIT:"p1"} and {MiRCA Port 1 JBD BMS:mirca.p1.online.last()}=1</expression>
                </dependency>
            </dependencies>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 2 JBD BMS:mirca.p2.protocol.last()}&lt;&gt;4</expression>
            <name>Port 2: protocol is not JBD BMS (template does not match port settings)</name>
            <priority>WARNING</priority>
            <description>The port runs protocol {ITEM.LASTVALUE}. Change the port settings or link another template.</description>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 2 JBD BMS:mirca.p2.online.max({$MIRCA.OFFLINE.TIME})}=0 and {MiRCA Port 2 JBD BMS:mirca.p2.protocol.last()}=4</expression>
            <name>Port 2: JBD BMS not responding</name>
            <priority>AVERAGE</priority>
            <description>No valid reply from the device for {$MIRCA.OFFLINE.TIME}. Check wiring, interface module, baud rate and device address.</description>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 2 JBD BMS:mirca.p2.soc.max(5m)}&lt;{$MIRCA.SOC.CRIT:"p2"} and {MiRCA Port 2 JBD BMS:mirca.p2.online.last()}=1</expression>
            <name>Port 2: battery SOC is critically low (&lt;{$MIRCA.SOC.CRIT:"p2"}%)</name>
            <priority>HIGH</priority>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 2 JBD BMS:mirca.p2.soc.max(5m)}&lt;{$MIRCA.SOC.WARN:"p2"} and {MiRCA Port 2 JBD BMS:mirca.p2.online.last()}=1</expression>
            <name>Port 2: battery SOC is low (&lt;{$MIRCA.SOC.WARN:"p2"}%)</name>
            <priority>WARNING</priority>
            <dependencies>
                <dependency>
                    <name>Port 2: battery SOC is critically low (&lt;{$MIRCA.SOC.CRIT:"p2"}%)</name>
                    <expression>{MiRCA Port 2 JBD BMS:mirca.p2.soc.max(5m)}&lt;{$MIRCA.SOC.CRIT:"p2"} and {MiRCA Port 2 JBD BMS:mirca.p2.online.last()}=1</expression>
                </dependency>
            </dependencies>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 1 PACE BMS:mirca.p1.protocol.last()}&lt;&gt;3</expression>
            <name>Port 1: protocol is not PACE BMS (template does not match port settings)</name>
            <priority>WARNING</priority>
            <description>The port runs protocol {ITEM.LASTVALUE}. Change the port settings or link another template.</description>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 1 PACE BMS:mirca.p1.online.max({$MIRCA.OFFLINE.TIME})}=0 and {MiRCA Port 1 PACE BMS:mirca.p1.protocol.last()}=3</expression>
            <name>Port 1: PACE BMS not responding</name>
            <priority>AVERAGE</priority>
            <description>No valid reply from the device for {$MIRCA.OFFLINE.TIME}. Check wiring, interface module, baud rate and device address.</description>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 1 PACE BMS:mirca.p1.soc.max(5m)}&lt;{$MIRCA.SOC.CRIT:"p1"} and {MiRCA Port 1 PACE BMS:mirca.p1.online.last()}=1</expression>
            <name>Port 1: battery SOC is critically low (&lt;{$MIRCA.SOC.CRIT:"p1"}%)</name>
            <priority>HIGH</priority>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 1 PACE BMS:mirca.p1.soc.max(5m)}&lt;{$MIRCA.SOC.WARN:"p1"} and {MiRCA Port 1 PACE BMS:mirca.p1.online.last()}=1</expression>
            <name>Port 1: battery SOC is low (&lt;{$MIRCA.SOC.WARN:"p1"}%)</name>
            <priority>WARNING</priority>
            <dependencies>
                <dependency>
                    <name>Port 1: battery SOC is critically low (&lt;{$MIRCA.SOC.CRIT:"p1"}%)</name>
                    <expression>{MiRCA Port 1 PACE BMS:mirca.p1.soc.max(5m)}&lt;{$MIRCA.SOC.CRIT:"p1"} and {MiRCA Port 1 PACE BMS:mirca.p1.online.last()}=1</expression>
                </dependency>
            </dependencies>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 2 PACE BMS:mirca.p2.protocol.last()}&lt;&gt;3</expression>
            <name>Port 2: protocol is not PACE BMS (template does not match port settings)</name>
            <priority>WARNING</priority>
            <description>The port runs protocol {ITEM.LASTVALUE}. Change the port settings or link another template.</description>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 2 PACE BMS:mirca.p2.online.max({$MIRCA.OFFLINE.TIME})}=0 and {MiRCA Port 2 PACE BMS:mirca.p2.protocol.last()}=3</expression>
            <name>Port 2: PACE BMS not responding</name>
            <priority>AVERAGE</priority>
            <description>No valid reply from the device for {$MIRCA.OFFLINE.TIME}. Check wiring, interface module, baud rate and device address.</description>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 2 PACE BMS:mirca.p2.soc.max(5m)}&lt;{$MIRCA.SOC.CRIT:"p2"} and {MiRCA Port 2 PACE BMS:mirca.p2.online.last()}=1</expression>
            <name>Port 2: battery SOC is critically low (&lt;{$MIRCA.SOC.CRIT:"p2"}%)</name>
            <priority>HIGH</priority>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 2 PACE BMS:mirca.p2.soc.max(5m)}&lt;{$MIRCA.SOC.WARN:"p2"} and {MiRCA Port 2 PACE BMS:mirca.p2.online.last()}=1</expression>
            <name>Port 2: battery SOC is low (&lt;{$MIRCA.SOC.WARN:"p2"}%)</name>
            <priority>WARNING</priority>
            <dependencies>
                <dependency>
                    <name>Port 2: battery SOC is critically low (&lt;{$MIRCA.SOC.CRIT:"p2"}%)</name>
                    <expression>{MiRCA Port 2 PACE BMS:mirca.p2.soc.max(5m)}&lt;{$MIRCA.SOC.CRIT:"p2"} and {MiRCA Port 2 PACE BMS:mirca.p2.online.last()}=1</expression>
                </dependency>
            </dependencies>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 1 Deye inverter Modbus:mirca.p1.protocol.last()}&lt;&gt;6</expression>
            <name>Port 1: protocol is not Deye inverter Modbus (template does not match port settings)</name>
            <priority>WARNING</priority>
            <description>The port runs protocol {ITEM.LASTVALUE}. Change the port settings or link another template.</description>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 1 Deye inverter Modbus:mirca.p1.online.max({$MIRCA.OFFLINE.TIME})}=0 and {MiRCA Port 1 Deye inverter Modbus:mirca.p1.protocol.last()}=6</expression>
            <name>Port 1: Deye inverter Modbus not responding</name>
            <priority>AVERAGE</priority>
            <description>No valid reply from the device for {$MIRCA.OFFLINE.TIME}. Check wiring, interface module, baud rate and device address.</description>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 1 Deye inverter Modbus:mirca.p1.m[state].last()}=4 and {MiRCA Port 1 Deye inverter Modbus:mirca.p1.online.last()}=1</expression>
            <name>Port 1: inverter is in FAULT state</name>
            <priority>HIGH</priority>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 1 Deye inverter Modbus:mirca.p1.m[state].last()}=3 and {MiRCA Port 1 Deye inverter Modbus:mirca.p1.online.last()}=1</expression>
            <name>Port 1: inverter is in ALARM state</name>
            <priority>AVERAGE</priority>
            <dependencies>
                <dependency>
                    <name>Port 1: inverter is in FAULT state</name>
                    <expression>{MiRCA Port 1 Deye inverter Modbus:mirca.p1.m[state].last()}=4 and {MiRCA Port 1 Deye inverter Modbus:mirca.p1.online.last()}=1</expression>
                </dependency>
            </dependencies>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 1 Deye inverter Modbus:mirca.p1.faults.lo.last()}&lt;&gt;0 and {MiRCA Port 1 Deye inverter Modbus:mirca.p1.faults.lo.text.strlen()}&gt;0 and {MiRCA Port 1 Deye inverter Modbus:mirca.p1.online.last()}=1</expression>
            <name>Port 1: inverter fault: {ITEM.LASTVALUE2}</name>
            <priority>AVERAGE</priority>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 1 Deye inverter Modbus:mirca.p1.faults.hi.last()}&lt;&gt;0 and {MiRCA Port 1 Deye inverter Modbus:mirca.p1.faults.hi.text.strlen()}&gt;0 and {MiRCA Port 1 Deye inverter Modbus:mirca.p1.online.last()}=1</expression>
            <name>Port 1: inverter fault: {ITEM.LASTVALUE2}</name>
            <priority>AVERAGE</priority>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 1 Deye inverter Modbus:mirca.p1.m[grid_connected].max({$MIRCA.OFFLINE.TIME})}=0 and {$MIRCA.DEYE.GRID.EXPECTED}=1 and {MiRCA Port 1 Deye inverter Modbus:mirca.p1.online.last()}=1</expression>
            <name>Port 1: grid disconnected</name>
            <priority>WARNING</priority>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 1 Deye inverter Modbus:mirca.p1.m[battery_soc].max(5m)}&lt;{$MIRCA.SOC.WARN:"p1"} and {MiRCA Port 1 Deye inverter Modbus:mirca.p1.online.last()}=1</expression>
            <name>Port 1: battery SOC is low (&lt;{$MIRCA.SOC.WARN:"p1"}%)</name>
            <priority>WARNING</priority>
        </trigger>
        <trigger>
            <expression>({MiRCA Port 1 Deye inverter Modbus:mirca.p1.m[radiator_temp].min(5m)}&gt;{$MIRCA.DEYE.TEMP.MAX} or {MiRCA Port 1 Deye inverter Modbus:mirca.p1.m[dc_temp].min(5m)}&gt;{$MIRCA.DEYE.TEMP.MAX}) and {MiRCA Port 1 Deye inverter Modbus:mirca.p1.online.last()}=1</expression>
            <name>Port 1: inverter temperature is high (&gt;{$MIRCA.DEYE.TEMP.MAX}°C)</name>
            <priority>AVERAGE</priority>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 2 Deye inverter Modbus:mirca.p2.protocol.last()}&lt;&gt;6</expression>
            <name>Port 2: protocol is not Deye inverter Modbus (template does not match port settings)</name>
            <priority>WARNING</priority>
            <description>The port runs protocol {ITEM.LASTVALUE}. Change the port settings or link another template.</description>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 2 Deye inverter Modbus:mirca.p2.online.max({$MIRCA.OFFLINE.TIME})}=0 and {MiRCA Port 2 Deye inverter Modbus:mirca.p2.protocol.last()}=6</expression>
            <name>Port 2: Deye inverter Modbus not responding</name>
            <priority>AVERAGE</priority>
            <description>No valid reply from the device for {$MIRCA.OFFLINE.TIME}. Check wiring, interface module, baud rate and device address.</description>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 2 Deye inverter Modbus:mirca.p2.m[state].last()}=4 and {MiRCA Port 2 Deye inverter Modbus:mirca.p2.online.last()}=1</expression>
            <name>Port 2: inverter is in FAULT state</name>
            <priority>HIGH</priority>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 2 Deye inverter Modbus:mirca.p2.m[state].last()}=3 and {MiRCA Port 2 Deye inverter Modbus:mirca.p2.online.last()}=1</expression>
            <name>Port 2: inverter is in ALARM state</name>
            <priority>AVERAGE</priority>
            <dependencies>
                <dependency>
                    <name>Port 2: inverter is in FAULT state</name>
                    <expression>{MiRCA Port 2 Deye inverter Modbus:mirca.p2.m[state].last()}=4 and {MiRCA Port 2 Deye inverter Modbus:mirca.p2.online.last()}=1</expression>
                </dependency>
            </dependencies>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 2 Deye inverter Modbus:mirca.p2.faults.lo.last()}&lt;&gt;0 and {MiRCA Port 2 Deye inverter Modbus:mirca.p2.faults.lo.text.strlen()}&gt;0 and {MiRCA Port 2 Deye inverter Modbus:mirca.p2.online.last()}=1</expression>
            <name>Port 2: inverter fault: {ITEM.LASTVALUE2}</name>
            <priority>AVERAGE</priority>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 2 Deye inverter Modbus:mirca.p2.faults.hi.last()}&lt;&gt;0 and {MiRCA Port 2 Deye inverter Modbus:mirca.p2.faults.hi.text.strlen()}&gt;0 and {MiRCA Port 2 Deye inverter Modbus:mirca.p2.online.last()}=1</expression>
            <name>Port 2: inverter fault: {ITEM.LASTVALUE2}</name>
            <priority>AVERAGE</priority>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 2 Deye inverter Modbus:mirca.p2.m[grid_connected].max({$MIRCA.OFFLINE.TIME})}=0 and {$MIRCA.DEYE.GRID.EXPECTED}=1 and {MiRCA Port 2 Deye inverter Modbus:mirca.p2.online.last()}=1</expression>
            <name>Port 2: grid disconnected</name>
            <priority>WARNING</priority>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 2 Deye inverter Modbus:mirca.p2.m[battery_soc].max(5m)}&lt;{$MIRCA.SOC.WARN:"p2"} and {MiRCA Port 2 Deye inverter Modbus:mirca.p2.online.last()}=1</expression>
            <name>Port 2: battery SOC is low (&lt;{$MIRCA.SOC.WARN:"p2"}%)</name>
            <priority>WARNING</priority>
        </trigger>
        <trigger>
            <expression>({MiRCA Port 2 Deye inverter Modbus:mirca.p2.m[radiator_temp].min(5m)}&gt;{$MIRCA.DEYE.TEMP.MAX} or {MiRCA Port 2 Deye inverter Modbus:mirca.p2.m[dc_temp].min(5m)}&gt;{$MIRCA.DEYE.TEMP.MAX}) and {MiRCA Port 2 Deye inverter Modbus:mirca.p2.online.last()}=1</expression>
            <name>Port 2: inverter temperature is high (&gt;{$MIRCA.DEYE.TEMP.MAX}°C)</name>
            <priority>AVERAGE</priority>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 1 Victron VE.Bus:mirca.p1.protocol.last()}&lt;&gt;1</expression>
            <name>Port 1: protocol is not Victron VE.Bus (template does not match port settings)</name>
            <priority>WARNING</priority>
            <description>The port runs protocol {ITEM.LASTVALUE}. Change the port settings or link another template.</description>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 1 Victron VE.Bus:mirca.p1.online.max({$MIRCA.OFFLINE.TIME})}=0 and {MiRCA Port 1 Victron VE.Bus:mirca.p1.protocol.last()}=1</expression>
            <name>Port 1: Victron VE.Bus not responding</name>
            <priority>AVERAGE</priority>
            <description>No valid reply from the device for {$MIRCA.OFFLINE.TIME}. Check wiring, interface module, baud rate and device address.</description>
        </trigger>
        <trigger>
            <expression>({MiRCA Port 1 Victron VE.Bus:mirca.p1.ac_frequency.max(2m)}&lt;{$MIRCA.AC.FREQ.MIN} or {MiRCA Port 1 Victron VE.Bus:mirca.p1.ac_frequency.min(2m)}&gt;{$MIRCA.AC.FREQ.MAX}) and {MiRCA Port 1 Victron VE.Bus:mirca.p1.ac_frequency.last()}&gt;0 and {MiRCA Port 1 Victron VE.Bus:mirca.p1.online.last()}=1</expression>
            <name>Port 1: AC frequency out of range ({ITEM.LASTVALUE1})</name>
            <priority>AVERAGE</priority>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 1 Victron VE.Bus:mirca.p1.dc_voltage.max(5m)}&lt;{$MIRCA.DC.VOLTAGE.MIN:"p1"} and {$MIRCA.DC.VOLTAGE.MIN:"p1"}&gt;0 and {MiRCA Port 1 Victron VE.Bus:mirca.p1.online.last()}=1</expression>
            <name>Port 1: DC voltage is low (&lt;{$MIRCA.DC.VOLTAGE.MIN:"p1"}V)</name>
            <priority>AVERAGE</priority>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 1 Victron VE.Bus:mirca.p1.dc_voltage.min(5m)}&gt;{$MIRCA.DC.VOLTAGE.MAX:"p1"} and {$MIRCA.DC.VOLTAGE.MAX:"p1"}&gt;0 and {MiRCA Port 1 Victron VE.Bus:mirca.p1.online.last()}=1</expression>
            <name>Port 1: DC voltage is high (&gt;{$MIRCA.DC.VOLTAGE.MAX:"p1"}V)</name>
            <priority>AVERAGE</priority>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 2 Victron VE.Bus:mirca.p2.protocol.last()}&lt;&gt;1</expression>
            <name>Port 2: protocol is not Victron VE.Bus (template does not match port settings)</name>
            <priority>WARNING</priority>
            <description>The port runs protocol {ITEM.LASTVALUE}. Change the port settings or link another template.</description>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 2 Victron VE.Bus:mirca.p2.online.max({$MIRCA.OFFLINE.TIME})}=0 and {MiRCA Port 2 Victron VE.Bus:mirca.p2.protocol.last()}=1</expression>
            <name>Port 2: Victron VE.Bus not responding</name>
            <priority>AVERAGE</priority>
            <description>No valid reply from the device for {$MIRCA.OFFLINE.TIME}. Check wiring, interface module, baud rate and device address.</description>
        </trigger>
        <trigger>
            <expression>({MiRCA Port 2 Victron VE.Bus:mirca.p2.ac_frequency.max(2m)}&lt;{$MIRCA.AC.FREQ.MIN} or {MiRCA Port 2 Victron VE.Bus:mirca.p2.ac_frequency.min(2m)}&gt;{$MIRCA.AC.FREQ.MAX}) and {MiRCA Port 2 Victron VE.Bus:mirca.p2.ac_frequency.last()}&gt;0 and {MiRCA Port 2 Victron VE.Bus:mirca.p2.online.last()}=1</expression>
            <name>Port 2: AC frequency out of range ({ITEM.LASTVALUE1})</name>
            <priority>AVERAGE</priority>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 2 Victron VE.Bus:mirca.p2.dc_voltage.max(5m)}&lt;{$MIRCA.DC.VOLTAGE.MIN:"p2"} and {$MIRCA.DC.VOLTAGE.MIN:"p2"}&gt;0 and {MiRCA Port 2 Victron VE.Bus:mirca.p2.online.last()}=1</expression>
            <name>Port 2: DC voltage is low (&lt;{$MIRCA.DC.VOLTAGE.MIN:"p2"}V)</name>
            <priority>AVERAGE</priority>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 2 Victron VE.Bus:mirca.p2.dc_voltage.min(5m)}&gt;{$MIRCA.DC.VOLTAGE.MAX:"p2"} and {$MIRCA.DC.VOLTAGE.MAX:"p2"}&gt;0 and {MiRCA Port 2 Victron VE.Bus:mirca.p2.online.last()}=1</expression>
            <name>Port 2: DC voltage is high (&gt;{$MIRCA.DC.VOLTAGE.MAX:"p2"}V)</name>
            <priority>AVERAGE</priority>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 1 JK BMS parallel bus:mirca.p1.protocol.last()}&lt;&gt;8</expression>
            <name>Port 1: protocol is not JK BMS parallel bus (template does not match port settings)</name>
            <priority>WARNING</priority>
            <description>The port runs protocol {ITEM.LASTVALUE}. Change the port settings or link another template.</description>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 1 JK BMS parallel bus:mirca.p1.online.max({$MIRCA.OFFLINE.TIME})}=0 and {MiRCA Port 1 JK BMS parallel bus:mirca.p1.protocol.last()}=8</expression>
            <name>Port 1: JK BMS parallel bus not responding</name>
            <priority>AVERAGE</priority>
            <description>No valid reply from the device for {$MIRCA.OFFLINE.TIME}. Check wiring, interface module, baud rate and device address.</description>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 1 JK BMS parallel bus:mirca.p1.soc.max(5m)}&lt;{$MIRCA.SOC.CRIT:"p1"} and {MiRCA Port 1 JK BMS parallel bus:mirca.p1.online.last()}=1</expression>
            <name>Port 1: battery SOC is critically low (&lt;{$MIRCA.SOC.CRIT:"p1"}%)</name>
            <priority>HIGH</priority>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 1 JK BMS parallel bus:mirca.p1.soc.max(5m)}&lt;{$MIRCA.SOC.WARN:"p1"} and {MiRCA Port 1 JK BMS parallel bus:mirca.p1.online.last()}=1</expression>
            <name>Port 1: battery SOC is low (&lt;{$MIRCA.SOC.WARN:"p1"}%)</name>
            <priority>WARNING</priority>
            <dependencies>
                <dependency>
                    <name>Port 1: battery SOC is critically low (&lt;{$MIRCA.SOC.CRIT:"p1"}%)</name>
                    <expression>{MiRCA Port 1 JK BMS parallel bus:mirca.p1.soc.max(5m)}&lt;{$MIRCA.SOC.CRIT:"p1"} and {MiRCA Port 1 JK BMS parallel bus:mirca.p1.online.last()}=1</expression>
                </dependency>
            </dependencies>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 1 JK BMS parallel bus:mirca.p1.mos_temp.min(5m)}&gt;{$MIRCA.MOS.TEMP.MAX:"p1"} and {MiRCA Port 1 JK BMS parallel bus:mirca.p1.online.last()}=1</expression>
            <name>Port 1: MOSFET temperature is high (&gt;{$MIRCA.MOS.TEMP.MAX:"p1"}°C)</name>
            <priority>AVERAGE</priority>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 1 JK BMS parallel bus:mirca.p1.alarms.band(#1,{$MIRCA.JK.ALARM.MASK})}&lt;&gt;0 and {MiRCA Port 1 JK BMS parallel bus:mirca.p1.alarms.text.strlen()}&gt;0 and {MiRCA Port 1 JK BMS parallel bus:mirca.p1.online.last()}=1</expression>
            <name>Port 1: BMS alarm: {ITEM.LASTVALUE2}</name>
            <priority>AVERAGE</priority>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 2 JK BMS parallel bus:mirca.p2.protocol.last()}&lt;&gt;8</expression>
            <name>Port 2: protocol is not JK BMS parallel bus (template does not match port settings)</name>
            <priority>WARNING</priority>
            <description>The port runs protocol {ITEM.LASTVALUE}. Change the port settings or link another template.</description>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 2 JK BMS parallel bus:mirca.p2.online.max({$MIRCA.OFFLINE.TIME})}=0 and {MiRCA Port 2 JK BMS parallel bus:mirca.p2.protocol.last()}=8</expression>
            <name>Port 2: JK BMS parallel bus not responding</name>
            <priority>AVERAGE</priority>
            <description>No valid reply from the device for {$MIRCA.OFFLINE.TIME}. Check wiring, interface module, baud rate and device address.</description>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 2 JK BMS parallel bus:mirca.p2.soc.max(5m)}&lt;{$MIRCA.SOC.CRIT:"p2"} and {MiRCA Port 2 JK BMS parallel bus:mirca.p2.online.last()}=1</expression>
            <name>Port 2: battery SOC is critically low (&lt;{$MIRCA.SOC.CRIT:"p2"}%)</name>
            <priority>HIGH</priority>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 2 JK BMS parallel bus:mirca.p2.soc.max(5m)}&lt;{$MIRCA.SOC.WARN:"p2"} and {MiRCA Port 2 JK BMS parallel bus:mirca.p2.online.last()}=1</expression>
            <name>Port 2: battery SOC is low (&lt;{$MIRCA.SOC.WARN:"p2"}%)</name>
            <priority>WARNING</priority>
            <dependencies>
                <dependency>
                    <name>Port 2: battery SOC is critically low (&lt;{$MIRCA.SOC.CRIT:"p2"}%)</name>
                    <expression>{MiRCA Port 2 JK BMS parallel bus:mirca.p2.soc.max(5m)}&lt;{$MIRCA.SOC.CRIT:"p2"} and {MiRCA Port 2 JK BMS parallel bus:mirca.p2.online.last()}=1</expression>
                </dependency>
            </dependencies>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 2 JK BMS parallel bus:mirca.p2.mos_temp.min(5m)}&gt;{$MIRCA.MOS.TEMP.MAX:"p2"} and {MiRCA Port 2 JK BMS parallel bus:mirca.p2.online.last()}=1</expression>
            <name>Port 2: MOSFET temperature is high (&gt;{$MIRCA.MOS.TEMP.MAX:"p2"}°C)</name>
            <priority>AVERAGE</priority>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 2 JK BMS parallel bus:mirca.p2.alarms.band(#1,{$MIRCA.JK.ALARM.MASK})}&lt;&gt;0 and {MiRCA Port 2 JK BMS parallel bus:mirca.p2.alarms.text.strlen()}&gt;0 and {MiRCA Port 2 JK BMS parallel bus:mirca.p2.online.last()}=1</expression>
            <name>Port 2: BMS alarm: {ITEM.LASTVALUE2}</name>
            <priority>AVERAGE</priority>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 1 Serial capture:mirca.p1.protocol.last()}&lt;&gt;7</expression>
            <name>Port 1: protocol is not Serial capture (template does not match port settings)</name>
            <priority>WARNING</priority>
            <description>The port runs protocol {ITEM.LASTVALUE}. Change the port settings or link another template.</description>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 1 Serial capture:mirca.p1.m[buffer_used].last()}&gt;=100</expression>
            <name>Port 1: capture buffer is full, frames are dropped</name>
            <priority>INFO</priority>
            <manual_close>YES</manual_close>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 2 Serial capture:mirca.p2.protocol.last()}&lt;&gt;7</expression>
            <name>Port 2: protocol is not Serial capture (template does not match port settings)</name>
            <priority>WARNING</priority>
            <description>The port runs protocol {ITEM.LASTVALUE}. Change the port settings or link another template.</description>
        </trigger>
        <trigger>
            <expression>{MiRCA Port 2 Serial capture:mirca.p2.m[buffer_used].last()}&gt;=100</expression>
            <name>Port 2: capture buffer is full, frames are dropped</name>
            <priority>INFO</priority>
            <manual_close>YES</manual_close>
        </trigger>
    </triggers>
    <graphs>
        <graph>
            <name>Board temperature</name>
            <graph_items>
                <graph_item>
                    <sortorder>0</sortorder>
                    <color>1A7C11</color>
                    <item>
                        <host>MiRCA Device</host>
                        <key>mirca.ds18b20</key>
                    </item>
                </graph_item>
            </graph_items>
        </graph>
        <graph>
            <name>Port 1: voltage and current</name>
            <graph_items>
                <graph_item>
                    <sortorder>0</sortorder>
                    <color>1A7C11</color>
                    <item>
                        <host>MiRCA Port 1 JK BMS Modbus</host>
                        <key>mirca.p1.voltage</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>1</sortorder>
                    <color>F63100</color>
                    <yaxisside>RIGHT</yaxisside>
                    <item>
                        <host>MiRCA Port 1 JK BMS Modbus</host>
                        <key>mirca.p1.current</key>
                    </item>
                </graph_item>
            </graph_items>
        </graph>
        <graph>
            <name>Port 1: SOC</name>
            <graph_items>
                <graph_item>
                    <sortorder>0</sortorder>
                    <color>1A7C11</color>
                    <item>
                        <host>MiRCA Port 1 JK BMS Modbus</host>
                        <key>mirca.p1.soc</key>
                    </item>
                </graph_item>
            </graph_items>
        </graph>
        <graph>
            <name>Port 1: power</name>
            <graph_items>
                <graph_item>
                    <sortorder>0</sortorder>
                    <color>1A7C11</color>
                    <item>
                        <host>MiRCA Port 1 JK BMS Modbus</host>
                        <key>mirca.p1.power</key>
                    </item>
                </graph_item>
            </graph_items>
        </graph>
        <graph>
            <name>Port 2: voltage and current</name>
            <graph_items>
                <graph_item>
                    <sortorder>0</sortorder>
                    <color>1A7C11</color>
                    <item>
                        <host>MiRCA Port 2 JK BMS Modbus</host>
                        <key>mirca.p2.voltage</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>1</sortorder>
                    <color>F63100</color>
                    <yaxisside>RIGHT</yaxisside>
                    <item>
                        <host>MiRCA Port 2 JK BMS Modbus</host>
                        <key>mirca.p2.current</key>
                    </item>
                </graph_item>
            </graph_items>
        </graph>
        <graph>
            <name>Port 2: SOC</name>
            <graph_items>
                <graph_item>
                    <sortorder>0</sortorder>
                    <color>1A7C11</color>
                    <item>
                        <host>MiRCA Port 2 JK BMS Modbus</host>
                        <key>mirca.p2.soc</key>
                    </item>
                </graph_item>
            </graph_items>
        </graph>
        <graph>
            <name>Port 2: power</name>
            <graph_items>
                <graph_item>
                    <sortorder>0</sortorder>
                    <color>1A7C11</color>
                    <item>
                        <host>MiRCA Port 2 JK BMS Modbus</host>
                        <key>mirca.p2.power</key>
                    </item>
                </graph_item>
            </graph_items>
        </graph>
        <graph>
            <name>Port 1: voltage and current</name>
            <graph_items>
                <graph_item>
                    <sortorder>0</sortorder>
                    <color>1A7C11</color>
                    <item>
                        <host>MiRCA Port 1 JK BMS 4G-GPS</host>
                        <key>mirca.p1.voltage</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>1</sortorder>
                    <color>F63100</color>
                    <yaxisside>RIGHT</yaxisside>
                    <item>
                        <host>MiRCA Port 1 JK BMS 4G-GPS</host>
                        <key>mirca.p1.current</key>
                    </item>
                </graph_item>
            </graph_items>
        </graph>
        <graph>
            <name>Port 1: SOC</name>
            <graph_items>
                <graph_item>
                    <sortorder>0</sortorder>
                    <color>1A7C11</color>
                    <item>
                        <host>MiRCA Port 1 JK BMS 4G-GPS</host>
                        <key>mirca.p1.soc</key>
                    </item>
                </graph_item>
            </graph_items>
        </graph>
        <graph>
            <name>Port 1: power</name>
            <graph_items>
                <graph_item>
                    <sortorder>0</sortorder>
                    <color>1A7C11</color>
                    <item>
                        <host>MiRCA Port 1 JK BMS 4G-GPS</host>
                        <key>mirca.p1.power.calc</key>
                    </item>
                </graph_item>
            </graph_items>
        </graph>
        <graph>
            <name>Port 2: voltage and current</name>
            <graph_items>
                <graph_item>
                    <sortorder>0</sortorder>
                    <color>1A7C11</color>
                    <item>
                        <host>MiRCA Port 2 JK BMS 4G-GPS</host>
                        <key>mirca.p2.voltage</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>1</sortorder>
                    <color>F63100</color>
                    <yaxisside>RIGHT</yaxisside>
                    <item>
                        <host>MiRCA Port 2 JK BMS 4G-GPS</host>
                        <key>mirca.p2.current</key>
                    </item>
                </graph_item>
            </graph_items>
        </graph>
        <graph>
            <name>Port 2: SOC</name>
            <graph_items>
                <graph_item>
                    <sortorder>0</sortorder>
                    <color>1A7C11</color>
                    <item>
                        <host>MiRCA Port 2 JK BMS 4G-GPS</host>
                        <key>mirca.p2.soc</key>
                    </item>
                </graph_item>
            </graph_items>
        </graph>
        <graph>
            <name>Port 2: power</name>
            <graph_items>
                <graph_item>
                    <sortorder>0</sortorder>
                    <color>1A7C11</color>
                    <item>
                        <host>MiRCA Port 2 JK BMS 4G-GPS</host>
                        <key>mirca.p2.power.calc</key>
                    </item>
                </graph_item>
            </graph_items>
        </graph>
        <graph>
            <name>Port 1: voltage and current</name>
            <graph_items>
                <graph_item>
                    <sortorder>0</sortorder>
                    <color>1A7C11</color>
                    <item>
                        <host>MiRCA Port 1 JBD BMS</host>
                        <key>mirca.p1.voltage</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>1</sortorder>
                    <color>F63100</color>
                    <yaxisside>RIGHT</yaxisside>
                    <item>
                        <host>MiRCA Port 1 JBD BMS</host>
                        <key>mirca.p1.current</key>
                    </item>
                </graph_item>
            </graph_items>
        </graph>
        <graph>
            <name>Port 1: SOC</name>
            <graph_items>
                <graph_item>
                    <sortorder>0</sortorder>
                    <color>1A7C11</color>
                    <item>
                        <host>MiRCA Port 1 JBD BMS</host>
                        <key>mirca.p1.soc</key>
                    </item>
                </graph_item>
            </graph_items>
        </graph>
        <graph>
            <name>Port 1: power</name>
            <graph_items>
                <graph_item>
                    <sortorder>0</sortorder>
                    <color>1A7C11</color>
                    <item>
                        <host>MiRCA Port 1 JBD BMS</host>
                        <key>mirca.p1.power.calc</key>
                    </item>
                </graph_item>
            </graph_items>
        </graph>
        <graph>
            <name>Port 2: voltage and current</name>
            <graph_items>
                <graph_item>
                    <sortorder>0</sortorder>
                    <color>1A7C11</color>
                    <item>
                        <host>MiRCA Port 2 JBD BMS</host>
                        <key>mirca.p2.voltage</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>1</sortorder>
                    <color>F63100</color>
                    <yaxisside>RIGHT</yaxisside>
                    <item>
                        <host>MiRCA Port 2 JBD BMS</host>
                        <key>mirca.p2.current</key>
                    </item>
                </graph_item>
            </graph_items>
        </graph>
        <graph>
            <name>Port 2: SOC</name>
            <graph_items>
                <graph_item>
                    <sortorder>0</sortorder>
                    <color>1A7C11</color>
                    <item>
                        <host>MiRCA Port 2 JBD BMS</host>
                        <key>mirca.p2.soc</key>
                    </item>
                </graph_item>
            </graph_items>
        </graph>
        <graph>
            <name>Port 2: power</name>
            <graph_items>
                <graph_item>
                    <sortorder>0</sortorder>
                    <color>1A7C11</color>
                    <item>
                        <host>MiRCA Port 2 JBD BMS</host>
                        <key>mirca.p2.power.calc</key>
                    </item>
                </graph_item>
            </graph_items>
        </graph>
        <graph>
            <name>Port 1: voltage and current</name>
            <graph_items>
                <graph_item>
                    <sortorder>0</sortorder>
                    <color>1A7C11</color>
                    <item>
                        <host>MiRCA Port 1 PACE BMS</host>
                        <key>mirca.p1.voltage</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>1</sortorder>
                    <color>F63100</color>
                    <yaxisside>RIGHT</yaxisside>
                    <item>
                        <host>MiRCA Port 1 PACE BMS</host>
                        <key>mirca.p1.current</key>
                    </item>
                </graph_item>
            </graph_items>
        </graph>
        <graph>
            <name>Port 1: SOC</name>
            <graph_items>
                <graph_item>
                    <sortorder>0</sortorder>
                    <color>1A7C11</color>
                    <item>
                        <host>MiRCA Port 1 PACE BMS</host>
                        <key>mirca.p1.soc</key>
                    </item>
                </graph_item>
            </graph_items>
        </graph>
        <graph>
            <name>Port 1: power</name>
            <graph_items>
                <graph_item>
                    <sortorder>0</sortorder>
                    <color>1A7C11</color>
                    <item>
                        <host>MiRCA Port 1 PACE BMS</host>
                        <key>mirca.p1.power.calc</key>
                    </item>
                </graph_item>
            </graph_items>
        </graph>
        <graph>
            <name>Port 2: voltage and current</name>
            <graph_items>
                <graph_item>
                    <sortorder>0</sortorder>
                    <color>1A7C11</color>
                    <item>
                        <host>MiRCA Port 2 PACE BMS</host>
                        <key>mirca.p2.voltage</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>1</sortorder>
                    <color>F63100</color>
                    <yaxisside>RIGHT</yaxisside>
                    <item>
                        <host>MiRCA Port 2 PACE BMS</host>
                        <key>mirca.p2.current</key>
                    </item>
                </graph_item>
            </graph_items>
        </graph>
        <graph>
            <name>Port 2: SOC</name>
            <graph_items>
                <graph_item>
                    <sortorder>0</sortorder>
                    <color>1A7C11</color>
                    <item>
                        <host>MiRCA Port 2 PACE BMS</host>
                        <key>mirca.p2.soc</key>
                    </item>
                </graph_item>
            </graph_items>
        </graph>
        <graph>
            <name>Port 2: power</name>
            <graph_items>
                <graph_item>
                    <sortorder>0</sortorder>
                    <color>1A7C11</color>
                    <item>
                        <host>MiRCA Port 2 PACE BMS</host>
                        <key>mirca.p2.power.calc</key>
                    </item>
                </graph_item>
            </graph_items>
        </graph>
        <graph>
            <name>Port 1: power flow</name>
            <graph_items>
                <graph_item>
                    <sortorder>0</sortorder>
                    <color>1A7C11</color>
                    <item>
                        <host>MiRCA Port 1 Deye inverter Modbus</host>
                        <key>mirca.p1.m[pv_power]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>1</sortorder>
                    <color>F63100</color>
                    <item>
                        <host>MiRCA Port 1 Deye inverter Modbus</host>
                        <key>mirca.p1.m[battery_power]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>2</sortorder>
                    <color>2774A4</color>
                    <item>
                        <host>MiRCA Port 1 Deye inverter Modbus</host>
                        <key>mirca.p1.m[grid_power]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>3</sortorder>
                    <color>A54F10</color>
                    <item>
                        <host>MiRCA Port 1 Deye inverter Modbus</host>
                        <key>mirca.p1.m[load_power]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>4</sortorder>
                    <color>FC6EA3</color>
                    <item>
                        <host>MiRCA Port 1 Deye inverter Modbus</host>
                        <key>mirca.p1.m[inverter_power]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>5</sortorder>
                    <color>6C59DC</color>
                    <item>
                        <host>MiRCA Port 1 Deye inverter Modbus</host>
                        <key>mirca.p1.m[gen_power]</key>
                    </item>
                </graph_item>
            </graph_items>
        </graph>
        <graph>
            <name>Port 1: PV strings</name>
            <graph_items>
                <graph_item>
                    <sortorder>0</sortorder>
                    <color>1A7C11</color>
                    <item>
                        <host>MiRCA Port 1 Deye inverter Modbus</host>
                        <key>mirca.p1.m[pv1_power]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>1</sortorder>
                    <color>F63100</color>
                    <item>
                        <host>MiRCA Port 1 Deye inverter Modbus</host>
                        <key>mirca.p1.m[pv2_power]</key>
                    </item>
                </graph_item>
            </graph_items>
        </graph>
        <graph>
            <name>Port 1: battery</name>
            <graph_items>
                <graph_item>
                    <sortorder>0</sortorder>
                    <color>1A7C11</color>
                    <item>
                        <host>MiRCA Port 1 Deye inverter Modbus</host>
                        <key>mirca.p1.m[battery_voltage]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>1</sortorder>
                    <color>F63100</color>
                    <yaxisside>RIGHT</yaxisside>
                    <item>
                        <host>MiRCA Port 1 Deye inverter Modbus</host>
                        <key>mirca.p1.m[battery_soc]</key>
                    </item>
                </graph_item>
            </graph_items>
        </graph>
        <graph>
            <name>Port 1: grid</name>
            <graph_items>
                <graph_item>
                    <sortorder>0</sortorder>
                    <color>1A7C11</color>
                    <item>
                        <host>MiRCA Port 1 Deye inverter Modbus</host>
                        <key>mirca.p1.m[grid_voltage]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>1</sortorder>
                    <color>F63100</color>
                    <yaxisside>RIGHT</yaxisside>
                    <item>
                        <host>MiRCA Port 1 Deye inverter Modbus</host>
                        <key>mirca.p1.m[grid_frequency]</key>
                    </item>
                </graph_item>
            </graph_items>
        </graph>
        <graph>
            <name>Port 1: temperatures</name>
            <graph_items>
                <graph_item>
                    <sortorder>0</sortorder>
                    <color>1A7C11</color>
                    <item>
                        <host>MiRCA Port 1 Deye inverter Modbus</host>
                        <key>mirca.p1.m[dc_temp]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>1</sortorder>
                    <color>F63100</color>
                    <item>
                        <host>MiRCA Port 1 Deye inverter Modbus</host>
                        <key>mirca.p1.m[radiator_temp]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>2</sortorder>
                    <color>2774A4</color>
                    <item>
                        <host>MiRCA Port 1 Deye inverter Modbus</host>
                        <key>mirca.p1.m[environment_temp]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>3</sortorder>
                    <color>A54F10</color>
                    <item>
                        <host>MiRCA Port 1 Deye inverter Modbus</host>
                        <key>mirca.p1.m[battery_temp]</key>
                    </item>
                </graph_item>
            </graph_items>
        </graph>
        <graph>
            <name>Port 1: energy today</name>
            <graph_items>
                <graph_item>
                    <sortorder>0</sortorder>
                    <color>1A7C11</color>
                    <item>
                        <host>MiRCA Port 1 Deye inverter Modbus</host>
                        <key>mirca.p1.m[day_pv]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>1</sortorder>
                    <color>F63100</color>
                    <item>
                        <host>MiRCA Port 1 Deye inverter Modbus</host>
                        <key>mirca.p1.m[day_load]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>2</sortorder>
                    <color>2774A4</color>
                    <item>
                        <host>MiRCA Port 1 Deye inverter Modbus</host>
                        <key>mirca.p1.m[day_grid_import]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>3</sortorder>
                    <color>A54F10</color>
                    <item>
                        <host>MiRCA Port 1 Deye inverter Modbus</host>
                        <key>mirca.p1.m[day_grid_export]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>4</sortorder>
                    <color>FC6EA3</color>
                    <item>
                        <host>MiRCA Port 1 Deye inverter Modbus</host>
                        <key>mirca.p1.m[day_battery_charge]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>5</sortorder>
                    <color>6C59DC</color>
                    <item>
                        <host>MiRCA Port 1 Deye inverter Modbus</host>
                        <key>mirca.p1.m[day_battery_discharge]</key>
                    </item>
                </graph_item>
            </graph_items>
        </graph>
        <graph>
            <name>Port 2: power flow</name>
            <graph_items>
                <graph_item>
                    <sortorder>0</sortorder>
                    <color>1A7C11</color>
                    <item>
                        <host>MiRCA Port 2 Deye inverter Modbus</host>
                        <key>mirca.p2.m[pv_power]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>1</sortorder>
                    <color>F63100</color>
                    <item>
                        <host>MiRCA Port 2 Deye inverter Modbus</host>
                        <key>mirca.p2.m[battery_power]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>2</sortorder>
                    <color>2774A4</color>
                    <item>
                        <host>MiRCA Port 2 Deye inverter Modbus</host>
                        <key>mirca.p2.m[grid_power]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>3</sortorder>
                    <color>A54F10</color>
                    <item>
                        <host>MiRCA Port 2 Deye inverter Modbus</host>
                        <key>mirca.p2.m[load_power]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>4</sortorder>
                    <color>FC6EA3</color>
                    <item>
                        <host>MiRCA Port 2 Deye inverter Modbus</host>
                        <key>mirca.p2.m[inverter_power]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>5</sortorder>
                    <color>6C59DC</color>
                    <item>
                        <host>MiRCA Port 2 Deye inverter Modbus</host>
                        <key>mirca.p2.m[gen_power]</key>
                    </item>
                </graph_item>
            </graph_items>
        </graph>
        <graph>
            <name>Port 2: PV strings</name>
            <graph_items>
                <graph_item>
                    <sortorder>0</sortorder>
                    <color>1A7C11</color>
                    <item>
                        <host>MiRCA Port 2 Deye inverter Modbus</host>
                        <key>mirca.p2.m[pv1_power]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>1</sortorder>
                    <color>F63100</color>
                    <item>
                        <host>MiRCA Port 2 Deye inverter Modbus</host>
                        <key>mirca.p2.m[pv2_power]</key>
                    </item>
                </graph_item>
            </graph_items>
        </graph>
        <graph>
            <name>Port 2: battery</name>
            <graph_items>
                <graph_item>
                    <sortorder>0</sortorder>
                    <color>1A7C11</color>
                    <item>
                        <host>MiRCA Port 2 Deye inverter Modbus</host>
                        <key>mirca.p2.m[battery_voltage]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>1</sortorder>
                    <color>F63100</color>
                    <yaxisside>RIGHT</yaxisside>
                    <item>
                        <host>MiRCA Port 2 Deye inverter Modbus</host>
                        <key>mirca.p2.m[battery_soc]</key>
                    </item>
                </graph_item>
            </graph_items>
        </graph>
        <graph>
            <name>Port 2: grid</name>
            <graph_items>
                <graph_item>
                    <sortorder>0</sortorder>
                    <color>1A7C11</color>
                    <item>
                        <host>MiRCA Port 2 Deye inverter Modbus</host>
                        <key>mirca.p2.m[grid_voltage]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>1</sortorder>
                    <color>F63100</color>
                    <yaxisside>RIGHT</yaxisside>
                    <item>
                        <host>MiRCA Port 2 Deye inverter Modbus</host>
                        <key>mirca.p2.m[grid_frequency]</key>
                    </item>
                </graph_item>
            </graph_items>
        </graph>
        <graph>
            <name>Port 2: temperatures</name>
            <graph_items>
                <graph_item>
                    <sortorder>0</sortorder>
                    <color>1A7C11</color>
                    <item>
                        <host>MiRCA Port 2 Deye inverter Modbus</host>
                        <key>mirca.p2.m[dc_temp]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>1</sortorder>
                    <color>F63100</color>
                    <item>
                        <host>MiRCA Port 2 Deye inverter Modbus</host>
                        <key>mirca.p2.m[radiator_temp]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>2</sortorder>
                    <color>2774A4</color>
                    <item>
                        <host>MiRCA Port 2 Deye inverter Modbus</host>
                        <key>mirca.p2.m[environment_temp]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>3</sortorder>
                    <color>A54F10</color>
                    <item>
                        <host>MiRCA Port 2 Deye inverter Modbus</host>
                        <key>mirca.p2.m[battery_temp]</key>
                    </item>
                </graph_item>
            </graph_items>
        </graph>
        <graph>
            <name>Port 2: energy today</name>
            <graph_items>
                <graph_item>
                    <sortorder>0</sortorder>
                    <color>1A7C11</color>
                    <item>
                        <host>MiRCA Port 2 Deye inverter Modbus</host>
                        <key>mirca.p2.m[day_pv]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>1</sortorder>
                    <color>F63100</color>
                    <item>
                        <host>MiRCA Port 2 Deye inverter Modbus</host>
                        <key>mirca.p2.m[day_load]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>2</sortorder>
                    <color>2774A4</color>
                    <item>
                        <host>MiRCA Port 2 Deye inverter Modbus</host>
                        <key>mirca.p2.m[day_grid_import]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>3</sortorder>
                    <color>A54F10</color>
                    <item>
                        <host>MiRCA Port 2 Deye inverter Modbus</host>
                        <key>mirca.p2.m[day_grid_export]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>4</sortorder>
                    <color>FC6EA3</color>
                    <item>
                        <host>MiRCA Port 2 Deye inverter Modbus</host>
                        <key>mirca.p2.m[day_battery_charge]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>5</sortorder>
                    <color>6C59DC</color>
                    <item>
                        <host>MiRCA Port 2 Deye inverter Modbus</host>
                        <key>mirca.p2.m[day_battery_discharge]</key>
                    </item>
                </graph_item>
            </graph_items>
        </graph>
        <graph>
            <name>Port 1: DC voltage and current</name>
            <graph_items>
                <graph_item>
                    <sortorder>0</sortorder>
                    <color>1A7C11</color>
                    <item>
                        <host>MiRCA Port 1 Victron VE.Bus</host>
                        <key>mirca.p1.dc_voltage</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>1</sortorder>
                    <color>F63100</color>
                    <yaxisside>RIGHT</yaxisside>
                    <item>
                        <host>MiRCA Port 1 Victron VE.Bus</host>
                        <key>mirca.p1.dc_current</key>
                    </item>
                </graph_item>
            </graph_items>
        </graph>
        <graph>
            <name>Port 1: AC frequency</name>
            <graph_items>
                <graph_item>
                    <sortorder>0</sortorder>
                    <color>1A7C11</color>
                    <item>
                        <host>MiRCA Port 1 Victron VE.Bus</host>
                        <key>mirca.p1.ac_frequency</key>
                    </item>
                </graph_item>
            </graph_items>
        </graph>
        <graph>
            <name>Port 2: DC voltage and current</name>
            <graph_items>
                <graph_item>
                    <sortorder>0</sortorder>
                    <color>1A7C11</color>
                    <item>
                        <host>MiRCA Port 2 Victron VE.Bus</host>
                        <key>mirca.p2.dc_voltage</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>1</sortorder>
                    <color>F63100</color>
                    <yaxisside>RIGHT</yaxisside>
                    <item>
                        <host>MiRCA Port 2 Victron VE.Bus</host>
                        <key>mirca.p2.dc_current</key>
                    </item>
                </graph_item>
            </graph_items>
        </graph>
        <graph>
            <name>Port 2: AC frequency</name>
            <graph_items>
                <graph_item>
                    <sortorder>0</sortorder>
                    <color>1A7C11</color>
                    <item>
                        <host>MiRCA Port 2 Victron VE.Bus</host>
                        <key>mirca.p2.ac_frequency</key>
                    </item>
                </graph_item>
            </graph_items>
        </graph>
        <graph>
            <name>Port 1: voltage and current</name>
            <graph_items>
                <graph_item>
                    <sortorder>0</sortorder>
                    <color>1A7C11</color>
                    <item>
                        <host>MiRCA Port 1 JK BMS parallel bus</host>
                        <key>mirca.p1.voltage</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>1</sortorder>
                    <color>F63100</color>
                    <yaxisside>RIGHT</yaxisside>
                    <item>
                        <host>MiRCA Port 1 JK BMS parallel bus</host>
                        <key>mirca.p1.current</key>
                    </item>
                </graph_item>
            </graph_items>
        </graph>
        <graph>
            <name>Port 1: SOC</name>
            <graph_items>
                <graph_item>
                    <sortorder>0</sortorder>
                    <color>1A7C11</color>
                    <item>
                        <host>MiRCA Port 1 JK BMS parallel bus</host>
                        <key>mirca.p1.soc</key>
                    </item>
                </graph_item>
            </graph_items>
        </graph>
        <graph>
            <name>Port 1: power</name>
            <graph_items>
                <graph_item>
                    <sortorder>0</sortorder>
                    <color>1A7C11</color>
                    <item>
                        <host>MiRCA Port 1 JK BMS parallel bus</host>
                        <key>mirca.p1.power</key>
                    </item>
                </graph_item>
            </graph_items>
        </graph>
        <graph>
            <name>Port 2: voltage and current</name>
            <graph_items>
                <graph_item>
                    <sortorder>0</sortorder>
                    <color>1A7C11</color>
                    <item>
                        <host>MiRCA Port 2 JK BMS parallel bus</host>
                        <key>mirca.p2.voltage</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>1</sortorder>
                    <color>F63100</color>
                    <yaxisside>RIGHT</yaxisside>
                    <item>
                        <host>MiRCA Port 2 JK BMS parallel bus</host>
                        <key>mirca.p2.current</key>
                    </item>
                </graph_item>
            </graph_items>
        </graph>
        <graph>
            <name>Port 2: SOC</name>
            <graph_items>
                <graph_item>
                    <sortorder>0</sortorder>
                    <color>1A7C11</color>
                    <item>
                        <host>MiRCA Port 2 JK BMS parallel bus</host>
                        <key>mirca.p2.soc</key>
                    </item>
                </graph_item>
            </graph_items>
        </graph>
        <graph>
            <name>Port 2: power</name>
            <graph_items>
                <graph_item>
                    <sortorder>0</sortorder>
                    <color>1A7C11</color>
                    <item>
                        <host>MiRCA Port 2 JK BMS parallel bus</host>
                        <key>mirca.p2.power</key>
                    </item>
                </graph_item>
            </graph_items>
        </graph>
    </graphs>
    <value_maps>
        <value_map>
            <name>MiRCA Deye grid</name>
            <mappings>
                <mapping>
                    <value>0</value>
                    <newvalue>Disconnected</newvalue>
                </mapping>
                <mapping>
                    <value>1</value>
                    <newvalue>Connected</newvalue>
                </mapping>
            </mappings>
        </value_map>
        <value_map>
            <name>MiRCA Deye state</name>
            <mappings>
                <mapping>
                    <value>0</value>
                    <newvalue>Standby</newvalue>
                </mapping>
                <mapping>
                    <value>1</value>
                    <newvalue>Self-check</newvalue>
                </mapping>
                <mapping>
                    <value>2</value>
                    <newvalue>Normal</newvalue>
                </mapping>
                <mapping>
                    <value>3</value>
                    <newvalue>Alarm</newvalue>
                </mapping>
                <mapping>
                    <value>4</value>
                    <newvalue>Fault</newvalue>
                </mapping>
                <mapping>
                    <value>5</value>
                    <newvalue>Activating</newvalue>
                </mapping>
            </mappings>
        </value_map>
        <value_map>
            <name>MiRCA online</name>
            <mappings>
                <mapping>
                    <value>0</value>
                    <newvalue>Offline</newvalue>
                </mapping>
                <mapping>
                    <value>1</value>
                    <newvalue>Online</newvalue>
                </mapping>
            </mappings>
        </value_map>
        <value_map>
            <name>MiRCA protocol</name>
            <mappings>
                <mapping>
                    <value>0</value>
                    <newvalue>Off</newvalue>
                </mapping>
                <mapping>
                    <value>1</value>
                    <newvalue>Victron VE.Bus</newvalue>
                </mapping>
                <mapping>
                    <value>2</value>
                    <newvalue>JK BMS 4G-GPS</newvalue>
                </mapping>
                <mapping>
                    <value>3</value>
                    <newvalue>PACE BMS</newvalue>
                </mapping>
                <mapping>
                    <value>4</value>
                    <newvalue>JBD BMS</newvalue>
                </mapping>
                <mapping>
                    <value>5</value>
                    <newvalue>JK BMS Modbus</newvalue>
                </mapping>
                <mapping>
                    <value>6</value>
                    <newvalue>Deye inverter Modbus</newvalue>
                </mapping>
                <mapping>
                    <value>7</value>
                    <newvalue>Serial capture</newvalue>
                </mapping>
                <mapping>
                    <value>8</value>
                    <newvalue>JK BMS parallel bus</newvalue>
                </mapping>
            </mappings>
        </value_map>
    </value_maps>
</zabbix_export>
