apiVersion: v1
kind: ConfigMap
metadata:
  name: kostal-energy-dashboard
  labels:
     grafana_dashboard: "1"
data:
  kostal-energy-dashboard.json: |-
    {
      "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"
          }
        ]
      },
      "editable": true,
      "fiscalYearStartMonth": 0,
      "graphTooltip": 1,
      "iteration": 1641214789087,
      "links": [],
      "liveNow": false,
      "panels": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "fieldConfig": {
            "defaults": {
              "color": {
                "fixedColor": "dark-yellow",
                "mode": "fixed"
              },
              "mappings": [],
              "thresholds": {
                "mode": "absolute",
                "steps": [
                  {
                    "color": "green",
                    "value": null
                  },
                  {
                    "color": "red",
                    "value": 80
                  }
                ]
              },
              "unit": "watth"
            },
            "overrides": []
          },
          "gridPos": {
            "h": 4,
            "w": 4,
            "x": 0,
            "y": 0
          },
          "id": 20,
          "options": {
            "colorMode": "value",
            "graphMode": "none",
            "justifyMode": "auto",
            "orientation": "auto",
            "reduceOptions": {
              "calcs": [
                "diff"
              ],
              "fields": "",
              "values": false
            },
            "text": {},
            "textMode": "value"
          },
          "pluginVersion": "8.3.3",
          "targets": [
            {
              "exemplar": true,
              "expr": "max(kpc_ac_energy_yield_wh_total)",
              "instant": false,
              "interval": "",
              "intervalFactor": 10,
              "legendFormat": "",
              "refId": "A"
            }
          ],
          "title": "PV",
          "type": "stat"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "fieldConfig": {
            "defaults": {
              "color": {
                "mode": "thresholds"
              },
              "mappings": [],
              "thresholds": {
                "mode": "absolute",
                "steps": [
                  {
                    "color": "green",
                    "value": null
                  }
                ]
              },
              "unit": "watth"
            },
            "overrides": []
          },
          "gridPos": {
            "h": 4,
            "w": 4,
            "x": 4,
            "y": 0
          },
          "id": 6,
          "options": {
            "colorMode": "value",
            "graphMode": "none",
            "justifyMode": "auto",
            "orientation": "auto",
            "reduceOptions": {
              "calcs": [
                "diff"
              ],
              "fields": "",
              "values": false
            },
            "text": {},
            "textMode": "value"
          },
          "pluginVersion": "8.3.3",
          "targets": [
            {
              "exemplar": true,
              "expr": "max(kpc_ac_energy_to_grid_wh_total)",
              "interval": "",
              "intervalFactor": 10,
              "legendFormat": "",
              "refId": "A"
            }
          ],
          "title": "Energy to Grid",
          "type": "stat"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "fieldConfig": {
            "defaults": {
              "color": {
                "fixedColor": "dark-orange",
                "mode": "fixed"
              },
              "mappings": [],
              "thresholds": {
                "mode": "absolute",
                "steps": [
                  {
                    "color": "green",
                    "value": null
                  }
                ]
              },
              "unit": "watth"
            },
            "overrides": []
          },
          "gridPos": {
            "h": 4,
            "w": 4,
            "x": 8,
            "y": 0
          },
          "id": 10,
          "options": {
            "colorMode": "value",
            "graphMode": "none",
            "justifyMode": "auto",
            "orientation": "auto",
            "reduceOptions": {
              "calcs": [
                "diff"
              ],
              "fields": "",
              "values": false
            },
            "text": {},
            "textMode": "value"
          },
          "pluginVersion": "8.3.3",
          "targets": [
            {
              "exemplar": true,
              "expr": "max(kpc_home_power_consumption_total_wh_total)",
              "interval": "",
              "intervalFactor": 10,
              "legendFormat": "",
              "refId": "A"
            }
          ],
          "title": "Home Consumption",
          "type": "stat"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "fieldConfig": {
            "defaults": {
              "color": {
                "fixedColor": "dark-yellow",
                "mode": "fixed"
              },
              "mappings": [],
              "thresholds": {
                "mode": "absolute",
                "steps": [
                  {
                    "color": "green",
                    "value": null
                  }
                ]
              },
              "unit": "watth"
            },
            "overrides": []
          },
          "gridPos": {
            "h": 4,
            "w": 3,
            "x": 12,
            "y": 0
          },
          "id": 12,
          "options": {
            "colorMode": "value",
            "graphMode": "none",
            "justifyMode": "auto",
            "orientation": "horizontal",
            "reduceOptions": {
              "calcs": [
                "diff"
              ],
              "fields": "",
              "values": false
            },
            "text": {},
            "textMode": "value"
          },
          "pluginVersion": "8.3.3",
          "targets": [
            {
              "exemplar": true,
              "expr": "max(kpc_home_power_consumption_wh_total{source=\"pv\"})",
              "interval": "",
              "intervalFactor": 10,
              "legendFormat": "PV",
              "refId": "A"
            }
          ],
          "title": "... from PV",
          "type": "stat"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "fieldConfig": {
            "defaults": {
              "color": {
                "fixedColor": "semi-dark-red",
                "mode": "fixed"
              },
              "mappings": [],
              "thresholds": {
                "mode": "absolute",
                "steps": [
                  {
                    "color": "green",
                    "value": null
                  }
                ]
              },
              "unit": "watth"
            },
            "overrides": []
          },
          "gridPos": {
            "h": 4,
            "w": 3,
            "x": 15,
            "y": 0
          },
          "id": 14,
          "options": {
            "colorMode": "value",
            "graphMode": "none",
            "justifyMode": "auto",
            "orientation": "auto",
            "reduceOptions": {
              "calcs": [
                "diff"
              ],
              "fields": "",
              "values": false
            },
            "text": {},
            "textMode": "value"
          },
          "pluginVersion": "8.3.3",
          "targets": [
            {
              "exemplar": true,
              "expr": "max(kpc_home_power_consumption_wh_total{source=\"grid\"})",
              "interval": "",
              "intervalFactor": 10,
              "legendFormat": "",
              "refId": "A"
            }
          ],
          "title": "... from Grid",
          "type": "stat"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "fieldConfig": {
            "defaults": {
              "color": {
                "fixedColor": "blue",
                "mode": "fixed"
              },
              "mappings": [],
              "thresholds": {
                "mode": "absolute",
                "steps": [
                  {
                    "color": "green",
                    "value": null
                  }
                ]
              },
              "unit": "watth"
            },
            "overrides": []
          },
          "gridPos": {
            "h": 4,
            "w": 3,
            "x": 18,
            "y": 0
          },
          "id": 18,
          "options": {
            "colorMode": "value",
            "graphMode": "none",
            "justifyMode": "auto",
            "orientation": "auto",
            "reduceOptions": {
              "calcs": [
                "diff"
              ],
              "fields": "",
              "values": false
            },
            "text": {},
            "textMode": "value"
          },
          "pluginVersion": "8.3.3",
          "targets": [
            {
              "exemplar": true,
              "expr": "max(goe_energy_wh_total)",
              "interval": "",
              "legendFormat": "",
              "refId": "A"
            }
          ],
          "title": "... to Car",
          "type": "stat"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "fieldConfig": {
            "defaults": {
              "color": {
                "fixedColor": "blue",
                "mode": "fixed"
              },
              "mappings": [],
              "thresholds": {
                "mode": "absolute",
                "steps": [
                  {
                    "color": "green",
                    "value": null
                  },
                  {
                    "color": "red",
                    "value": 80
                  }
                ]
              },
              "unit": "watth"
            },
            "overrides": []
          },
          "gridPos": {
            "h": 4,
            "w": 3,
            "x": 21,
            "y": 0
          },
          "id": 22,
          "options": {
            "colorMode": "value",
            "graphMode": "none",
            "justifyMode": "auto",
            "orientation": "horizontal",
            "reduceOptions": {
              "calcs": [
                "lastNotNull"
              ],
              "fields": "",
              "values": false
            },
            "text": {
              "titleSize": 24,
              "valueSize": 24
            },
            "textMode": "auto"
          },
          "pluginVersion": "8.3.3",
          "targets": [
            {
              "exemplar": false,
              "expr": "increase(max(pvcontrol:total_charged_energy_wh_total)[$__range:])",
              "instant": true,
              "interval": "",
              "intervalFactor": 10,
              "legendFormat": "Total",
              "refId": "A"
            },
            {
              "exemplar": false,
              "expr": "increase(max(pvcontrol:charged_energy_wh_total{source=\"pv\"})[$__range:])",
              "hide": false,
              "instant": true,
              "interval": "",
              "legendFormat": "... PV",
              "refId": "C"
            },
            {
              "exemplar": false,
              "expr": "increase(max(pvcontrol:charged_energy_wh_total{source=\"grid\"})[$__range:])",
              "hide": false,
              "instant": true,
              "interval": "",
              "legendFormat": "... Grid",
              "refId": "B"
            }
          ],
          "title": "... to Car",
          "type": "stat"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "fieldConfig": {
            "defaults": {
              "color": {
                "mode": "palette-classic"
              },
              "custom": {
                "axisLabel": "",
                "axisPlacement": "auto",
                "barAlignment": -1,
                "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": true,
                "stacking": {
                  "group": "A",
                  "mode": "normal"
                },
                "thresholdsStyle": {
                  "mode": "off"
                }
              },
              "mappings": [],
              "min": 0,
              "thresholds": {
                "mode": "absolute",
                "steps": [
                  {
                    "color": "green",
                    "value": null
                  },
                  {
                    "color": "red",
                    "value": 80
                  }
                ]
              },
              "unit": "watth"
            },
            "overrides": [
              {
                "matcher": {
                  "id": "byName",
                  "options": "Total"
                },
                "properties": [
                  {
                    "id": "custom.stacking",
                    "value": {
                      "group": false,
                      "mode": "normal"
                    }
                  },
                  {
                    "id": "color",
                    "value": {
                      "fixedColor": "semi-dark-orange",
                      "mode": "fixed"
                    }
                  }
                ]
              },
              {
                "matcher": {
                  "id": "byName",
                  "options": "grid"
                },
                "properties": [
                  {
                    "id": "color",
                    "value": {
                      "fixedColor": "semi-dark-red",
                      "mode": "fixed"
                    }
                  }
                ]
              },
              {
                "matcher": {
                  "id": "byName",
                  "options": "pv"
                },
                "properties": [
                  {
                    "id": "color",
                    "value": {
                      "fixedColor": "dark-yellow",
                      "mode": "fixed"
                    }
                  }
                ]
              }
            ]
          },
          "gridPos": {
            "h": 9,
            "w": 24,
            "x": 0,
            "y": 4
          },
          "id": 2,
          "options": {
            "legend": {
              "calcs": [],
              "displayMode": "list",
              "placement": "bottom"
            },
            "tooltip": {
              "mode": "multi"
            }
          },
          "pluginVersion": "8.0.1",
          "targets": [
            {
              "exemplar": true,
              "expr": "max(kpc_home_power_consumption_total_wh_total) - max(kpc_home_power_consumption_total_wh_total offset $resolution)",
              "hide": false,
              "interval": "$resolution",
              "legendFormat": "Total",
              "refId": "B"
            },
            {
              "exemplar": true,
              "expr": "max by (source)(kpc_home_power_consumption_wh_total{source!=\"battery\"}) - max by (source)(kpc_home_power_consumption_wh_total{source!=\"battery\"} offset $resolution)",
              "interval": "$resolution",
              "legendFormat": "{{source}}",
              "refId": "A"
            }
          ],
          "title": "Home Consumption",
          "type": "timeseries"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "fieldConfig": {
            "defaults": {
              "color": {
                "mode": "palette-classic"
              },
              "custom": {
                "axisLabel": "",
                "axisPlacement": "auto",
                "barAlignment": -1,
                "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": true,
                "stacking": {
                  "group": "A",
                  "mode": "none"
                },
                "thresholdsStyle": {
                  "mode": "off"
                }
              },
              "mappings": [],
              "min": 0,
              "thresholds": {
                "mode": "absolute",
                "steps": [
                  {
                    "color": "green",
                    "value": null
                  },
                  {
                    "color": "red",
                    "value": 80
                  }
                ]
              },
              "unit": "watth"
            },
            "overrides": [
              {
                "matcher": {
                  "id": "byName",
                  "options": "PV"
                },
                "properties": [
                  {
                    "id": "color",
                    "value": {
                      "fixedColor": "dark-yellow",
                      "mode": "fixed"
                    }
                  }
                ]
              },
              {
                "matcher": {
                  "id": "byName",
                  "options": "To Grid"
                },
                "properties": [
                  {
                    "id": "color",
                    "value": {
                      "fixedColor": "semi-dark-green",
                      "mode": "fixed"
                    }
                  }
                ]
              }
            ]
          },
          "gridPos": {
            "h": 8,
            "w": 24,
            "x": 0,
            "y": 13
          },
          "id": 4,
          "options": {
            "legend": {
              "calcs": [],
              "displayMode": "list",
              "placement": "bottom"
            },
            "tooltip": {
              "mode": "multi"
            }
          },
          "pluginVersion": "8.0.1",
          "targets": [
            {
              "exemplar": true,
              "expr": "max(kpc_ac_energy_yield_wh_total) - max(kpc_ac_energy_yield_wh_total offset $resolution)",
              "hide": false,
              "interval": "$resolution",
              "legendFormat": "PV",
              "refId": "B"
            },
            {
              "exemplar": true,
              "expr": "max(kpc_ac_energy_to_grid_wh_total) - max(kpc_ac_energy_to_grid_wh_total offset $resolution)",
              "interval": "$resolution",
              "legendFormat": "To Grid",
              "refId": "A"
            }
          ],
          "title": "PV",
          "type": "timeseries"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "fieldConfig": {
            "defaults": {
              "color": {
                "mode": "palette-classic"
              },
              "custom": {
                "axisLabel": "",
                "axisPlacement": "auto",
                "barAlignment": -1,
                "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": true,
                "stacking": {
                  "group": "A",
                  "mode": "none"
                },
                "thresholdsStyle": {
                  "mode": "off"
                }
              },
              "mappings": [],
              "min": 0,
              "thresholds": {
                "mode": "absolute",
                "steps": [
                  {
                    "color": "green",
                    "value": null
                  },
                  {
                    "color": "red",
                    "value": 80
                  }
                ]
              },
              "unit": "watth"
            },
            "overrides": [
              {
                "matcher": {
                  "id": "byName",
                  "options": "Car"
                },
                "properties": [
                  {
                    "id": "color",
                    "value": {
                      "fixedColor": "blue",
                      "mode": "fixed"
                    }
                  }
                ]
              },
              {
                "matcher": {
                  "id": "byName",
                  "options": "Grid"
                },
                "properties": [
                  {
                    "id": "color",
                    "value": {
                      "fixedColor": "semi-dark-red",
                      "mode": "fixed"
                    }
                  }
                ]
              }
            ]
          },
          "gridPos": {
            "h": 7,
            "w": 24,
            "x": 0,
            "y": 21
          },
          "id": 16,
          "options": {
            "legend": {
              "calcs": [],
              "displayMode": "list",
              "placement": "bottom"
            },
            "tooltip": {
              "mode": "multi"
            }
          },
          "pluginVersion": "8.0.1",
          "targets": [
            {
              "exemplar": true,
              "expr": "increase(max(pvcontrol:total_charged_energy_wh_total)[$resolution:])",
              "interval": "$resolution",
              "legendFormat": "Car",
              "refId": "A"
            },
            {
              "exemplar": true,
              "expr": "increase(max(pvcontrol:charged_energy_wh_total{source=\"grid\"})[$resolution:])",
              "hide": false,
              "interval": "$resolution",
              "legendFormat": "Grid",
              "refId": "B"
            }
          ],
          "title": "Car Charging",
          "type": "timeseries"
        }
      ],
      "refresh": false,
      "schemaVersion": 34,
      "style": "dark",
      "tags": [],
      "templating": {
        "list": [
          {
            "auto": false,
            "auto_count": 30,
            "auto_min": "10s",
            "current": {
              "selected": false,
              "text": "1h",
              "value": "1h"
            },
            "hide": 0,
            "label": "Resolution",
            "name": "resolution",
            "options": [
              {
                "selected": false,
                "text": "5m",
                "value": "5m"
              },
              {
                "selected": true,
                "text": "1h",
                "value": "1h"
              },
              {
                "selected": false,
                "text": "1d",
                "value": "1d"
              },
              {
                "selected": false,
                "text": "1w",
                "value": "1w"
              },
              {
                "selected": false,
                "text": "1M",
                "value": "1M"
              }
            ],
            "query": "5m,1h,1d,1w,1M",
            "queryValue": "",
            "refresh": 2,
            "skipUrlSync": false,
            "type": "interval"
          },
          {
            "current": {
              "selected": true,
              "text": "default",
              "value": "default"
            },
            "hide": 0,
            "includeAll": false,
            "multi": false,
            "name": "datasource",
            "options": [],
            "query": "prometheus",
            "queryValue": "",
            "refresh": 1,
            "regex": "",
            "skipUrlSync": false,
            "type": "datasource"
          }
        ]
      },
      "time": {
        "from": "now-24h",
        "to": "now"
      },
      "timepicker": {},
      "timezone": "",
      "title": "Kostal Energy",
      "uid": "bGXzWbiRz",
      "version": 1,
      "weekStart": ""
    }