Grafana dashboard: APC UPS Detailed Summary
Description: A Flux-based modification of the InfluxQL-based dashboard from https://grafana.com/grafana/dashboards/12625 - thank you, jenniferhatches.  Modifications pertain to layout (less emphasis on power consumption costs), colour thresholds for UPS Runtime, and the addition of power factor calculated based on maximum load/real power (watts) and maximum apparent power (volt-amps) supported by the UPS, as well as correct representation of the calculated load and total UPS consumption as a function of load percentage. You will need to manually alter the load power figures for the "maxwatt" variable, in accordance with APC's official specifications for your UPS unit(s). "maxvoltamp" variable will continue to automatically extract its value from the model name, as per the previous author's design.

Notes for Revision 2: Completely revamped the calculation for kWh graphs, which were so far away from accuracy I'm embarrassed I overlooked them when interpreting the code from InfluxQL to Flux. Correctly using integral function for gathering kWh consumption in both 24hr and 1M periods.

The greater focus for this dashboard over the original versions from other contributors was concerning the performance of the UPS rather than the consumption and cost analysis that they incorporated. Parts of that were retained but the detailed graphing of power (load and total apparent) and runtime were the prime focus here, to assist with predicting the failure of battery packs. This meant implementing InfluxDB 2.0 to allow for conditional calculations on the map() function for the purposes of calculating power factor for any future applications that I hadn't thought of at the time of uploading this.

As noted in the Short Description, a few additional variables have been built, one of which requires manual input, as it's not stored with the UPS. Check on the APC UPS official website for the specifications concerning the Maximum Load Output of your specific UPS model (expressed in watts). Do not confuse this with the VA (volt-amps) number contained in the model number, which is apparent power. Modify your maxwatt variable with the respective value(s) of your UPS unit(s) as taken from APC's official website, alongside their respective UPS names you have assigned to them (mine are simply called "UPSTower" and "UPS Rack").

From what little I searched on the community forums, it doesn't appear that the calculated Power Factor (PF) figure can be rounded off to two decimal places in the representation of those values in the variable summary bar at the top of the dashboard. If you find it as annoying as I do when it's an irrational number, you can always hide the variable, as it's not actually used in any of the dashboard's panels anyway!

Feel free to drop me a line in the community forum if you have any questions or can educate me on any further improvements needed.

