Grafana dashboard: Xiaomi Mijia Temperature, and Humidity Dashboard
Description: Grafana Dashboard to monitor Xiaomi Mijia - Temperature and Humidity


{
  "__inputs": [
    {
      "name": "DS_INFLUXDB",
      "label": "InfluxDB",
      "description": "",
      "type": "datasource",
      "pluginId": "influxdb",
      "pluginName": "InfluxDB"
    }
  ],
  "__elements": [],
  "__requires": [
    {
      "type": "grafana",
      "id": "grafana",
      "name": "Grafana",
      "version": "8.3.0"
    },
    {
      "type": "panel",
      "id": "graph",
      "name": "Graph (old)",
      "version": ""
    },
    {
      "type": "datasource",
      "id": "influxdb",
      "name": "InfluxDB",
      "version": "1.0.0"
    },
    {
      "type": "panel",
      "id": "stat",
      "name": "Stat",
      "version": ""
    },
    {
      "type": "panel",
      "id": "text",
      "name": "Text",
      "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"
      }
    ]
  },
  "editable": true,
  "fiscalYearStartMonth": 0,
  "graphTooltip": 0,
  "id": 54,
  "iteration": 1646232301559,
  "links": [],
  "liveNow": false,
  "panels": [
    {
      "collapsed": false,
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 0
      },
      "id": 5,
      "panels": [],
      "repeat": "xiaomi_device",
      "title": "Xiaomi Mijia - $xiaomi_device",
      "type": "row"
    },
    {
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds",
            "seriesBy": "last"
          },
          "custom": {
            "axisLabel": "",
            "axisPlacement": "auto",
            "barAlignment": 0,
            "drawStyle": "line",
            "fillOpacity": 30,
            "gradientMode": "hue",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "lineInterpolation": "smooth",
            "lineStyle": {
              "fill": "solid"
            },
            "lineWidth": 0,
            "pointSize": 6,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "auto",
            "spanNulls": false,
            "stacking": {
              "group": "A",
              "mode": "none"
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "mappings": [],
          "min": 0,
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "dark-blue",
                "value": null
              },
              {
                "color": "semi-dark-green",
                "value": 16
              },
              {
                "color": "dark-green",
                "value": 18
              },
              {
                "color": "semi-dark-orange",
                "value": 22
              },
              {
                "color": "dark-red",
                "value": 26
              }
            ]
          },
          "unit": "celsius"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 7,
        "w": 9,
        "x": 0,
        "y": 1
      },
      "id": 2,
      "interval": "5m",
      "options": {
        "legend": {
          "calcs": [
            "lastNotNull"
          ],
          "displayMode": "hidden",
          "placement": "bottom"
        },
        "tooltip": {
          "mode": "multi"
        }
      },
      "targets": [
        {
          "datasource": {
            "type": "influxdb",
            "uid": "${DS_INFLUXDB}"
          },
          "hide": false,
          "query": "  from(bucket: v.defaultBucket)\r\n  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\r\n  |> filter(fn: (r) => r[\"_measurement\"] == \"xiaomi_temphum\")\r\n  |> filter(fn: (r) => r[\"_field\"] == \"temperature\" )\r\n  |> filter(fn: (r) => r[\"xiaomi_device\"] =~ /${xiaomi_device:regex}/)\r\n  |> pivot(rowKey:[\"_time\"], columnKey: [\"_field\"], valueColumn: \"_value\")\r\n  |> map(fn: (r) => ({ r with  _value: float(v: r.temperature) / 100.0 }))\r\n  |> group(columns: [\"xiaomi_device\",\"_field\"])\r\n  |> aggregateWindow(every: 5m0s, fn: mean, createEmpty: false)\r\n  |> yield(name: \"mean\")",
          "refId": "A"
        }
      ],
      "title": "Temperature",
      "type": "timeseries"
    },
    {
      "fieldConfig": {
        "defaults": {
          "color": {
            "fixedColor": "dark-blue",
            "mode": "fixed"
          },
          "custom": {
            "axisLabel": "",
            "axisPlacement": "auto",
            "barAlignment": 0,
            "drawStyle": "line",
            "fillOpacity": 25,
            "gradientMode": "hue",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "lineInterpolation": "smooth",
            "lineStyle": {
              "fill": "solid"
            },
            "lineWidth": 0,
            "pointSize": 5,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "always",
            "spanNulls": true,
            "stacking": {
              "group": "A",
              "mode": "none"
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "mappings": [],
          "min": 0,
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "dark-blue",
                "value": null
              }
            ]
          },
          "unit": "percent"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 7,
        "w": 9,
        "x": 9,
        "y": 1
      },
      "id": 3,
      "interval": "5m",
      "options": {
        "legend": {
          "calcs": [
            "lastNotNull"
          ],
          "displayMode": "hidden",
          "placement": "bottom"
        },
        "tooltip": {
          "mode": "multi"
        }
      },
      "targets": [
        {
          "datasource": {
            "type": "influxdb",
            "uid": "${DS_INFLUXDB}"
          },
          "hide": false,
          "query": "  from(bucket: v.defaultBucket)\r\n  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\r\n  |> filter(fn: (r) => r[\"_measurement\"] == \"xiaomi_temphum\")\r\n  |> filter(fn: (r) => r[\"_field\"] == \"humidity\")\r\n  |> filter(fn: (r) => r[\"xiaomi_device\"] =~ /${xiaomi_device:regex}/)\r\n  |> group(columns: [\"xiaomi_device\",\"_field\"])\r\n  |> aggregateWindow(every: 5m0s, fn: mean, createEmpty: false)\r\n  |> yield(name: \"mean\")",
          "refId": "A"
        }
      ],
      "title": "Humidity",
      "type": "timeseries"
    },
    {
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "min": 0,
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "dark-blue",
                "value": null
              },
              {
                "color": "semi-dark-green",
                "value": 16
              },
              {
                "color": "dark-green",
                "value": 18
              },
              {
                "color": "dark-orange",
                "value": 22
              },
              {
                "color": "dark-red",
                "value": 26
              }
            ]
          },
          "unit": "celsius"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 7,
        "w": 3,
        "x": 18,
        "y": 1
      },
      "id": 15,
      "interval": "5m",
      "options": {
        "colorMode": "background",
        "graphMode": "none",
        "justifyMode": "auto",
        "orientation": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        },
        "text": {},
        "textMode": "value"
      },
      "pluginVersion": "8.3.3",
      "targets": [
        {
          "datasource": {
            "type": "influxdb",
            "uid": "${DS_INFLUXDB}"
          },
          "hide": false,
          "query": "  from(bucket: v.defaultBucket)\r\n  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\r\n  |> filter(fn: (r) => r[\"_measurement\"] == \"xiaomi_temphum\")\r\n  |> filter(fn: (r) => r[\"_field\"] == \"temperature\" )\r\n  |> filter(fn: (r) => r[\"xiaomi_device\"] =~ /${xiaomi_device:regex}/)\r\n  |> pivot(rowKey:[\"_time\"], columnKey: [\"_field\"], valueColumn: \"_value\")\r\n  |> map(fn: (r) => ({ r with  _value: float(v: r.temperature) / 100.0 }))\r\n  |> group(columns: [\"xiaomi_device\",\"_field\"])\r\n  |> aggregateWindow(every: 5m0s, fn: mean, createEmpty: false)\r\n  |> yield(name: \"mean\")",
          "refId": "A"
        }
      ],
      "title": "Temperature",
      "type": "stat"
    },
    {
      "fieldConfig": {
        "defaults": {
          "mappings": [
            {
              "options": {
                "from": 0,
                "result": {
                  "color": "dark-red",
                  "index": 0,
                  "text": "Too Dry"
                },
                "to": 25
              },
              "type": "range"
            },
            {
              "options": {
                "from": 25,
                "result": {
                  "color": "dark-yellow",
                  "index": 1
                },
                "to": 30
              },
              "type": "range"
            },
            {
              "options": {
                "from": 30,
                "result": {
                  "color": "dark-green",
                  "index": 2
                },
                "to": 60
              },
              "type": "range"
            },
            {
              "options": {
                "from": 61,
                "result": {
                  "color": "dark-yellow",
                  "index": 3
                },
                "to": 70
              },
              "type": "range"
            },
            {
              "options": {
                "from": 70,
                "result": {
                  "color": "dark-red",
                  "index": 4
                },
                "to": 100
              },
              "type": "range"
            }
          ],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "dark-blue",
                "value": null
              }
            ]
          },
          "unit": "percent"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 7,
        "w": 3,
        "x": 21,
        "y": 1
      },
      "id": 16,
      "interval": "5m",
      "options": {
        "colorMode": "background",
        "graphMode": "none",
        "justifyMode": "center",
        "orientation": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        },
        "text": {},
        "textMode": "auto"
      },
      "pluginVersion": "8.3.3",
      "targets": [
        {
          "datasource": {
            "type": "influxdb",
            "uid": "${DS_INFLUXDB}"
          },
          "hide": false,
          "query": "  from(bucket: v.defaultBucket)\r\n  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\r\n  |> filter(fn: (r) => r[\"_measurement\"] == \"xiaomi_temphum\")\r\n  |> filter(fn: (r) => r[\"_field\"] == \"humidity\")\r\n  |> filter(fn: (r) => r[\"xiaomi_device\"] =~ /${xiaomi_device:regex}/)\r\n  |> group(columns: [\"xiaomi_device\",\"_field\"])\r\n  |> aggregateWindow(every: 5m0s, fn: mean, createEmpty: false)\r\n  |> yield(name: \"mean\")",
          "refId": "A"
        }
      ],
      "title": "Humidity",
      "type": "stat"
    }
  ],
  "refresh": "5m",
  "schemaVersion": 34,
  "style": "dark",
  "tags": [],
  "templating": {
    "list": [
      {
        "current": {
          "selected": true,
          "text": [
            "All"
          ],
          "value": [
            "$__all"
          ]
        },
        "definition": "from(bucket: v.defaultBucket)\r\n  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\r\n  |> filter(fn: (r) => r[\"_measurement\"] == \"xiaomi_temphum\")\r\n  |> keep(columns: [\"xiaomi_device\", \"xiaomi_room\"])\r\n  |> distinct(column: \"xiaomi_device\")\r\n  |> group()",
        "hide": 0,
        "includeAll": true,
        "label": "Xiaomi Mijia",
        "multi": true,
        "name": "xiaomi_device",
        "options": [],
        "query": "from(bucket: v.defaultBucket)\r\n  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\r\n  |> filter(fn: (r) => r[\"_measurement\"] == \"xiaomi_temphum\")\r\n  |> keep(columns: [\"xiaomi_device\", \"xiaomi_room\"])\r\n  |> distinct(column: \"xiaomi_device\")\r\n  |> group()",
        "refresh": 2,
        "regex": "",
        "skipUrlSync": false,
        "sort": 0,
        "type": "query"
      }
    ]
  },
  "time": {
    "from": "now-3h",
    "to": "now"
  },
  "timepicker": {},
  "timezone": "",
  "title": "Xiaomi Mijia Temperature, and Humidity Dashboard",
  "uid": "vUNyvHY7k",
  "version": 10,
  "weekStart": "",
  "gnetId": 18362,
  "description": "Grafana Dashboard to monitor Xiaomi Mijia - Temperature and Humidity"
}