#!/usr/bin/env python3 from cmk.graphing.v1 import Title from cmk.graphing.v1.graphs import Graph, MinimalRange from cmk.graphing.v1.metrics import ( Color, DecimalNotation, Metric, SINotation, StrictPrecision, Unit, ) # Voltage metric_p1_voltage = Metric( name="p1_voltage_v", title=Title("Voltage"), unit=Unit( DecimalNotation("V"), StrictPrecision(1), ), color=Color.BLUE, ) graph_p1_voltage = Graph( name="p1_voltage", title=Title("P1 voltage"), simple_lines=["p1_voltage_v"], minimal_range=MinimalRange(200, 260), ) # Power metric_p1_power = Metric( name="p1_power_w", title=Title("Power"), unit=Unit( SINotation("W"), StrictPrecision(0), ), color=Color.BLUE, ) graph_p1_power = Graph( name="p1_power", title=Title("P1 power"), simple_lines=["p1_power_w"], minimal_range=MinimalRange(0, 3000), ) # Current metric_p1_current = Metric( name="p1_current_a", title=Title("Current"), unit=Unit( DecimalNotation("A"), StrictPrecision(3), ), color=Color.BLUE, ) graph_p1_current = Graph( name="p1_current", title=Title("P1 current"), simple_lines=["p1_current_a"], minimal_range=MinimalRange(0, 20), ) # Energy import metric_p1_energy_total = Metric( name="p1_energy_total_kwh", title=Title("Total"), unit=Unit( SINotation("Wh"), StrictPrecision(3), ), color=Color.BLUE, ) metric_p1_energy_t1 = Metric( name="p1_energy_t1_kwh", title=Title("Tariff 1"), unit=Unit( SINotation("Wh"), StrictPrecision(3), ), color=Color.GREEN, ) metric_p1_energy_t2 = Metric( name="p1_energy_t2_kwh", title=Title("Tariff 2"), unit=Unit( SINotation("Wh"), StrictPrecision(3), ), color=Color.ORANGE, ) graph_p1_energy = Graph( name="p1_energy", title=Title("P1 energy"), simple_lines=[ "p1_energy_total_kwh", "p1_energy_t1_kwh", "p1_energy_t2_kwh", ], minimal_range=MinimalRange(0, 1), ) # Gas metric_p1_gas = Metric( name="p1_gas_m3", title=Title("Gas"), unit=Unit( DecimalNotation("m³"), StrictPrecision(2), ), color=Color.BLUE, ) graph_p1_gas = Graph( name="p1_gas", title=Title("P1 gas consumption"), simple_lines=["p1_gas_m3"], minimal_range=MinimalRange(0, 1), ) # Voltage sag/swell counters metric_p1_voltage_sag_l1 = Metric( name="p1_voltage_sag_l1", title=Title("Voltage sags L1"), unit=Unit(DecimalNotation(""), StrictPrecision(0)), color=Color.BLUE, ) metric_p1_voltage_sag_l2 = Metric( name="p1_voltage_sag_l2", title=Title("Voltage sags L2"), unit=Unit(DecimalNotation(""), StrictPrecision(0)), color=Color.GREEN, ) metric_p1_voltage_sag_l3 = Metric( name="p1_voltage_sag_l3", title=Title("Voltage sags L3"), unit=Unit(DecimalNotation(""), StrictPrecision(0)), color=Color.ORANGE, ) graph_p1_voltage_sags = Graph( name="p1_voltage_sags", title=Title("P1 voltage sags"), simple_lines=[ "p1_voltage_sag_l1", "p1_voltage_sag_l2", "p1_voltage_sag_l3", ], minimal_range=MinimalRange(0, 1), ) # Voltage swell counters metric_p1_voltage_swell_l1 = Metric( name="p1_voltage_swell_l1", title=Title("Voltage swells L1"), unit=Unit(DecimalNotation(""), StrictPrecision(0)), color=Color.BLUE, ) metric_p1_voltage_swell_l2 = Metric( name="p1_voltage_swell_l2", title=Title("Voltage swells L2"), unit=Unit(DecimalNotation(""), StrictPrecision(0)), color=Color.GREEN, ) metric_p1_voltage_swell_l3 = Metric( name="p1_voltage_swell_l3", title=Title("Voltage swells L3"), unit=Unit(DecimalNotation(""), StrictPrecision(0)), color=Color.ORANGE, ) graph_p1_voltage_swells = Graph( name="p1_voltage_swells", title=Title("P1 voltage swells"), simple_lines=[ "p1_voltage_swell_l1", "p1_voltage_swell_l2", "p1_voltage_swell_l3", ], minimal_range=MinimalRange(0, 1), ) # Power failures metric_p1_any_power_fail = Metric( name="p1_any_power_failure", title=Title("Any power failures"), unit=Unit(DecimalNotation(""), StrictPrecision(0)), color=Color.BLUE, ) metric_p1_long_power_fail = Metric( name="p1_long_power_failure", title=Title("Long power failures"), unit=Unit(DecimalNotation(""), StrictPrecision(0)), color=Color.RED, ) graph_p1_power_failures = Graph( name="p1_power_failures", title=Title("P1 power failures"), simple_lines=[ "p1_any_power_failure", "p1_long_power_failure", ], minimal_range=MinimalRange(0, 1), )