{
  "__inputs": [
    {
      "name": "DS_INFLUXDB-FLUXED",
      "label": "InfluxDB-Fluxed",
      "description": "InfluxDB 2.0 (not 1.0.0 as the Dependencies suggests)",
      "type": "datasource",
      "pluginId": "influxdb",
      "pluginName": "InfluxDB"
    }
  ],
  "__requires": [
    {
      "type": "panel",
      "id": "gauge",
      "name": "Gauge",
      "version": ""
    },
    {
      "type": "grafana",
      "id": "grafana",
      "name": "Grafana",
      "version": "8.1.3"
    },
    {
      "type": "datasource",
      "id": "influxdb",
      "name": "InfluxDB",
      "version": "1.0.0"
    },
    {
      "type": "panel",
      "id": "stat",
      "name": "Stat",
      "version": ""
    },
    {
      "type": "panel",
      "id": "timeseries",
      "name": "Time series",
      "version": ""
    }
  ],
  "annotations": {
    "list": [
      {
        "builtIn": 1,
        "datasource": "-- Grafana --",
        "enable": true,
        "hide": true,
        "iconColor": "rgba(0, 211, 255, 1)",
        "name": "Annotations & Alerts",
        "target": {
          "limit": 100,
          "matchAny": false,
          "tags": [],
          "type": "dashboard"
        },
        "type": "dashboard"
      }
    ]
  },
  "description": "A Flux-based modification of the InfluxQL-based dashboard from https://grafana.com/grafana/dashboards/12625 - thank you, jenniferhatches.  Modifications pertain to layout (less emphasis on power consumption costs), colour thresholds for UPS Runtime, and the addition of power factor calculated based on maximum load/real power (watts) and maximum apparent power (volt-amps) supported by the UPS, as well as correct representation of the calculated load and total UPS consumption as a function of load percentage. You will need to manually alter the load power figures for the \"maxwatt\" variable, in accordance with APC's official specifications for your UPS unit(s). \"maxvoltamp\" variable will continue to automatically extract its value from the model name, as per the previous author's design.\n\nNotes for Revision 2: Completely revamped the calculation for kWh graphs, which were so far away from accuracy I'm embarrassed I overlooked them when interpreting the code from InfluxQL to Flux. Correctly using integral function for gathering kWh consumption in both 24hr and 1M periods.",
  "editable": true,
  "gnetId": 15010,
  "graphTooltip": 0,
  "id": null,
  "iteration": 1632042967745,
  "links": [],
  "panels": [
    {
      "cacheTimeout": null,
      "datasource": "$upsdatasource",
      "description": "",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "decimals": 1,
          "mappings": [
            {
              "options": {
                "BOOST ONLINE": {
                  "color": "light-yellow",
                  "index": 2,
                  "text": "BOOST"
                },
                "COMMLOST": {
                  "color": "light-purple",
                  "index": 4,
                  "text": "NO COMMS"
                },
                "ONBATT": {
                  "color": "semi-dark-red",
                  "index": 3,
                  "text": "ON BATTERY"
                },
                "ONLINE": {
                  "color": "semi-dark-green",
                  "index": 1,
                  "text": "ONLINE"
                },
                "ONLINE LOWBATT": {
                  "color": "semi-dark-red",
                  "index": 5,
                  "text": "ONLINE (Check batteries)"
                }
              },
              "type": "value"
            },
            {
              "options": {
                "match": "null",
                "result": {
                  "index": 0,
                  "text": "N/A"
                }
              },
              "type": "special"
            }
          ],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "red",
                "value": null
              }
            ]
          },
          "unit": "string"
        },
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "_value"
            },
            "properties": [
              {
                "id": "displayName",
                "value": "${upsname}"
              }
            ]
          }
        ]
      },
      "gridPos": {
        "h": 6,
        "w": 5,
        "x": 0,
        "y": 0
      },
      "hideTimeOverride": true,
      "id": 42,
      "interval": null,
      "links": [],
      "maxDataPoints": 100,
      "options": {
        "colorMode": "value",
        "fieldOptions": {
          "calcs": [
            "lastNotNull"
          ]
        },
        "graphMode": "none",
        "justifyMode": "auto",
        "orientation": "horizontal",
        "reduceOptions": {
          "calcs": [
            "mean"
          ],
          "fields": "/.*/",
          "values": true
        },
        "text": {},
        "textMode": "auto"
      },
      "pluginVersion": "8.1.3",
      "targets": [
        {
          "alias": "Volts",
          "groupBy": [
            {
              "params": [
                "$__interval"
              ],
              "type": "time"
            },
            {
              "params": [
                "null"
              ],
              "type": "fill"
            }
          ],
          "hide": false,
          "measurement": "apcupsd",
          "orderByTime": "ASC",
          "policy": "default",
          "query": "from(bucket: \"telegraf\")\r\n  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\r\n  |> filter(fn: (r) => r._measurement == \"apcupsd\" and r.ups_name == \"${upsname}\")\r\n  |> keep(columns: [\"status\"])\r\n  |> group()\r\n  |> distinct(column: \"status\")\r\n  |> last()\r\n  ",
          "rawQuery": false,
          "refId": "A",
          "resultFormat": "time_series",
          "select": [
            [
              {
                "params": [
                  "battery_voltage"
                ],
                "type": "field"
              },
              {
                "params": [],
                "type": "mean"
              }
            ]
          ],
          "tags": [
            {
              "key": "ups_name",
              "operator": "=~",
              "value": "/^$upsname$/"
            }
          ]
        }
      ],
      "timeFrom": "now-1m",
      "title": "Status",
      "transformations": [],
      "type": "stat"
    },
    {
      "cacheTimeout": null,
      "datasource": "$upsdatasource",
      "description": "",
      "fieldConfig": {
        "defaults": {
          "mappings": [
            {
              "options": {
                "match": "null",
                "result": {
                  "text": "N/A"
                }
              },
              "type": "special"
            }
          ],
          "max": 100,
          "min": 0,
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "semi-dark-green",
                "value": null
              },
              {
                "color": "light-yellow",
                "value": 25
              },
              {
                "color": "semi-dark-orange",
                "value": 50
              },
              {
                "color": "dark-red",
                "value": 75
              }
            ]
          },
          "unit": "percent"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 6,
        "w": 4,
        "x": 5,
        "y": 0
      },
      "hideTimeOverride": true,
      "id": 55,
      "interval": null,
      "links": [],
      "maxDataPoints": 100,
      "options": {
        "fieldOptions": {
          "calcs": [
            "lastNotNull"
          ]
        },
        "orientation": "horizontal",
        "reduceOptions": {
          "calcs": [
            "mean"
          ],
          "fields": "",
          "values": false
        },
        "showThresholdLabels": true,
        "showThresholdMarkers": true,
        "text": {}
      },
      "pluginVersion": "8.1.3",
      "targets": [
        {
          "alias": "Percent",
          "groupBy": [
            {
              "params": [
                "$__interval"
              ],
              "type": "time"
            },
            {
              "params": [
                "none"
              ],
              "type": "fill"
            }
          ],
          "measurement": "apcupsd",
          "orderByTime": "ASC",
          "policy": "default",
          "query": "from(bucket: \"telegraf\")\r\n  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\r\n  |> filter(fn: (r) => r._measurement == \"apcupsd\" and r.ups_name == \"${upsname}\")\r\n  |> filter(fn: (r) => r._field == \"load_percent\")\r\n  |> group()\r\n  |> yield(name: \"last\")\r\n",
          "refId": "A",
          "resultFormat": "time_series",
          "select": [
            [
              {
                "params": [
                  "battery_charge_percent"
                ],
                "type": "field"
              },
              {
                "params": [],
                "type": "mean"
              }
            ]
          ],
          "slimit": "",
          "tags": [
            {
              "key": "ups_name",
              "operator": "=~",
              "value": "/^$upsname$/"
            }
          ]
        }
      ],
      "timeFrom": "1h",
      "title": "Load Power",
      "transformations": [
        {
          "id": "organize",
          "options": {
            "excludeByName": {},
            "indexByName": {},
            "renameByName": {
              "Value": " "
            }
          }
        }
      ],
      "type": "gauge"
    },
    {
      "cacheTimeout": null,
      "datasource": "$upsdatasource",
      "description": "",
      "fieldConfig": {
        "defaults": {
          "mappings": [
            {
              "options": {
                "match": "null",
                "result": {
                  "text": "N/A"
                }
              },
              "type": "special"
            }
          ],
          "max": 100,
          "min": 0,
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "#d44a3a",
                "value": null
              },
              {
                "color": "rgba(237, 129, 40, 0.89)",
                "value": 20
              },
              {
                "color": "#299c46",
                "value": 50
              }
            ]
          },
          "unit": "percent"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 6,
        "w": 4,
        "x": 9,
        "y": 0
      },
      "hideTimeOverride": true,
      "id": 4,
      "interval": null,
      "links": [],
      "maxDataPoints": 100,
      "options": {
        "fieldOptions": {
          "calcs": [
            "lastNotNull"
          ]
        },
        "orientation": "horizontal",
        "reduceOptions": {
          "calcs": [
            "mean"
          ],
          "fields": "",
          "values": false
        },
        "showThresholdLabels": true,
        "showThresholdMarkers": true,
        "text": {}
      },
      "pluginVersion": "8.1.3",
      "repeat": null,
      "targets": [
        {
          "alias": "Percent",
          "groupBy": [
            {
              "params": [
                "$__interval"
              ],
              "type": "time"
            },
            {
              "params": [
                "none"
              ],
              "type": "fill"
            }
          ],
          "measurement": "apcupsd",
          "orderByTime": "ASC",
          "policy": "default",
          "query": "from(bucket: \"telegraf\")\r\n  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\r\n  |> filter(fn: (r) => r._measurement == \"apcupsd\" and r.ups_name == \"${upsname}\")\r\n  |> filter(fn: (r) => r._field == \"battery_charge_percent\")\r\n  |> group()\r\n  |> yield(name: \"last\")\r\n",
          "refId": "A",
          "resultFormat": "time_series",
          "select": [
            [
              {
                "params": [
                  "battery_charge_percent"
                ],
                "type": "field"
              },
              {
                "params": [],
                "type": "mean"
              }
            ]
          ],
          "slimit": "",
          "tags": [
            {
              "key": "ups_name",
              "operator": "=~",
              "value": "/^$upsname$/"
            }
          ]
        }
      ],
      "timeFrom": "1h",
      "title": "Battery Charge",
      "transformations": [
        {
          "id": "organize",
          "options": {
            "excludeByName": {},
            "indexByName": {},
            "renameByName": {
              "Value": " "
            }
          }
        }
      ],
      "type": "gauge"
    },
    {
      "cacheTimeout": null,
      "datasource": "$upsdatasource",
      "fieldConfig": {
        "defaults": {
          "decimals": 1,
          "mappings": [
            {
              "options": {
                "match": "null",
                "result": {
                  "text": "N/A"
                }
              },
              "type": "special"
            }
          ],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "#d44a3a",
                "value": null
              },
              {
                "color": "rgba(237, 129, 40, 0.89)",
                "value": 2700000000000
              },
              {
                "color": "#299c46",
                "value": 3600000000000
              }
            ]
          },
          "unit": "ns"
        },
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "time_left_ns"
            },
            "properties": [
              {
                "id": "displayName",
                "value": "${__field.labels.ups_name}"
              }
            ]
          }
        ]
      },
      "gridPos": {
        "h": 6,
        "w": 4,
        "x": 13,
        "y": 0
      },
      "hideTimeOverride": true,
      "id": 6,
      "interval": null,
      "links": [],
      "maxDataPoints": 100,
      "options": {
        "colorMode": "background",
        "fieldOptions": {
          "calcs": [
            "mean"
          ]
        },
        "graphMode": "none",
        "justifyMode": "auto",
        "orientation": "horizontal",
        "reduceOptions": {
          "calcs": [
            "mean"
          ],
          "fields": "",
          "values": false
        },
        "text": {},
        "textMode": "auto"
      },
      "pluginVersion": "8.1.3",
      "targets": [
        {
          "groupBy": [
            {
              "params": [
                "$__interval"
              ],
              "type": "time"
            },
            {
              "params": [
                "none"
              ],
              "type": "fill"
            }
          ],
          "measurement": "apcupsd",
          "orderByTime": "ASC",
          "policy": "default",
          "query": "from(bucket: \"telegraf\")\r\n  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\r\n  |> filter(fn: (r) => r._measurement == \"apcupsd\" and r.ups_name == \"${upsname}\")\r\n  |> filter(fn: (r) => r._field == \"time_left_ns\")\r\n  |> last()\r\n  |> yield(name: \"last\")\r\n",
          "refId": "A",
          "resultFormat": "table",
          "select": [
            [
              {
                "params": [
                  "time_left_ns"
                ],
                "type": "field"
              },
              {
                "params": [],
                "type": "mean"
              }
            ]
          ],
          "tags": [
            {
              "key": "ups_name",
              "operator": "=~",
              "value": "/^$upsname$/"
            }
          ]
        }
      ],
      "timeFrom": "1m",
      "title": "Runtime Remaining",
      "transformations": [
        {
          "id": "organize",
          "options": {
            "excludeByName": {},
            "indexByName": {},
            "renameByName": {
              "Value": " "
            }
          }
        }
      ],
      "type": "stat"
    },
    {
      "cacheTimeout": null,
      "datasource": "$upsdatasource",
      "fieldConfig": {
        "defaults": {
          "decimals": 1,
          "mappings": [
            {
              "options": {
                "0": {
                  "index": 1,
                  "text": "Not on battery"
                }
              },
              "type": "value"
            },
            {
              "options": {
                "match": "null",
                "result": {
                  "index": 0,
                  "text": "N/A"
                }
              },
              "type": "special"
            }
          ],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "dark-blue",
                "value": null
              },
              {
                "color": "rgba(237, 129, 40, 0.89)",
                "value": 2700000000000
              },
              {
                "color": "semi-dark-red",
                "value": 3600000000000
              }
            ]
          },
          "unit": "ns"
        },
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "time_left_ns"
            },
            "properties": [
              {
                "id": "displayName",
                "value": "${__field.labels.ups_name}"
              }
            ]
          }
        ]
      },
      "gridPos": {
        "h": 6,
        "w": 4,
        "x": 17,
        "y": 0
      },
      "hideTimeOverride": true,
      "id": 56,
      "interval": null,
      "links": [],
      "maxDataPoints": 100,
      "options": {
        "colorMode": "background",
        "fieldOptions": {
          "calcs": [
            "mean"
          ]
        },
        "graphMode": "none",
        "justifyMode": "auto",
        "orientation": "horizontal",
        "reduceOptions": {
          "calcs": [
            "last"
          ],
          "fields": "",
          "values": false
        },
        "text": {},
        "textMode": "auto"
      },
      "pluginVersion": "8.1.3",
      "targets": [
        {
          "groupBy": [
            {
              "params": [
                "$__interval"
              ],
              "type": "time"
            },
            {
              "params": [
                "none"
              ],
              "type": "fill"
            }
          ],
          "measurement": "apcupsd",
          "orderByTime": "ASC",
          "policy": "default",
          "query": "from(bucket: \"telegraf\")\r\n  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\r\n  |> filter(fn: (r) => r._measurement == \"apcupsd\" and r.ups_name == \"${upsname}\")\r\n  |> filter(fn: (r) => r._field == \"time_on_battery_ns\")\r\n  |> last()\r\n  |> yield(name: \"last\")\r\n",
          "refId": "A",
          "resultFormat": "table",
          "select": [
            [
              {
                "params": [
                  "time_left_ns"
                ],
                "type": "field"
              },
              {
                "params": [],
                "type": "mean"
              }
            ]
          ],
          "tags": [
            {
              "key": "ups_name",
              "operator": "=~",
              "value": "/^$upsname$/"
            }
          ]
        }
      ],
      "timeFrom": "1m",
      "title": "Time on Battery",
      "transformations": [
        {
          "id": "organize",
          "options": {
            "excludeByName": {},
            "indexByName": {},
            "renameByName": {
              "Value": " "
            }
          }
        }
      ],
      "type": "stat"
    },
    {
      "cacheTimeout": null,
      "datasource": "$upsdatasource",
      "description": "",
      "fieldConfig": {
        "defaults": {
          "decimals": 1,
          "mappings": [
            {
              "options": {
                "match": "null",
                "result": {
                  "text": "N/A"
                }
              },
              "type": "special"
            }
          ],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "red",
                "value": null
              },
              {
                "color": "yellow",
                "value": 12
              },
              {
                "color": "green",
                "value": 13
              }
            ]
          },
          "unit": "volt"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 3,
        "w": 3,
        "x": 21,
        "y": 0
      },
      "hideTimeOverride": true,
      "id": 54,
      "interval": null,
      "links": [],
      "maxDataPoints": 100,
      "options": {
        "colorMode": "value",
        "fieldOptions": {
          "calcs": [
            "lastNotNull"
          ]
        },
        "graphMode": "none",
        "justifyMode": "auto",
        "orientation": "horizontal",
        "reduceOptions": {
          "calcs": [
            "mean"
          ],
          "fields": "",
          "values": false
        },
        "text": {},
        "textMode": "auto"
      },
      "pluginVersion": "8.1.3",
      "targets": [
        {
          "alias": "Volts",
          "groupBy": [
            {
              "params": [
                "$__interval"
              ],
              "type": "time"
            },
            {
              "params": [
                "null"
              ],
              "type": "fill"
            }
          ],
          "hide": false,
          "measurement": "apcupsd",
          "orderByTime": "ASC",
          "policy": "default",
          "query": "from(bucket: \"telegraf\")\r\n  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\r\n  |> filter(fn: (r) => r._measurement == \"apcupsd\" and r.ups_name == \"${upsname}\")\r\n  |> filter(fn: (r) => r._field == \"battery_voltage\")\r\n  |> last()\r\n  |> yield(name: \"last\")\r\n",
          "rawQuery": false,
          "refId": "A",
          "resultFormat": "time_series",
          "select": [
            [
              {
                "params": [
                  "battery_voltage"
                ],
                "type": "field"
              },
              {
                "params": [],
                "type": "mean"
              }
            ]
          ],
          "tags": [
            {
              "key": "ups_name",
              "operator": "=~",
              "value": "/^$upsname$/"
            }
          ]
        }
      ],
      "timeFrom": "now-1m",
      "title": "Battery Voltage",
      "transformations": [
        {
          "id": "organize",
          "options": {
            "excludeByName": {},
            "indexByName": {},
            "renameByName": {
              "Value": " ",
              "battery_voltage {host=\"ubuntu-magnum-20\", model=\"Smart-UPS 1000 XL\", serial=\"AS0539232598\", status=\"ONLINE\", ups_name=\"UPSTower\"}": " ",
              "battery_voltage {host=\"ubuntu-magnum-20\", model=\"Smart-UPS 1500 RM\", serial=\"AS0633131078\", status=\"ONLINE\", ups_name=\"UPS Rack\"}": " "
            }
          }
        }
      ],
      "type": "stat"
    },
    {
      "cacheTimeout": null,
      "datasource": "${DS_INFLUXDB-FLUXED}",
      "description": "",
      "fieldConfig": {
        "defaults": {
          "mappings": [
            {
              "options": {
                "match": "null",
                "result": {
                  "text": "N/A"
                }
              },
              "type": "special"
            }
          ],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 375
              }
            ]
          },
          "unit": "none"
        },
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "_value"
            },
            "properties": [
              {
                "id": "displayName",
                "value": "${upsname}"
              }
            ]
          },
          {
            "matcher": {
              "id": "byFrameRefID",
              "options": "Real"
            },
            "properties": [
              {
                "id": "unit",
                "value": "watt"
              },
              {
                "id": "displayName",
                "value": "Real"
              }
            ]
          },
          {
            "matcher": {
              "id": "byFrameRefID",
              "options": "Apparent"
            },
            "properties": [
              {
                "id": "unit",
                "value": "voltamp"
              },
              {
                "id": "displayName",
                "value": "Apparent"
              }
            ]
          }
        ]
      },
      "gridPos": {
        "h": 4,
        "w": 3,
        "x": 21,
        "y": 3
      },
      "hideTimeOverride": true,
      "id": 10,
      "interval": null,
      "links": [],
      "maxDataPoints": 100,
      "options": {
        "colorMode": "value",
        "fieldOptions": {
          "calcs": [
            "lastNotNull"
          ]
        },
        "graphMode": "none",
        "justifyMode": "auto",
        "orientation": "horizontal",
        "reduceOptions": {
          "calcs": [
            "mean"
          ],
          "fields": "",
          "values": false
        },
        "text": {
          "valueSize": 32
        },
        "textMode": "auto"
      },
      "pluginVersion": "8.1.3",
      "targets": [
        {
          "alias": "Watts",
          "groupBy": [
            {
              "params": [
                "$__interval"
              ],
              "type": "time"
            },
            {
              "params": [
                "none"
              ],
              "type": "fill"
            }
          ],
          "hide": false,
          "measurement": "apcupsd",
          "orderByTime": "ASC",
          "policy": "default",
          "query": "from(bucket: \"telegraf\")\r\n  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\r\n  |> filter(fn: (r) => r._measurement == \"apcupsd\" and r.ups_name == \"${upsname}\" and r._field == \"load_percent\")\r\n  |> keep(columns: [\"_time\",\"_value\"])\r\n  |> map(fn: (r) => ({ r with _value: (r._value / 100.0) * float(v: ${maxwatt})}))\r\n  |> yield(name: \"last\")\r\n",
          "rawQuery": false,
          "refId": "Real",
          "resultFormat": "time_series",
          "select": [
            [
              {
                "params": [
                  "load_percent"
                ],
                "type": "field"
              },
              {
                "params": [],
                "type": "mean"
              },
              {
                "params": [
                  " / 100*$maxwatt"
                ],
                "type": "math"
              }
            ]
          ],
          "tags": [
            {
              "key": "ups_name",
              "operator": "=~",
              "value": "/^$upsname$/"
            }
          ]
        },
        {
          "hide": false,
          "query": "from(bucket: \"telegraf\")\r\n  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\r\n  |> filter(fn: (r) => r._measurement == \"apcupsd\" and r.ups_name == \"${upsname}\" and r._field == \"load_percent\")\r\n  |> keep(columns: [\"_time\",\"_value\"])\r\n  |> map(fn: (r) => ({ r with _value: (r._value / 100.0) * float(v: ${maxvoltamp})}))\r\n  |> keep(columns: [\"_value\"])\r\n  |> yield(name: \"last\")\r\n",
          "refId": "Apparent"
        }
      ],
      "timeFrom": "now-1m",
      "title": "Current UPS Load",
      "transformations": [
        {
          "id": "organize",
          "options": {
            "excludeByName": {},
            "indexByName": {},
            "renameByName": {
              "Value": " ",
              "load_percent {host=\"ubuntu-magnum-20\", model=\"Smart-UPS 1000 XL\", serial=\"AS0539232598\", status=\"ONLINE\", ups_name=\"UPSTower\"}": " ",
              "load_percent {host=\"ubuntu-magnum-20\", model=\"Smart-UPS 1500 RM\", serial=\"AS0633131078\", status=\"ONLINE\", ups_name=\"UPS Rack\"}": " "
            }
          }
        }
      ],
      "type": "stat"
    },
    {
      "datasource": "$upsdatasource",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisLabel": "",
            "axisPlacement": "auto",
            "barAlignment": 0,
            "drawStyle": "line",
            "fillOpacity": 40,
            "gradientMode": "none",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "lineInterpolation": "linear",
            "lineWidth": 1,
            "pointSize": 5,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "never",
            "spanNulls": false,
            "stacking": {
              "group": "A",
              "mode": "none"
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "links": [],
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          },
          "unit": "ns"
        },
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "Value"
            },
            "properties": [
              {
                "id": "displayName",
                "value": "${upsname}"
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "APC.mean"
            },
            "properties": [
              {
                "id": "color",
                "value": {
                  "fixedColor": "rgb(0, 218, 255)",
                  "mode": "fixed"
                }
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "UPS Load"
            },
            "properties": [
              {
                "id": "color",
                "value": {
                  "fixedColor": "#70dbed",
                  "mode": "fixed"
                }
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "Minutes"
            },
            "properties": [
              {
                "id": "unit",
                "value": "watt"
              },
              {
                "id": "custom.axisPlacement",
                "value": "hidden"
              },
              {
                "id": "custom.axisLabel",
                "value": "Watts"
              }
            ]
          }
        ]
      },
      "gridPos": {
        "h": 7,
        "w": 11,
        "x": 0,
        "y": 6
      },
      "hideTimeOverride": false,
      "id": 49,
      "links": [],
      "options": {
        "legend": {
          "calcs": [
            "mean",
            "max",
            "min"
          ],
          "displayMode": "hidden",
          "placement": "bottom"
        },
        "tooltip": {
          "mode": "single"
        }
      },
      "pluginVersion": "8.1.3",
      "targets": [
        {
          "alias": "Runtime Remaining",
          "groupBy": [
            {
              "params": [
                "$__interval"
              ],
              "type": "time"
            },
            {
              "params": [
                "none"
              ],
              "type": "fill"
            }
          ],
          "measurement": "apcupsd",
          "orderByTime": "ASC",
          "policy": "default",
          "query": "from(bucket: \"telegraf\")\r\n  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\r\n  |> filter(fn: (r) => r._measurement == \"apcupsd\" and r.ups_name == \"${upsname}\")\r\n  |> filter(fn: (r) => r._field == \"time_left_ns\")\r\n  |> keep(columns: [\"_time\",\"_value\",\"battery_charge_percent\",\"upsname\"])\r\n  |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)\r\n  |> yield(name: \"mean\")\r\n",
          "rawQuery": false,
          "refId": "A",
          "resultFormat": "time_series",
          "select": [
            [
              {
                "params": [
                  "time_left_ns"
                ],
                "type": "field"
              },
              {
                "params": [],
                "type": "mean"
              }
            ]
          ],
          "tags": [
            {
              "key": "ups_name",
              "operator": "=~",
              "value": "/^$upsname$/"
            }
          ]
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "Runtime Remaining",
      "transformations": [],
      "type": "timeseries"
    },
    {
      "datasource": "$upsdatasource",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds",
            "seriesBy": "last"
          },
          "custom": {
            "axisLabel": "",
            "axisPlacement": "auto",
            "barAlignment": 0,
            "drawStyle": "line",
            "fillOpacity": 40,
            "gradientMode": "none",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "lineInterpolation": "linear",
            "lineWidth": 1,
            "pointSize": 5,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "never",
            "spanNulls": false,
            "stacking": {
              "group": "A",
              "mode": "none"
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "links": [],
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "semi-dark-red",
                "value": null
              },
              {
                "color": "#EAB839",
                "value": 200
              },
              {
                "color": "green",
                "value": 220
              }
            ]
          },
          "unit": "volt"
        },
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "Value"
            },
            "properties": [
              {
                "id": "displayName",
                "value": "${upsname}"
              }
            ]
          }
        ]
      },
      "gridPos": {
        "h": 7,
        "w": 10,
        "x": 11,
        "y": 6
      },
      "id": 50,
      "links": [],
      "options": {
        "legend": {
          "calcs": [
            "mean",
            "max",
            "min"
          ],
          "displayMode": "hidden",
          "placement": "bottom"
        },
        "tooltip": {
          "mode": "single"
        }
      },
      "pluginVersion": "8.1.3",
      "targets": [
        {
          "alias": "Battery Charge",
          "groupBy": [
            {
              "params": [
                "$__interval"
              ],
              "type": "time"
            },
            {
              "params": [
                "none"
              ],
              "type": "fill"
            }
          ],
          "measurement": "apcupsd",
          "orderByTime": "ASC",
          "policy": "default",
          "query": "from(bucket: \"telegraf\")\r\n  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\r\n  |> filter(fn: (r) => r._measurement == \"apcupsd\" and r.ups_name == \"${upsname}\")\r\n  |> filter(fn: (r) => r._field == \"input_voltage\")\r\n  |> keep(columns: [\"_time\",\"_value\",\"input_voltage\",\"upsname\"])\r\n  |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)\r\n  |> yield(name: \"mean\")\r\n",
          "rawQuery": false,
          "refId": "A",
          "resultFormat": "time_series",
          "select": [
            [
              {
                "params": [
                  "battery_charge_percent"
                ],
                "type": "field"
              },
              {
                "params": [],
                "type": "mean"
              }
            ]
          ],
          "tags": [
            {
              "key": "ups_name",
              "operator": "=~",
              "value": "/^$upsname$/"
            }
          ]
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "Input Voltage",
      "transformations": [],
      "type": "timeseries"
    },
    {
      "cacheTimeout": null,
      "datasource": "$upsdatasource",
      "description": "",
      "fieldConfig": {
        "defaults": {
          "decimals": 1,
          "mappings": [
            {
              "options": {
                "match": "null",
                "result": {
                  "text": "N/A"
                }
              },
              "type": "special"
            }
          ],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "red",
                "value": null
              },
              {
                "color": "yellow",
                "value": 200
              },
              {
                "color": "green",
                "value": 220
              }
            ]
          },
          "unit": "volt"
        },
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "input_voltage"
            },
            "properties": [
              {
                "id": "displayName",
                "value": "${__field.labels.ups_name}"
              }
            ]
          }
        ]
      },
      "gridPos": {
        "h": 3,
        "w": 3,
        "x": 21,
        "y": 7
      },
      "hideTimeOverride": true,
      "id": 43,
      "interval": null,
      "links": [],
      "maxDataPoints": 100,
      "options": {
        "colorMode": "value",
        "fieldOptions": {
          "calcs": [
            "lastNotNull"
          ]
        },
        "graphMode": "none",
        "justifyMode": "auto",
        "orientation": "horizontal",
        "reduceOptions": {
          "calcs": [
            "mean"
          ],
          "fields": "",
          "values": false
        },
        "text": {},
        "textMode": "auto"
      },
      "pluginVersion": "8.1.3",
      "targets": [
        {
          "alias": "Volts",
          "groupBy": [
            {
              "params": [
                "$__interval"
              ],
              "type": "time"
            },
            {
              "params": [
                "null"
              ],
              "type": "fill"
            }
          ],
          "hide": false,
          "measurement": "apcupsd",
          "orderByTime": "ASC",
          "policy": "default",
          "query": "from(bucket: \"telegraf\")\r\n  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\r\n  |> filter(fn: (r) => r._measurement == \"apcupsd\" and r.ups_name == \"${upsname}\")\r\n  |> filter(fn: (r) => r._field == \"input_voltage\")\r\n  |> last()\r\n  |> yield(name: \"last\")\r\n",
          "rawQuery": false,
          "refId": "A",
          "resultFormat": "time_series",
          "select": [
            [
              {
                "params": [
                  "input_voltage"
                ],
                "type": "field"
              },
              {
                "params": [],
                "type": "mean"
              }
            ]
          ],
          "tags": [
            {
              "key": "ups_name",
              "operator": "=~",
              "value": "/^$upsname$/"
            }
          ]
        }
      ],
      "timeFrom": "now-1m",
      "title": "Input Voltage",
      "transformations": [],
      "type": "stat"
    },
    {
      "cacheTimeout": null,
      "datasource": "$upsdatasource",
      "description": "",
      "fieldConfig": {
        "defaults": {
          "decimals": 1,
          "mappings": [
            {
              "options": {
                "match": "null",
                "result": {
                  "text": "N/A"
                }
              },
              "type": "special"
            }
          ],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "red",
                "value": null
              },
              {
                "color": "yellow",
                "value": 12
              },
              {
                "color": "green",
                "value": 13
              }
            ]
          },
          "unit": "hertz"
        },
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "input_frequency"
            },
            "properties": [
              {
                "id": "displayName",
                "value": "${__field.labels.ups_name}"
              }
            ]
          }
        ]
      },
      "gridPos": {
        "h": 3,
        "w": 3,
        "x": 21,
        "y": 10
      },
      "hideTimeOverride": true,
      "id": 44,
      "interval": null,
      "links": [],
      "maxDataPoints": 100,
      "options": {
        "colorMode": "value",
        "fieldOptions": {
          "calcs": [
            "lastNotNull"
          ]
        },
        "graphMode": "none",
        "justifyMode": "auto",
        "orientation": "horizontal",
        "reduceOptions": {
          "calcs": [
            "mean"
          ],
          "fields": "",
          "values": false
        },
        "text": {},
        "textMode": "auto"
      },
      "pluginVersion": "8.1.3",
      "targets": [
        {
          "alias": "Hz",
          "groupBy": [
            {
              "params": [
                "$__interval"
              ],
              "type": "time"
            },
            {
              "params": [
                "null"
              ],
              "type": "fill"
            }
          ],
          "hide": false,
          "measurement": "apcupsd",
          "orderByTime": "ASC",
          "policy": "default",
          "query": "from(bucket: \"telegraf\")\r\n  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\r\n  |> filter(fn: (r) => r._measurement == \"apcupsd\" and r.ups_name == \"${upsname}\")\r\n  |> filter(fn: (r) => r._field == \"input_frequency\")\r\n  |> last()\r\n  |> yield(name: \"last\")\r\n",
          "rawQuery": false,
          "refId": "A",
          "resultFormat": "time_series",
          "select": [
            [
              {
                "params": [
                  "input_frequency"
                ],
                "type": "field"
              },
              {
                "params": [],
                "type": "mean"
              }
            ]
          ],
          "tags": [
            {
              "key": "ups_name",
              "operator": "=~",
              "value": "/^$upsname$/"
            }
          ]
        }
      ],
      "timeFrom": "now-1m",
      "title": "Input Frequency",
      "transformations": [
        {
          "id": "organize",
          "options": {
            "excludeByName": {},
            "indexByName": {},
            "renameByName": {
              "Value": " "
            }
          }
        }
      ],
      "type": "stat"
    },
    {
      "datasource": "$upsdatasource",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisLabel": "",
            "axisPlacement": "auto",
            "barAlignment": 0,
            "drawStyle": "line",
            "fillOpacity": 40,
            "gradientMode": "none",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "lineInterpolation": "linear",
            "lineWidth": 1,
            "pointSize": 5,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "never",
            "spanNulls": false,
            "stacking": {
              "group": "A",
              "mode": "none"
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "links": [],
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 22
              },
              {
                "color": "#EAB839",
                "value": 23
              },
              {
                "color": "light-green",
                "value": 24
              }
            ]
          },
          "unit": "volt"
        },
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "Value"
            },
            "properties": [
              {
                "id": "displayName",
                "value": "${upsname}"
              }
            ]
          }
        ]
      },
      "gridPos": {
        "h": 7,
        "w": 11,
        "x": 0,
        "y": 13
      },
      "id": 52,
      "links": [],
      "options": {
        "legend": {
          "calcs": [
            "mean",
            "max",
            "min"
          ],
          "displayMode": "hidden",
          "placement": "bottom"
        },
        "tooltip": {
          "mode": "single"
        }
      },
      "pluginVersion": "8.1.3",
      "targets": [
        {
          "alias": "Battery Charge",
          "groupBy": [
            {
              "params": [
                "$__interval"
              ],
              "type": "time"
            },
            {
              "params": [
                "none"
              ],
              "type": "fill"
            }
          ],
          "measurement": "apcupsd",
          "orderByTime": "ASC",
          "policy": "default",
          "query": "from(bucket: \"telegraf\")\r\n  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\r\n  |> filter(fn: (r) => r._measurement == \"apcupsd\" and r.ups_name == \"${upsname}\")\r\n  |> filter(fn: (r) => r._field == \"battery_voltage\")\r\n  |> keep(columns: [\"_time\",\"_value\",\"battery_voltage\",\"upsname\"])\r\n  |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)\r\n  |> yield(name: \"mean\")\r\n",
          "rawQuery": false,
          "refId": "A",
          "resultFormat": "time_series",
          "select": [
            [
              {
                "params": [
                  "battery_charge_percent"
                ],
                "type": "field"
              },
              {
                "params": [],
                "type": "mean"
              }
            ]
          ],
          "tags": [
            {
              "key": "ups_name",
              "operator": "=~",
              "value": "/^$upsname$/"
            }
          ]
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "Battery Voltage",
      "transformations": [],
      "type": "timeseries"
    },
    {
      "datasource": "$upsdatasource",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisLabel": "",
            "axisPlacement": "auto",
            "barAlignment": 0,
            "drawStyle": "line",
            "fillOpacity": 40,
            "gradientMode": "none",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "lineInterpolation": "linear",
            "lineWidth": 1,
            "pointSize": 5,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "never",
            "spanNulls": false,
            "stacking": {
              "group": "A",
              "mode": "none"
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "links": [],
          "mappings": [],
          "max": 60,
          "min": 40,
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 190
              },
              {
                "color": "#EAB839",
                "value": 219
              },
              {
                "color": "light-green",
                "value": 220
              }
            ]
          },
          "unit": "hertz"
        },
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "Value"
            },
            "properties": [
              {
                "id": "displayName",
                "value": "${upsname}"
              }
            ]
          }
        ]
      },
      "gridPos": {
        "h": 7,
        "w": 10,
        "x": 11,
        "y": 13
      },
      "id": 57,
      "links": [],
      "options": {
        "legend": {
          "calcs": [
            "mean",
            "max",
            "min"
          ],
          "displayMode": "hidden",
          "placement": "bottom"
        },
        "tooltip": {
          "mode": "single"
        }
      },
      "pluginVersion": "8.1.3",
      "targets": [
        {
          "alias": "Battery Charge",
          "groupBy": [
            {
              "params": [
                "$__interval"
              ],
              "type": "time"
            },
            {
              "params": [
                "none"
              ],
              "type": "fill"
            }
          ],
          "measurement": "apcupsd",
          "orderByTime": "ASC",
          "policy": "default",
          "query": "from(bucket: \"telegraf\")\r\n  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\r\n  |> filter(fn: (r) => r._measurement == \"apcupsd\" and r.ups_name == \"${upsname}\")\r\n  |> filter(fn: (r) => r._field == \"input_frequency\")\r\n  |> keep(columns: [\"_time\",\"_value\",\"input_frequency\",\"upsname\"])\r\n  |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)\r\n  |> yield(name: \"mean\")\r\n",
          "rawQuery": false,
          "refId": "A",
          "resultFormat": "time_series",
          "select": [
            [
              {
                "params": [
                  "battery_charge_percent"
                ],
                "type": "field"
              },
              {
                "params": [],
                "type": "mean"
              }
            ]
          ],
          "tags": [
            {
              "key": "ups_name",
              "operator": "=~",
              "value": "/^$upsname$/"
            }
          ]
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "Input Frequency",
      "transformations": [],
      "type": "timeseries"
    },
    {
      "cacheTimeout": null,
      "datasource": "$upsdatasource",
      "description": "",
      "fieldConfig": {
        "defaults": {
          "decimals": 1,
          "mappings": [
            {
              "options": {
                "match": "null",
                "result": {
                  "text": "N/A"
                }
              },
              "type": "special"
            }
          ],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "red",
                "value": null
              },
              {
                "color": "yellow",
                "value": 200
              },
              {
                "color": "green",
                "value": 220
              }
            ]
          },
          "unit": "volt"
        },
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "output_voltage"
            },
            "properties": [
              {
                "id": "displayName",
                "value": "${__field.labels.ups_name}"
              }
            ]
          }
        ]
      },
      "gridPos": {
        "h": 3,
        "w": 3,
        "x": 21,
        "y": 13
      },
      "hideTimeOverride": true,
      "id": 45,
      "interval": null,
      "links": [],
      "maxDataPoints": 100,
      "options": {
        "colorMode": "value",
        "fieldOptions": {
          "calcs": [
            "lastNotNull"
          ]
        },
        "graphMode": "none",
        "justifyMode": "auto",
        "orientation": "horizontal",
        "reduceOptions": {
          "calcs": [
            "mean"
          ],
          "fields": "",
          "values": false
        },
        "text": {},
        "textMode": "auto"
      },
      "pluginVersion": "8.1.3",
      "targets": [
        {
          "alias": "Volts",
          "groupBy": [
            {
              "params": [
                "$__interval"
              ],
              "type": "time"
            },
            {
              "params": [
                "null"
              ],
              "type": "fill"
            }
          ],
          "hide": false,
          "measurement": "apcupsd",
          "orderByTime": "ASC",
          "policy": "default",
          "query": "from(bucket: \"telegraf\")\r\n  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\r\n  |> filter(fn: (r) => r._measurement == \"apcupsd\" and r.ups_name == \"${upsname}\")\r\n  |> filter(fn: (r) => r._field == \"output_voltage\")\r\n  |> last()\r\n  |> yield(name: \"last\")\r\n",
          "rawQuery": false,
          "refId": "A",
          "resultFormat": "time_series",
          "select": [
            [
              {
                "params": [
                  "output_voltage"
                ],
                "type": "field"
              },
              {
                "params": [],
                "type": "mean"
              }
            ]
          ],
          "tags": [
            {
              "key": "ups_name",
              "operator": "=~",
              "value": "/^$upsname$/"
            }
          ]
        }
      ],
      "timeFrom": "now-1m",
      "title": "Output Voltage",
      "transformations": [
        {
          "id": "organize",
          "options": {
            "excludeByName": {},
            "indexByName": {},
            "renameByName": {
              "Value": " "
            }
          }
        }
      ],
      "type": "stat"
    },
    {
      "cacheTimeout": null,
      "datasource": "$upsdatasource",
      "description": "",
      "fieldConfig": {
        "defaults": {
          "decimals": 1,
          "mappings": [
            {
              "options": {
                "match": "null",
                "result": {
                  "text": "N/A"
                }
              },
              "type": "special"
            }
          ],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "yellow",
                "value": 35
              },
              {
                "color": "semi-dark-red",
                "value": 45
              }
            ]
          },
          "unit": "celsius"
        },
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "internal_temp"
            },
            "properties": [
              {
                "id": "displayName",
                "value": "${__field.labels.ups_name}"
              }
            ]
          }
        ]
      },
      "gridPos": {
        "h": 3,
        "w": 3,
        "x": 21,
        "y": 16
      },
      "hideTimeOverride": true,
      "id": 46,
      "interval": null,
      "links": [],
      "maxDataPoints": 100,
      "options": {
        "colorMode": "value",
        "fieldOptions": {
          "calcs": [
            "lastNotNull"
          ]
        },
        "graphMode": "none",
        "justifyMode": "auto",
        "orientation": "horizontal",
        "reduceOptions": {
          "calcs": [
            "mean"
          ],
          "fields": "",
          "values": false
        },
        "text": {},
        "textMode": "auto"
      },
      "pluginVersion": "8.1.3",
      "targets": [
        {
          "alias": "C",
          "groupBy": [
            {
              "params": [
                "$__interval"
              ],
              "type": "time"
            },
            {
              "params": [
                "null"
              ],
              "type": "fill"
            }
          ],
          "hide": false,
          "measurement": "apcupsd",
          "orderByTime": "ASC",
          "policy": "default",
          "query": "from(bucket: \"telegraf\")\r\n  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\r\n  |> filter(fn: (r) => r._measurement == \"apcupsd\" and r.ups_name == \"${upsname}\")\r\n  |> filter(fn: (r) => r._field == \"internal_temp\")\r\n  |> last()\r\n  |> yield(name: \"mean\")\r\n",
          "rawQuery": false,
          "refId": "A",
          "resultFormat": "time_series",
          "select": [
            [
              {
                "params": [
                  "internal_temp"
                ],
                "type": "field"
              },
              {
                "params": [],
                "type": "mean"
              }
            ]
          ],
          "tags": [
            {
              "key": "ups_name",
              "operator": "=~",
              "value": "/^$upsname$/"
            }
          ]
        }
      ],
      "timeFrom": "now-1m",
      "title": "Internal Temp",
      "transformations": [
        {
          "id": "organize",
          "options": {
            "excludeByName": {},
            "indexByName": {},
            "renameByName": {
              "Value": " "
            }
          }
        }
      ],
      "type": "stat"
    },
    {
      "cacheTimeout": null,
      "datasource": "$upsdatasource",
      "description": "",
      "fieldConfig": {
        "defaults": {
          "decimals": 2,
          "mappings": [
            {
              "options": {
                "match": "null",
                "result": {
                  "text": "N/A"
                }
              },
              "type": "special"
            }
          ],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          },
          "unit": "kwatth"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 2,
        "w": 3,
        "x": 21,
        "y": 19
      },
      "hideTimeOverride": true,
      "id": 41,
      "interval": "1h",
      "links": [],
      "options": {
        "colorMode": "value",
        "fieldOptions": {
          "calcs": [
            "sum"
          ]
        },
        "graphMode": "none",
        "justifyMode": "auto",
        "orientation": "horizontal",
        "reduceOptions": {
          "calcs": [
            "sum"
          ],
          "fields": "",
          "values": false
        },
        "text": {},
        "textMode": "auto"
      },
      "pluginVersion": "8.1.3",
      "targets": [
        {
          "groupBy": [
            {
              "params": [
                "$__interval"
              ],
              "type": "time"
            },
            {
              "params": [
                "null"
              ],
              "type": "fill"
            }
          ],
          "hide": false,
          "measurement": "apcupsd",
          "orderByTime": "ASC",
          "policy": "default",
          "query": "from(bucket: \"telegraf\")\r\n  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\r\n  |> filter(fn: (r) => r._measurement == \"apcupsd\" and r.ups_name == \"${upsname}\" and r._field == \"load_percent\")\r\n  |> keep(columns: [\"_time\",\"_value\",\"load_percent\"])\r\n  |> map(fn: (r) => ({ r with _value: ((r._value / 100.0) * float(v: ${maxvoltamp}) / 1000.0)}))\r\n  |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)\r\n  |> yield(name: \"mean\")\r\n",
          "rawQuery": false,
          "refId": "A",
          "resultFormat": "time_series",
          "select": [
            [
              {
                "params": [
                  "load_percent"
                ],
                "type": "field"
              },
              {
                "params": [],
                "type": "mean"
              },
              {
                "params": [
                  "/100*$maxwatt/1000"
                ],
                "type": "math"
              }
            ]
          ],
          "tags": [
            {
              "key": "ups_name",
              "operator": "=~",
              "value": "/^$upsname$/"
            }
          ]
        }
      ],
      "timeFrom": "1d",
      "timeShift": null,
      "title": "Past Day's Usage",
      "transformations": [
        {
          "id": "organize",
          "options": {
            "excludeByName": {},
            "indexByName": {},
            "renameByName": {
              "Value": " "
            }
          }
        }
      ],
      "type": "stat"
    },
    {
      "datasource": "$upsdatasource",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisLabel": "",
            "axisPlacement": "auto",
            "barAlignment": 0,
            "drawStyle": "line",
            "fillOpacity": 40,
            "gradientMode": "none",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "lineInterpolation": "linear",
            "lineWidth": 1,
            "pointSize": 5,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "never",
            "spanNulls": false,
            "stacking": {
              "group": "A",
              "mode": "none"
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "links": [],
          "mappings": [],
          "max": 100,
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          },
          "unit": "percent"
        },
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "Value"
            },
            "properties": [
              {
                "id": "displayName",
                "value": "${upsname}"
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "APC.mean"
            },
            "properties": [
              {
                "id": "color",
                "value": {
                  "fixedColor": "rgb(0, 218, 255)",
                  "mode": "fixed"
                }
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "UPS Load"
            },
            "properties": [
              {
                "id": "color",
                "value": {
                  "fixedColor": "#70dbed",
                  "mode": "fixed"
                }
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "Watts"
            },
            "properties": [
              {
                "id": "unit",
                "value": "watt"
              },
              {
                "id": "custom.axisPlacement",
                "value": "hidden"
              },
              {
                "id": "custom.axisLabel",
                "value": "Watts"
              }
            ]
          }
        ]
      },
      "gridPos": {
        "h": 7,
        "w": 11,
        "x": 0,
        "y": 20
      },
      "id": 48,
      "links": [],
      "options": {
        "legend": {
          "calcs": [
            "mean",
            "max",
            "min"
          ],
          "displayMode": "hidden",
          "placement": "bottom"
        },
        "tooltip": {
          "mode": "single"
        }
      },
      "pluginVersion": "8.1.3",
      "targets": [
        {
          "alias": "Battery Charge",
          "groupBy": [
            {
              "params": [
                "$__interval"
              ],
              "type": "time"
            },
            {
              "params": [
                "none"
              ],
              "type": "fill"
            }
          ],
          "measurement": "apcupsd",
          "orderByTime": "ASC",
          "policy": "default",
          "query": "from(bucket: \"telegraf\")\r\n  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\r\n  |> filter(fn: (r) => r._measurement == \"apcupsd\" and r.ups_name == \"${upsname}\")\r\n  |> filter(fn: (r) => r._field == \"battery_charge_percent\")\r\n  |> keep(columns: [\"_time\",\"_value\",\"battery_charge_percent\",\"upsname\"])\r\n  |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)\r\n  |> yield(name: \"mean\")\r\n",
          "rawQuery": false,
          "refId": "A",
          "resultFormat": "time_series",
          "select": [
            [
              {
                "params": [
                  "battery_charge_percent"
                ],
                "type": "field"
              },
              {
                "params": [],
                "type": "mean"
              }
            ]
          ],
          "tags": [
            {
              "key": "ups_name",
              "operator": "=~",
              "value": "/^$upsname$/"
            }
          ]
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "Battery Charge %",
      "transformations": [],
      "type": "timeseries"
    },
    {
      "datasource": "$upsdatasource",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "custom": {
            "axisLabel": "",
            "axisPlacement": "auto",
            "barAlignment": 0,
            "drawStyle": "line",
            "fillOpacity": 40,
            "gradientMode": "none",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "lineInterpolation": "linear",
            "lineWidth": 1,
            "pointSize": 5,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "never",
            "spanNulls": false,
            "stacking": {
              "group": "A",
              "mode": "none"
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "links": [],
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "semi-dark-red",
                "value": null
              },
              {
                "color": "#EAB839",
                "value": 200
              },
              {
                "color": "green",
                "value": 220
              }
            ]
          },
          "unit": "volt"
        },
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "Value"
            },
            "properties": [
              {
                "id": "displayName",
                "value": "${upsname}"
              }
            ]
          }
        ]
      },
      "gridPos": {
        "h": 7,
        "w": 10,
        "x": 11,
        "y": 20
      },
      "id": 51,
      "links": [],
      "options": {
        "legend": {
          "calcs": [
            "mean",
            "max",
            "min"
          ],
          "displayMode": "hidden",
          "placement": "bottom"
        },
        "tooltip": {
          "mode": "single"
        }
      },
      "pluginVersion": "8.1.3",
      "targets": [
        {
          "alias": "Battery Charge",
          "groupBy": [
            {
              "params": [
                "$__interval"
              ],
              "type": "time"
            },
            {
              "params": [
                "none"
              ],
              "type": "fill"
            }
          ],
          "measurement": "apcupsd",
          "orderByTime": "ASC",
          "policy": "default",
          "query": "from(bucket: \"telegraf\")\r\n  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\r\n  |> filter(fn: (r) => r._measurement == \"apcupsd\" and r.ups_name == \"${upsname}\")\r\n  |> filter(fn: (r) => r._field == \"output_voltage\")\r\n  |> keep(columns: [\"_time\",\"_value\",\"output_voltage\",\"upsname\"])\r\n  |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)\r\n  |> yield(name: \"mean\")\r\n",
          "rawQuery": false,
          "refId": "A",
          "resultFormat": "time_series",
          "select": [
            [
              {
                "params": [
                  "battery_charge_percent"
                ],
                "type": "field"
              },
              {
                "params": [],
                "type": "mean"
              }
            ]
          ],
          "tags": [
            {
              "key": "ups_name",
              "operator": "=~",
              "value": "/^$upsname$/"
            }
          ]
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "Output Voltage",
      "transformations": [],
      "type": "timeseries"
    },
    {
      "cacheTimeout": null,
      "datasource": "$upsdatasource",
      "description": "",
      "fieldConfig": {
        "defaults": {
          "decimals": 2,
          "displayName": "$currency",
          "mappings": [
            {
              "options": {
                "match": "null",
                "result": {
                  "text": ""
                }
              },
              "type": "special"
            }
          ],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          },
          "unit": "none"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 2,
        "w": 3,
        "x": 21,
        "y": 21
      },
      "hideTimeOverride": true,
      "id": 22,
      "interval": "1h",
      "links": [],
      "options": {
        "colorMode": "value",
        "fieldOptions": {
          "calcs": [
            "sum"
          ]
        },
        "graphMode": "none",
        "justifyMode": "center",
        "orientation": "horizontal",
        "reduceOptions": {
          "calcs": [
            "sum"
          ],
          "fields": "",
          "values": false
        },
        "text": {},
        "textMode": "auto"
      },
      "pluginVersion": "8.1.3",
      "targets": [
        {
          "alias": "Costs",
          "groupBy": [
            {
              "params": [
                "$__interval"
              ],
              "type": "time"
            },
            {
              "params": [
                "none"
              ],
              "type": "fill"
            }
          ],
          "hide": false,
          "measurement": "apcupsd",
          "orderByTime": "ASC",
          "policy": "default",
          "query": "from(bucket: \"telegraf\")\r\n  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\r\n  |> filter(fn: (r) => r._measurement == \"apcupsd\" and r.ups_name == \"${upsname}\" and r._field == \"load_percent\")\r\n  |> keep(columns: [\"_time\",\"_value\"])\r\n  |> map(fn: (r) => ({ r with _value: ((r._value / 100.0) * float(v: ${maxvoltamp}) / 1000.0) * ${kwhprice}}))\r\n  |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)\r\n  |> yield(name: \"mean\")\r\n",
          "rawQuery": false,
          "refId": "A",
          "resultFormat": "time_series",
          "select": [
            [
              {
                "params": [
                  "load_percent"
                ],
                "type": "field"
              },
              {
                "params": [],
                "type": "mean"
              },
              {
                "params": [
                  "/100*$maxwatt/1000*$kwhprice"
                ],
                "type": "math"
              }
            ]
          ],
          "tags": [
            {
              "key": "ups_name",
              "operator": "=~",
              "value": "/^$upsname$/"
            }
          ]
        }
      ],
      "timeFrom": "1d",
      "title": "Past Day's Cost",
      "type": "stat"
    },
    {
      "datasource": "${DS_INFLUXDB-FLUXED}",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisLabel": "",
            "axisPlacement": "auto",
            "barAlignment": 0,
            "drawStyle": "line",
            "fillOpacity": 40,
            "gradientMode": "none",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "lineInterpolation": "linear",
            "lineWidth": 1,
            "pointSize": 5,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "never",
            "spanNulls": false,
            "stacking": {
              "group": "A",
              "mode": "none"
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "links": [],
          "mappings": [],
          "min": 0,
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          },
          "unit": "percent"
        },
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "Value"
            },
            "properties": [
              {
                "id": "displayName",
                "value": "${upsname}"
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "APC.mean"
            },
            "properties": [
              {
                "id": "color",
                "value": {
                  "fixedColor": "rgb(0, 218, 255)",
                  "mode": "fixed"
                }
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "UPS Load"
            },
            "properties": [
              {
                "id": "color",
                "value": {
                  "fixedColor": "#70dbed",
                  "mode": "fixed"
                }
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "Watts"
            },
            "properties": [
              {
                "id": "unit",
                "value": "watt"
              },
              {
                "id": "custom.axisPlacement",
                "value": "hidden"
              },
              {
                "id": "custom.axisLabel",
                "value": "Watts"
              }
            ]
          }
        ]
      },
      "gridPos": {
        "h": 6,
        "w": 11,
        "x": 0,
        "y": 27
      },
      "id": 2,
      "links": [],
      "options": {
        "legend": {
          "calcs": [
            "mean",
            "max",
            "min"
          ],
          "displayMode": "hidden",
          "placement": "bottom"
        },
        "tooltip": {
          "mode": "single"
        }
      },
      "pluginVersion": "8.1.3",
      "repeat": null,
      "targets": [
        {
          "alias": "UPS Load",
          "groupBy": [
            {
              "params": [
                "$__interval"
              ],
              "type": "time"
            },
            {
              "params": [
                "none"
              ],
              "type": "fill"
            }
          ],
          "measurement": "apcupsd",
          "orderByTime": "ASC",
          "policy": "default",
          "query": "from(bucket: \"telegraf\")\r\n  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\r\n  |> filter(fn: (r) => r._measurement == \"apcupsd\" and r.ups_name == \"${upsname}\")\r\n  |> filter(fn: (r) => r._field == \"load_percent\")\r\n  |> keep(columns: [\"_time\",\"_value\",\"battery_charge_percent\",\"upsname\"])\r\n  |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)\r\n  |> yield(name: \"mean\")\r\n",
          "refId": "A",
          "resultFormat": "time_series",
          "select": [
            [
              {
                "params": [
                  "load_percent"
                ],
                "type": "field"
              },
              {
                "params": [],
                "type": "mean"
              }
            ]
          ],
          "tags": [
            {
              "key": "ups_name",
              "operator": "=~",
              "value": "/^$upsname$/"
            }
          ]
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "UPS Load %",
      "transformations": [],
      "type": "timeseries"
    },
    {
      "datasource": "$upsdatasource",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisLabel": "",
            "axisPlacement": "left",
            "barAlignment": 1,
            "drawStyle": "bars",
            "fillOpacity": 0,
            "gradientMode": "none",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "lineInterpolation": "linear",
            "lineWidth": 5,
            "pointSize": 5,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "never",
            "spanNulls": false,
            "stacking": {
              "group": "A",
              "mode": "none"
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "decimals": 1,
          "links": [],
          "mappings": [],
          "min": 0,
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              }
            ]
          },
          "unit": "kwatth"
        },
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "Value"
            },
            "properties": [
              {
                "id": "displayName",
                "value": "${upsname}"
              },
              {
                "id": "color",
                "value": {
                  "fixedColor": "semi-dark-yellow",
                  "mode": "fixed"
                }
              }
            ]
          }
        ]
      },
      "gridPos": {
        "h": 7,
        "w": 10,
        "x": 11,
        "y": 27
      },
      "hideTimeOverride": false,
      "id": 33,
      "interval": "1d",
      "links": [],
      "options": {
        "legend": {
          "calcs": [
            "min",
            "mean",
            "max"
          ],
          "displayMode": "list",
          "placement": "bottom"
        },
        "tooltip": {
          "mode": "single"
        }
      },
      "pluginVersion": "8.1.2",
      "targets": [
        {
          "alias": "kWh",
          "dsType": "influxdb",
          "groupBy": [
            {
              "params": [
                "$__interval"
              ],
              "type": "time"
            },
            {
              "params": [
                "null"
              ],
              "type": "fill"
            }
          ],
          "hide": false,
          "measurement": "apcupsd",
          "orderByTime": "ASC",
          "policy": "default",
          "query": "from(bucket: \"telegraf\")\r\n  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\r\n  |> filter(fn: (r) => r._measurement == \"apcupsd\" and r.ups_name == \"${upsname}\" and r._field == \"load_percent\")\r\n  |> aggregateWindow(\r\n    every: 1h,\r\n    fn: (tables=<-, column) =>\r\n        tables\r\n            |> integral(unit: 1h)\r\n            |> map(fn: (r) => ({ r with _value: ((r._value / 100.0) * float(v: ${maxvoltamp}) / 1000.0)})))\r\n  |> keep(columns: [\"_time\",\"_value\"])\r\n  |> aggregateWindow(every: v.windowPeriod, fn: sum, createEmpty: false)\r\n//  |> keep(columns: [\"_time\",\"_value\",\"upsname\"])\r\n//  |> map(fn: (r) => ({ r with _value: ((r._value / 100.0) * float(v: ${maxvoltamp}) / 1000.0 * 24.0)}))\r\n//  |> keep(columns: [\"_time\",\"_value\"])\r\n//  |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)\r\n//  |> yield(name: \"mean\")\r\n",
          "refId": "A",
          "resultFormat": "time_series",
          "select": [
            [
              {
                "params": [
                  "load_percent"
                ],
                "type": "field"
              },
              {
                "params": [],
                "type": "mean"
              },
              {
                "params": [
                  "/100*$maxwatt/1000*24"
                ],
                "type": "math"
              }
            ]
          ],
          "tags": [
            {
              "key": "ups_name",
              "operator": "=~",
              "value": "/^$upsname$/"
            }
          ]
        }
      ],
      "timeFrom": "1M",
      "timeShift": null,
      "title": "Power Consumption",
      "transformations": [],
      "type": "timeseries"
    },
    {
      "datasource": "$upsdatasource",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisLabel": "",
            "axisPlacement": "auto",
            "barAlignment": 0,
            "drawStyle": "line",
            "fillOpacity": 40,
            "gradientMode": "none",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "lineInterpolation": "linear",
            "lineWidth": 1,
            "pointSize": 5,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "never",
            "spanNulls": false,
            "stacking": {
              "group": "A",
              "mode": "none"
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "links": [],
          "mappings": [
            {
              "options": {
                "0": {
                  "index": 0,
                  "text": "Not on battery"
                }
              },
              "type": "value"
            }
          ],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 22
              },
              {
                "color": "#EAB839",
                "value": 23
              },
              {
                "color": "light-green",
                "value": 24
              }
            ]
          },
          "unit": "ns"
        },
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "Value"
            },
            "properties": [
              {
                "id": "displayName",
                "value": "${upsname}"
              }
            ]
          }
        ]
      },
      "gridPos": {
        "h": 7,
        "w": 11,
        "x": 0,
        "y": 33
      },
      "id": 53,
      "links": [],
      "options": {
        "legend": {
          "calcs": [
            "mean",
            "max",
            "min"
          ],
          "displayMode": "hidden",
          "placement": "bottom"
        },
        "tooltip": {
          "mode": "single"
        }
      },
      "pluginVersion": "8.1.3",
      "targets": [
        {
          "alias": "Battery Charge",
          "groupBy": [
            {
              "params": [
                "$__interval"
              ],
              "type": "time"
            },
            {
              "params": [
                "none"
              ],
              "type": "fill"
            }
          ],
          "measurement": "apcupsd",
          "orderByTime": "ASC",
          "policy": "default",
          "query": "from(bucket: \"telegraf\")\r\n  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\r\n  |> filter(fn: (r) => r._measurement == \"apcupsd\" and r.ups_name == \"${upsname}\")\r\n  |> filter(fn: (r) => r._field == \"time_on_battery_ns\")\r\n  |> keep(columns: [\"_time\",\"_value\",\"time_on_battery_ns\",\"upsname\"])\r\n  |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)\r\n  |> yield(name: \"mean\")\r\n",
          "rawQuery": false,
          "refId": "A",
          "resultFormat": "time_series",
          "select": [
            [
              {
                "params": [
                  "battery_charge_percent"
                ],
                "type": "field"
              },
              {
                "params": [],
                "type": "mean"
              }
            ]
          ],
          "tags": [
            {
              "key": "ups_name",
              "operator": "=~",
              "value": "/^$upsname$/"
            }
          ]
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "Time on Battery",
      "transformations": [],
      "type": "timeseries"
    },
    {
      "datasource": "$upsdatasource",
      "description": "",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisLabel": "",
            "axisPlacement": "auto",
            "barAlignment": 0,
            "drawStyle": "bars",
            "fillOpacity": 100,
            "gradientMode": "none",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "lineInterpolation": "linear",
            "lineWidth": 1,
            "pointSize": 5,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "never",
            "spanNulls": false,
            "stacking": {
              "group": "A",
              "mode": "none"
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "decimals": 1,
          "links": [],
          "mappings": [],
          "min": 0,
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              }
            ]
          },
          "unit": "kwatth"
        },
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "Value"
            },
            "properties": [
              {
                "id": "displayName",
                "value": "${upsname}"
              },
              {
                "id": "color",
                "value": {
                  "fixedColor": "semi-dark-yellow",
                  "mode": "fixed"
                }
              }
            ]
          }
        ]
      },
      "gridPos": {
        "h": 7,
        "w": 10,
        "x": 11,
        "y": 34
      },
      "hideTimeOverride": false,
      "id": 34,
      "interval": "1M",
      "links": [],
      "options": {
        "legend": {
          "calcs": [
            "mean",
            "lastNotNull",
            "max",
            "sum"
          ],
          "displayMode": "list",
          "placement": "bottom"
        },
        "tooltip": {
          "mode": "single"
        }
      },
      "pluginVersion": "8.1.2",
      "targets": [
        {
          "alias": "kWh",
          "dsType": "influxdb",
          "groupBy": [
            {
              "params": [
                "$__interval"
              ],
              "type": "time"
            },
            {
              "params": [
                "null"
              ],
              "type": "fill"
            }
          ],
          "hide": false,
          "measurement": "apcupsd",
          "orderByTime": "ASC",
          "policy": "default",
          "query": "from(bucket: \"telegraf\")\r\n  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\r\n  |> filter(fn: (r) => r._measurement == \"apcupsd\" and r.ups_name == \"${upsname}\" and r._field == \"load_percent\")\r\n  |> aggregateWindow(\r\n    every: 1h,\r\n    fn: (tables=<-, column) =>\r\n        tables\r\n            |> integral(unit: 1h)\r\n            |> map(fn: (r) => ({ r with _value: ((r._value / 100.0) * float(v: ${maxvoltamp}) / 1000.0)})))\r\n  |> keep(columns: [\"_time\",\"_value\"])\r\n  |> aggregateWindow(every: v.windowPeriod, fn: sum, createEmpty: false)",
          "refId": "A",
          "resultFormat": "time_series",
          "select": [
            [
              {
                "params": [
                  "load_percent"
                ],
                "type": "field"
              },
              {
                "params": [],
                "type": "mean"
              },
              {
                "params": [
                  "/100*$maxwatt/1000*24"
                ],
                "type": "math"
              }
            ]
          ],
          "tags": [
            {
              "key": "ups_name",
              "operator": "=~",
              "value": "/^$upsname$/"
            }
          ]
        }
      ],
      "timeFrom": "1y",
      "timeShift": null,
      "title": "Power Consumption",
      "transformations": [],
      "type": "timeseries"
    }
  ],
  "refresh": "30s",
  "schemaVersion": 30,
  "style": "dark",
  "tags": [
    "apcupsd"
  ],
  "templating": {
    "list": [
      {
        "current": {
          "selected": false,
          "text": "InfluxDB-Fluxed",
          "value": "InfluxDB-Fluxed"
        },
        "description": null,
        "error": null,
        "hide": 0,
        "includeAll": false,
        "label": "UPS Datasource",
        "multi": false,
        "name": "upsdatasource",
        "options": [],
        "query": "influxdb",
        "queryValue": "",
        "refresh": 1,
        "regex": "/^InfluxDB-Fluxed/",
        "skipUrlSync": false,
        "type": "datasource"
      },
      {
        "allValue": null,
        "current": {},
        "datasource": "${DS_INFLUXDB-FLUXED}",
        "definition": "from(bucket: \"telegraf\")\r\n  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\r\n  |> filter(fn: (r) => r._measurement == \"apcupsd\")\r\n  |> keep(columns: [\"ups_name\"])\r\n  |> group()\r\n  |> distinct(column: \"ups_name\")\r\n\r\n  ",
        "description": null,
        "error": null,
        "hide": 0,
        "includeAll": false,
        "label": "UPS Name",
        "multi": false,
        "name": "upsname",
        "options": [],
        "query": "from(bucket: \"telegraf\")\r\n  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\r\n  |> filter(fn: (r) => r._measurement == \"apcupsd\")\r\n  |> keep(columns: [\"ups_name\"])\r\n  |> group()\r\n  |> distinct(column: \"ups_name\")\r\n\r\n  ",
        "refresh": 1,
        "regex": "",
        "skipUrlSync": false,
        "sort": 0,
        "type": "query"
      },
      {
        "allValue": null,
        "current": {},
        "datasource": "${DS_INFLUXDB-FLUXED}",
        "definition": "from(bucket: \"telegraf\")\r\n  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\r\n  |> filter(fn: (r) => r._measurement == \"apcupsd\" and r.ups_name == \"${upsname}\")\r\n  |> keep(columns: [\"model\"])\r\n  |> group()\r\n  |> distinct(column: \"model\")\r\n\r\n",
        "description": null,
        "error": null,
        "hide": 0,
        "includeAll": false,
        "label": "UPS Max Output Power Capacity (VA)",
        "multi": false,
        "name": "maxvoltamp",
        "options": [],
        "query": "from(bucket: \"telegraf\")\r\n  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\r\n  |> filter(fn: (r) => r._measurement == \"apcupsd\" and r.ups_name == \"${upsname}\")\r\n  |> keep(columns: [\"model\"])\r\n  |> group()\r\n  |> distinct(column: \"model\")\r\n\r\n",
        "refresh": 1,
        "regex": "/.*(\\d{4,4})/",
        "skipUrlSync": false,
        "sort": 0,
        "tagValuesQuery": "",
        "tagsQuery": "",
        "type": "query",
        "useTags": false
      },
      {
        "allValue": null,
        "current": {},
        "datasource": "${DS_INFLUXDB-FLUXED}",
        "definition": "from(bucket: \"telegraf\")\r\n  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\r\n  |> filter(fn: (r) => r._measurement == \"apcupsd\" and r.ups_name == \"${upsname}\" and r._field == \"nominal_power\")\r\n  |> keep(columns: [\"_time\",\"ups_name\"])\r\n  |> map(fn: (r) => ({ r with _value: if \"${upsname}\" == \"UPSTower\" then 800 else 980}))\r\n  |> yield(name: \"last\")\r\n",
        "description": null,
        "error": null,
        "hide": 0,
        "includeAll": false,
        "label": "UPS Max Output Power Capacity (W)",
        "multi": false,
        "name": "maxwatt",
        "options": [],
        "query": "from(bucket: \"telegraf\")\r\n  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\r\n  |> filter(fn: (r) => r._measurement == \"apcupsd\" and r.ups_name == \"${upsname}\" and r._field == \"nominal_power\")\r\n  |> keep(columns: [\"_time\",\"ups_name\"])\r\n  |> map(fn: (r) => ({ r with _value: if \"${upsname}\" == \"UPSTower\" then 800 else 980}))\r\n  |> yield(name: \"last\")\r\n",
        "refresh": 1,
        "regex": "",
        "skipUrlSync": false,
        "sort": 0,
        "type": "query"
      },
      {
        "allValue": null,
        "current": {},
        "datasource": "${DS_INFLUXDB-FLUXED}",
        "definition": "from(bucket: \"telegraf\")\r\n  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\r\n  |> filter(fn: (r) => r._measurement == \"apcupsd\" and r.ups_name == \"${upsname}\")\r\n  |> keep(columns: [\"_time\",\"ups_name\"])\r\n  |> map(fn: (r) => ({ r with _value: if \"${upsname}\" == \"UPSTower\" then float(v: ${maxwatt})/float(v: ${maxvoltamp}) else float(v: ${maxwatt})/float(v: ${maxvoltamp})}))\r\n  |> yield(name: \"last\")\r\n",
        "description": null,
        "error": null,
        "hide": 0,
        "includeAll": false,
        "label": "Power Factor",
        "multi": false,
        "name": "powerfactor",
        "options": [],
        "query": "from(bucket: \"telegraf\")\r\n  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\r\n  |> filter(fn: (r) => r._measurement == \"apcupsd\" and r.ups_name == \"${upsname}\")\r\n  |> keep(columns: [\"_time\",\"ups_name\"])\r\n  |> map(fn: (r) => ({ r with _value: if \"${upsname}\" == \"UPSTower\" then float(v: ${maxwatt})/float(v: ${maxvoltamp}) else float(v: ${maxwatt})/float(v: ${maxvoltamp})}))\r\n  |> yield(name: \"last\")\r\n",
        "refresh": 1,
        "regex": "",
        "skipUrlSync": false,
        "sort": 0,
        "type": "query"
      },
      {
        "current": {
          "selected": true,
          "text": ".15",
          "value": ".15"
        },
        "description": null,
        "error": null,
        "hide": 0,
        "label": "kWh Price",
        "name": "kwhprice",
        "options": [
          {
            "selected": true,
            "text": ".15",
            "value": ".15"
          }
        ],
        "query": ".15",
        "skipUrlSync": false,
        "type": "textbox"
      },
      {
        "allValue": null,
        "current": {
          "selected": false,
          "text": "$",
          "value": "$"
        },
        "description": null,
        "error": null,
        "hide": 0,
        "includeAll": false,
        "label": "Currency",
        "multi": false,
        "name": "currency",
        "options": [
          {
            "selected": true,
            "text": "$",
            "value": "$"
          },
          {
            "selected": false,
            "text": "€",
            "value": "€"
          },
          {
            "selected": false,
            "text": "£",
            "value": "£"
          },
          {
            "selected": false,
            "text": "C$",
            "value": "C$"
          },
          {
            "selected": false,
            "text": "kr",
            "value": "kr"
          },
          {
            "selected": false,
            "text": "₽",
            "value": "₽"
          },
          {
            "selected": false,
            "text": "¥",
            "value": "¥"
          },
          {
            "selected": false,
            "text": "R",
            "value": "R"
          }
        ],
        "query": "$,€,£,C$,kr,₽,¥,R",
        "queryValue": "",
        "skipUrlSync": false,
        "type": "custom"
      }
    ]
  },
  "time": {
    "from": "now-3h",
    "to": "now"
  },
  "timepicker": {
    "hidden": false,
    "refresh_intervals": [
      "30s",
      "1m",
      "15m",
      "30m",
      "1h"
    ],
    "time_options": [
      "5m",
      "15m",
      "1h",
      "6h",
      "12h",
      "24h",
      "2d",
      "7d",
      "30d"
    ]
  },
  "timezone": "Australia/Sydney",
  "title": "APC UPS Detailed Summary",
  "uid": "RwSBnsS7z",
  "version": 22
}