Toon thermostat data to grafana

If you don't know where to post, post here.

Moderators: marcelr, TheHogNL, Toonz

Post Reply
TheHogNL
Forum Moderator
Forum Moderator
Posts: 2125
Joined: Sun Aug 20, 2017 8:53 pm

Toon thermostat data to grafana

Post by TheHogNL »

Hi all,

I created a script to push some thermostat data to grafana using a free provider corlysis.com. Go there, register a free account and create an empty time-database.

Then run this script on your Toon (after entering your corlysis details in the variables in the top of the script). You can run this script manually or from inittab or something.

Code: Select all

#!/bin/sh
DB="enter-db-name"
USER="enter-db-username-default=token"
PASSWORD="enter-db-password"

### don't change below this line ###
HOSTNAME=`hostname`
URL="https://corlysis.com:8086/write?db=$DB"

while true
do
        OUTPUT=`curl -Nks "http://localhost/happ_thermstat?action=getThermostatInfo"`
        CURTEMP=`echo $OUTPUT | sed 's/.*"currentTemp":"\([0-9]*\)".*/\1/'`
        CURTEMP=`awk "BEGIN {print ($CURTEMP)/100}"`
        SETTEMP=`echo $OUTPUT | sed 's/.*"currentSetpoint":"\([0-9]*\)".*/\1/'`
        SETTEMP=`awk "BEGIN {print ($SETTEMP)/100}"`
        BOILERSETTEMP=`echo $OUTPUT | sed 's/.*"currentInternalBoilerSetpoint":"\([0-9]*\)".*/\1/'`
        BURNERSTATE=`echo $OUTPUT | sed 's/.*"burnerInfo":"\([0-3]*\)".*/\1/'`
        MODULATIONLEVEL=`echo $OUTPUT | sed 's/.*"currentModulationLevel":"\([0-9]*\)".*/\1/'`


        POST="thermostat,hostname=$HOSTNAME curtemp=$CURTEMP,settemp=$SETTEMP,boilersettemp=$BOILERSETTEMP,burnerstate=$BURNERSTATE,modulationlevel=$MODULATIONLEVEL"
        RESULT=`curl -Nksi -XPOST $URL -u "$USER:$PASSWORD" --data-binary "$POST"`
        sleep 60
done
Then head back to corlysis website and create your Grafana dashboard and import this JSON file to create my default dashboard. You would then see pretty graphs!

Code: Select all

