Grafana dashboard: Energy Usage
Description: Tuya and octopus energy usage dashboard


{
  "__inputs": [
    {
      "name": "DS_MICROSOFT_SQL SERVER",
      "label": "Microsoft SQL Server",
      "description": "",
      "type": "datasource",
      "pluginId": "mssql",
      "pluginName": "Microsoft SQL Server"
    }
  ],
  "__elements": {},
  "__requires": [
    {
      "type": "panel",
      "id": "gauge",
      "name": "Gauge",
      "version": ""
    },
    {
      "type": "grafana",
      "id": "grafana",
      "name": "Grafana",
      "version": "9.5.0-cloud.5.a016665c"
    },
    {
      "type": "datasource",
      "id": "mssql",
      "name": "Microsoft SQL Server",
      "version": "1.0.0"
    },
    {
      "type": "panel",
      "id": "stat",
      "name": "Stat",
      "version": ""
    },
    {
      "type": "panel",
      "id": "timeseries",
      "name": "Time series",
      "version": ""
    }
  ],
  "annotations": {
    "list": [
      {
        "builtIn": 1,
        "datasource": {
          "type": "grafana",
          "uid": "-- Grafana --"
        },
        "enable": true,
        "hide": true,
        "iconColor": "rgba(0, 211, 255, 1)",
        "name": "Annotations & Alerts",
        "type": "dashboard"
      }
    ]
  },
  "editable": true,
  "fiscalYearStartMonth": 0,
  "graphTooltip": 0,
  "id": null,
  "links": [],
  "liveNow": false,
  "panels": [
    {
      "datasource": {
        "type": "mssql",
        "uid": "${DS_MICROSOFT_SQL SERVER}"
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "percentage",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "#EAB839",
                "value": 70
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          },
          "unit": "none"
        },
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "date"
            },
            "properties": [
              {
                "id": "unit",
                "value": "dateTimeFromNow"
              },
              {
                "id": "thresholds",
                "value": {
                  "mode": "absolute",
                  "steps": [
                    {
                      "color": "green",
                      "value": null
                    }
                  ]
                }
              },
              {
                "id": "custom.neutral"
              }
            ]
          }
        ]
      },
      "gridPos": {
        "h": 7,
        "w": 12,
        "x": 5,
        "y": 0
      },
      "id": 2,
      "options": {
        "orientation": "auto",
        "reduceOptions": {
          "calcs": [
            "firstNotNull"
          ],
          "fields": "/.*/",
          "values": false
        },
        "showThresholdLabels": false,
        "showThresholdMarkers": true
      },
      "pluginVersion": "9.5.0-cloud.5.a016665c",
      "targets": [
        {
          "dataset": "wolston-database",
          "datasource": {
            "type": "mssql",
            "uid": "${DS_MICROSOFT_SQL SERVER}"
          },
          "editorMode": "code",
          "format": "table",
          "key": "Q-e2335b96-e57d-42fe-b0e5-27b0cb8e0319-0",
          "rawQuery": true,
          "rawSql": "SELECT \r\ndate,\r\ndaily_electric,\r\ndaily_gas\r\n FROM dbo.T200_utilities\r\n ORDER BY date DESC",
          "refId": "A",
          "sql": {
            "columns": [
              {
                "parameters": [
                  {
                    "name": "*",
                    "type": "functionParameter"
                  }
                ],
                "type": "function"
              }
            ],
            "groupBy": [
              {
                "property": {
                  "type": "string"
                },
                "type": "groupBy"
              }
            ],
            "limit": 50
          },
          "table": "dbo.gas_consumption"
        }
      ],
      "title": "Latest reading",
      "transformations": [
        {
          "id": "calculateField",
          "options": {}
        }
      ],
      "type": "gauge"
    },
    {
      "datasource": {
        "type": "mssql",
        "uid": "${DS_MICROSOFT_SQL SERVER}"
      },
      "description": "",
      "fieldConfig": {
        "defaults": {
          "color": {
            "fixedColor": "yellow",
            "mode": "palette-classic"
          },
          "custom": {
            "axisCenteredZero": false,
            "axisColorMode": "text",
            "axisLabel": "Cost (£) per day",
            "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": "normal"
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          }
        },
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "Total"
            },
            "properties": [
              {
                "id": "custom.lineInterpolation",
                "value": "linear"
              },
              {
                "id": "custom.drawStyle",
                "value": "line"
              },
              {
                "id": "custom.fillOpacity",
                "value": 0
              },
              {
                "id": "custom.drawStyle",
                "value": "line"
              },
              {
                "id": "color",
                "value": {
                  "fixedColor": "purple",
                  "mode": "fixed"
                }
              },
              {
                "id": "custom.showPoints",
                "value": "auto"
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "daily_electric"
            },
            "properties": [
              {
                "id": "color",
                "value": {
                  "fixedColor": "semi-dark-blue",
                  "mode": "fixed"
                }
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "daily_gas"
            },
            "properties": [
              {
                "id": "color",
                "value": {
                  "mode": "fixed"
                }
              }
            ]
          }
        ]
      },
      "gridPos": {
        "h": 7,
        "w": 12,
        "x": 5,
        "y": 7
      },
      "id": 1,
      "options": {
        "legend": {
          "calcs": [],
          "displayMode": "list",
          "placement": "bottom",
          "showLegend": true
        },
        "timezone": [
          "utc"
        ],
        "tooltip": {
          "mode": "single",
          "sort": "none"
        }
      },
      "targets": [
        {
          "dataset": "wolston-database",
          "datasource": {
            "type": "mssql",
            "uid": "${DS_MICROSOFT_SQL SERVER}"
          },
          "editorMode": "code",
          "format": "table",
          "key": "Q-e2335b96-e57d-42fe-b0e5-27b0cb8e0319-0",
          "rawQuery": true,
          "rawSql": "SELECT \r\ndate,\r\ndaily_electric,\r\ndaily_gas\r\n FROM dbo.T200_utilities",
          "refId": "A",
          "sql": {
            "columns": [
              {
                "parameters": [
                  {
                    "name": "*",
                    "type": "functionParameter"
                  }
                ],
                "type": "function"
              }
            ],
            "groupBy": [
              {
                "property": {
                  "type": "string"
                },
                "type": "groupBy"
              }
            ],
            "limit": 50
          },
          "table": "dbo.gas_consumption"
        }
      ],
      "title": "Energy Consumption per day",
      "transformations": [
        {
          "id": "calculateField",
          "options": {
            "mode": "reduceRow",
            "reduce": {
              "include": [
                "daily_electric",
                "daily_gas"
              ],
              "reducer": "sum"
            },
            "replaceFields": false
          }
        }
      ],
      "type": "timeseries"
    },
    {
      "datasource": {
        "type": "mssql",
        "uid": "${DS_MICROSOFT_SQL SERVER}"
      },
      "fieldConfig": {
        "defaults": {
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          },
          "unit": "short"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 4,
        "w": 12,
        "x": 5,
        "y": 14
      },
      "id": 7,
      "options": {
        "colorMode": "value",
        "graphMode": "area",
        "justifyMode": "auto",
        "orientation": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        },
        "textMode": "auto"
      },
      "pluginVersion": "9.5.0-cloud.5.a016665c",
      "targets": [
        {
          "datasource": {
            "type": "mssql",
            "uid": "${DS_MICROSOFT_SQL SERVER}"
          },
          "editorMode": "code",
          "format": "table",
          "rawQuery": true,
          "rawSql": "SELECT \r\n      [date]\r\n      ,[standing_charge] as elec_standing_charge\r\n      ,[unit_rate] as elec_unit_rate\r\n  FROM [dbo].[electric_tariff]\r\n  ORDER BY date DESC;",
          "refId": "A",
          "sql": {
            "columns": [
              {
                "parameters": [],
                "type": "function"
              }
            ],
            "groupBy": [
              {
                "property": {
                  "type": "string"
                },
                "type": "groupBy"
              }
            ],
            "limit": 50
          }
        },
        {
          "datasource": {
            "type": "mssql",
            "uid": "${DS_MICROSOFT_SQL SERVER}"
          },
          "editorMode": "code",
          "format": "table",
          "hide": false,
          "rawQuery": true,
          "rawSql": "SELECT \r\n      [date]\r\n      ,[standing_charge] as gas_standing_charge\r\n      ,[unit_rate] as gas_unit_rate\r\n  FROM [dbo].[gas_tariff]\r\n  ORDER BY date DESC;",
          "refId": "B",
          "sql": {
            "columns": [
              {
                "parameters": [],
                "type": "function"
              }
            ],
            "groupBy": [
              {
                "property": {
                  "type": "string"
                },
                "type": "groupBy"
              }
            ],
            "limit": 50
          }
        }
      ],
      "title": "Today's tariff (p/kwh)",
      "transformations": [],
      "type": "stat"
    },
    {
      "datasource": {
        "type": "mssql",
        "uid": "${DS_MICROSOFT_SQL SERVER}"
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisCenteredZero": false,
            "axisColorMode": "text",
            "axisLabel": "",
            "axisPlacement": "auto",
            "barAlignment": 0,
            "drawStyle": "line",
            "fillOpacity": 50,
            "gradientMode": "opacity",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "lineInterpolation": "linear",
            "lineWidth": 1,
            "pointSize": 5,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "auto",
            "spanNulls": false,
            "stacking": {
              "group": "A",
              "mode": "none"
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          }
        },
        "overrides": []
      },
      "gridPos": {
        "h": 6,
        "w": 12,
        "x": 5,
        "y": 18
      },
      "id": 5,
      "options": {
        "legend": {
          "calcs": [],
          "displayMode": "list",
          "placement": "bottom",
          "showLegend": true
        },
        "tooltip": {
          "mode": "single",
          "sort": "none"
        }
      },
      "pluginVersion": "9.5.0-cloud.5.a016665c",
      "targets": [
        {
          "datasource": {
            "type": "mssql",
            "uid": "${DS_MICROSOFT_SQL SERVER}"
          },
          "editorMode": "code",
          "format": "table",
          "rawQuery": true,
          "rawSql": "SELECT \r\n      [date]\r\n      ,[standing_charge]\r\n      ,[unit_rate]\r\n  FROM [dbo].[electric_tariff]\r\n  ORDER BY date DESC;",
          "refId": "A",
          "sql": {
            "columns": [
              {
                "parameters": [],
                "type": "function"
              }
            ],
            "groupBy": [
              {
                "property": {
                  "type": "string"
                },
                "type": "groupBy"
              }
            ],
            "limit": 50
          }
        }
      ],
      "title": "Today's electric tariff (p/kwh)",
      "transformations": [],
      "type": "timeseries"
    },
    {
      "datasource": {
        "type": "mssql",
        "uid": "${DS_MICROSOFT_SQL SERVER}"
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisCenteredZero": false,
            "axisColorMode": "text",
            "axisLabel": "",
            "axisPlacement": "auto",
            "barAlignment": 0,
            "drawStyle": "line",
            "fillOpacity": 50,
            "gradientMode": "opacity",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "lineInterpolation": "linear",
            "lineWidth": 1,
            "pointSize": 5,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "auto",
            "spanNulls": false,
            "stacking": {
              "group": "A",
              "mode": "none"
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green"
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          }
        },
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "standing_charge"
            },
            "properties": [
              {
                "id": "color",
                "value": {
                  "fixedColor": "purple",
                  "mode": "fixed"
                }
              }
            ]
          }
        ]
      },
      "gridPos": {
        "h": 7,
        "w": 12,
        "x": 5,
        "y": 24
      },
      "id": 6,
      "options": {
        "legend": {
          "calcs": [],
          "displayMode": "list",
          "placement": "bottom",
          "showLegend": true
        },
        "tooltip": {
          "mode": "single",
          "sort": "none"
        }
      },
      "pluginVersion": "9.5.0-cloud.5.a016665c",
      "targets": [
        {
          "datasource": {
            "type": "mssql",
            "uid": "${DS_MICROSOFT_SQL SERVER}"
          },
          "editorMode": "code",
          "format": "table",
          "rawQuery": true,
          "rawSql": "SELECT \r\n      [date]\r\n      ,[standing_charge]\r\n      ,[unit_rate]\r\n  FROM [dbo].[gas_tariff]\r\n  ORDER BY date DESC;",
          "refId": "A",
          "sql": {
            "columns": [
              {
                "parameters": [],
                "type": "function"
              }
            ],
            "groupBy": [
              {
                "property": {
                  "type": "string"
                },
                "type": "groupBy"
              }
            ],
            "limit": 50
          }
        }
      ],
      "title": "Today's gas tariff (p/kwh)",
      "transformations": [],
      "type": "timeseries"
    },
    {
      "datasource": {
        "type": "mssql",
        "uid": "${DS_MICROSOFT_SQL SERVER}"
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "fixedColor": "purple",
            "mode": "fixed"
          },
          "custom": {
            "axisCenteredZero": false,
            "axisColorMode": "text",
            "axisLabel": "",
            "axisPlacement": "auto",
            "barAlignment": 0,
            "drawStyle": "line",
            "fillOpacity": 0,
            "gradientMode": "none",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "lineInterpolation": "linear",
            "lineWidth": 1,
            "pointSize": 5,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "auto",
            "spanNulls": false,
            "stacking": {
              "group": "A",
              "mode": "none"
            },
            "thresholdsStyle": {
              "mode": "line"
            }
          },
          "displayName": "Computer",
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green"
              },
              {
                "color": "#EAB839",
                "value": 1
              },
              {
                "color": "red",
                "value": 2
              }
            ]
          },
          "unit": "currencyGBP"
        },
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "cost_per_day"
            },
            "properties": [
              {
                "id": "decimals",
                "value": 2
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "date"
            },
            "properties": [
              {
                "id": "unit",
                "value": "dateTimeAsLocal"
              }
            ]
          },
          {
            "matcher": {
              "id": "byFrameRefID",
              "options": "B"
            },
            "properties": [
              {
                "id": "displayName",
                "value": "Washing machine"
              },
              {
                "id": "color",
                "value": {
                  "fixedColor": "blue",
                  "mode": "fixed"
                }
              }
            ]
          }
        ]
      },
      "gridPos": {
        "h": 9,
        "w": 12,
        "x": 5,
        "y": 31
      },
      "id": 3,
      "options": {
        "legend": {
          "calcs": [],
          "displayMode": "list",
          "placement": "bottom",
          "showLegend": true
        },
        "timezone": [
          "utc"
        ],
        "tooltip": {
          "mode": "single",
          "sort": "none"
        }
      },
      "pluginVersion": "9.5.0-cloud.5.a016665c",
      "targets": [
        {
          "dataset": "wolston-database",
          "datasource": {
            "type": "mssql",
            "uid": "${DS_MICROSOFT_SQL SERVER}"
          },
          "editorMode": "code",
          "format": "table",
          "rawQuery": true,
          "rawSql": "SELECT \r\n  date,\r\n  device,\r\n  cost_per_day\r\n FROM dbo.T201_tuya_usage \r\n WHERE device = 'Computer'\r\n ORDER BY\r\n  date DESC",
          "refId": "A",
          "sql": {
            "columns": [
              {
                "parameters": [
                  {
                    "name": "*",
                    "type": "functionParameter"
                  }
                ],
                "type": "function"
              }
            ],
            "groupBy": [
              {
                "property": {
                  "type": "string"
                },
                "type": "groupBy"
              }
            ],
            "limit": 50
          },
          "table": "dbo.T201_tuya_usage"
        },
        {
          "datasource": {
            "type": "mssql",
            "uid": "${DS_MICROSOFT_SQL SERVER}"
          },
          "editorMode": "code",
          "format": "table",
          "hide": false,
          "rawQuery": true,
          "rawSql": "SELECT \r\n  date,\r\n  device,\r\n  cost_per_day\r\n FROM dbo.T201_tuya_usage \r\n WHERE device = 'Washing machine'\r\n ORDER BY\r\n  date DESC",
          "refId": "B",
          "sql": {
            "columns": [
              {
                "parameters": [],
                "type": "function"
              }
            ],
            "groupBy": [
              {
                "property": {
                  "type": "string"
                },
                "type": "groupBy"
              }
            ],
            "limit": 50
          }
        }
      ],
      "title": "Usage cost (£/day)",
      "transformations": [],
      "type": "timeseries"
    }
  ],
  "refresh": "1h",
  "schemaVersion": 38,
  "style": "dark",
  "tags": [],
  "templating": {
    "list": []
  },
  "time": {
    "from": "2023-01-30T00:00:00.000Z",
    "to": "2023-05-30T00:00:00.000Z"
  },
  "timepicker": {},
  "timezone": "utc",
  "title": "Energy Usage",
  "uid": "e8058d0e-827b-4007-a0a2-3cbf91245aa5",
  "version": 18,
  "weekStart": "",
  "gnetId": 18662,
  "description": "Tuya and octopus energy usage dashboard"
}