<?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 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>
    </templates>
    <triggers>
        <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>
    </triggers>
    <graphs>
        <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 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>