{
  "annotations": {
    "list": [
      {
        "builtIn": 1,
        "datasource": "-- Grafana --",
        "enable": true,
        "hide": true,
        "iconColor": "rgba(0, 211, 255, 1)",
        "name": "Annotations & Alerts",
        "type": "dashboard"
      }
    ]
  },
  "editable": true,
  "gnetId": null,
  "graphTooltip": 0,
  "id": 1079,
  "iteration": 1572532026834,
  "links": [],
  "panels": [
    {
      "aliasColors": {},
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "datasource": null,
      "fill": 1,
      "gridPos": {
        "h": 9,
        "w": 12,
        "x": 0,
        "y": 0
      },
      "id": 2,
      "legend": {
        "avg": false,
        "current": false,
        "max": false,
        "min": false,
        "show": true,
        "total": false,
        "values": false
      },
      "lines": true,
      "linewidth": 1,
      "links": [],
      "nullPointMode": "connected",
      "percentage": false,
      "pointradius": 5,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [
        {
          "alias": "Burner state",
          "yaxis": 2
        },
        {
          "alias": "Modulation level",
          "yaxis": 2
        },
        {
          "alias": "Boiler set temp",
          "yaxis": 2
        }
      ],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "alias": "Boiler set temp",
          "groupBy": [
            {
              "params": [
                "$__interval"
              ],
              "type": "time"
            },
            {
              "params": [
                "previous"
              ],
              "type": "fill"
            }
          ],
          "measurement": "thermostat",
          "orderByTime": "ASC",
          "policy": "default",
          "refId": "A",
          "resultFormat": "time_series",
          "select": [
            [
              {
                "params": [
                  "boilersettemp"
                ],
                "type": "field"
              },
              {
                "params": [],
                "type": "mean"
              }
            ]
          ],
          "tags": [
            {
              "key": "hostname",
              "operator": "=~",
              "value": "/^$Hostname$/"
            }
          ]
        },
        {
          "alias": "Burner state",
          "groupBy": [
            {
              "params": [
                "$__interval"
              ],
              "type": "time"
            },
            {
              "params": [
                "previous"
              ],
              "type": "fill"
            }
          ],
          "measurement": "thermostat",
          "orderByTime": "ASC",
          "policy": "default",
          "refId": "B",
          "resultFormat": "time_series",
          "select": [
            [
              {
                "params": [
                  "burnerstate"
                ],
                "type": "field"
              },
              {
                "params": [],
                "type": "mean"
              },
              {
                "params": [
                  "*25"
                ],
                "type": "math"
              }
            ]
          ],
          "tags": [
            {
              "key": "hostname",
              "operator": "=~",
              "value": "/^$Hostname$/"
            }
          ]
        },
        {
          "alias": "Current temperature",
          "groupBy": [
            {
              "params": [
                "$__interval"
              ],
              "type": "time"
            },
            {
              "params": [
                "previous"
              ],
              "type": "fill"
            }
          ],
          "measurement": "thermostat",
          "orderByTime": "ASC",
          "policy": "default",
          "refId": "C",
          "resultFormat": "time_series",
          "select": [
            [
              {
                "params": [
                  "curtemp"
                ],
                "type": "field"
              },
              {
                "params": [],
                "type": "mean"
              }
            ]
          ],
          "tags": [
            {
              "key": "hostname",
              "operator": "=~",
              "value": "/^$Hostname$/"
            }
          ]
        },
        {
          "alias": "Setpoint temperature",
          "groupBy": [
            {
              "params": [
                "$__interval"
              ],
              "type": "time"
            },
            {
              "params": [
                "previous"
              ],
              "type": "fill"
            }
          ],
          "measurement": "thermostat",
          "orderByTime": "ASC",
          "policy": "default",
          "refId": "D",
          "resultFormat": "time_series",
          "select": [
            [
              {
                "params": [
                  "settemp"
                ],
                "type": "field"
              },
              {
                "params": [],
                "type": "mean"
              }
            ]
          ],
          "tags": [
            {
              "key": "hostname",
              "operator": "=~",
              "value": "/^$Hostname$/"
            }
          ]
        },
        {
          "alias": "Modulation level",
          "groupBy": [
            {
              "params": [
                "$__interval"
              ],
              "type": "time"
            },
            {
              "params": [
                "previous"
              ],
              "type": "fill"
            }
          ],
          "measurement": "thermostat",
          "orderByTime": "ASC",
          "policy": "default",
          "refId": "E",
          "resultFormat": "time_series",
          "select": [
            [
              {
                "params": [
                  "modulationlevel"
                ],
                "type": "field"
              },
              {
                "params": [],
                "type": "mean"
              }
            ]
          ],
          "tags": [
            {
              "key": "hostname",
              "operator": "=~",
              "value": "/^$Hostname$/"
            }
          ]
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeShift": null,
      "title": "Thermostat values - $Hostname",
      "tooltip": {
        "shared": true,
        "sort": 0,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "format": "celsius",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": "100",
          "min": "0",
          "show": true
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": null
      }
    }
  ],
  "schemaVersion": 16,
  "style": "dark",
  "tags": [],
  "templating": {
    "list": [
      {
        "allValue": null,
        "current": {
          "text": "choose our toon",
          "value": "choose our toon"
        },
        "datasource": "influx_auto_Toon",
        "hide": 0,
        "includeAll": false,
        "label": null,
        "multi": false,
        "name": "Hostname",
        "query": "show tag values with key = \"hostname\"",
        "refresh": 1,
        "regex": "",
        "skipUrlSync": false,
        "sort": 0,
        "tagValuesQuery": "",
        "tags": [],
        "tagsQuery": "",
        "type": "query",
        "useTags": false
      }
    ]
  },
  "time": {
    "from": "now/d",
    "to": "now"
  },
  "timepicker": {
    "refresh_intervals": [
      "5s",
      "10s",
      "30s",
      "1m",
      "5m",
      "15m",
      "30m",
      "1h",
      "2h",
      "1d"
    ],
    "time_options": [
      "5m",
      "15m",
      "1h",
      "6h",
      "12h",
      "24h",
      "2d",
      "7d",
      "30d"
    ]
  },
  "timezone": "",
  "title": "Toon dashboard",
  "uid": "Nru7--AZk",
  "version": 7
}
Member of the Toon Software Collective
Post Reply

Return to “Toon miscellaneous”