Skip to content

Instantly share code, notes, and snippets.

@ytjohn
Last active March 19, 2024 22:00
Show Gist options
  • Save ytjohn/8f65f66693a4105f9aeff13357ab76c1 to your computer and use it in GitHub Desktop.
Save ytjohn/8f65f66693a4105f9aeff13357ab76c1 to your computer and use it in GitHub Desktop.
waterfurnace dashboard

I have an exporter (python below) that exposes metrics in prometheus format. That puts it into the default datasource of "inlfux".

screenshots: https://imgur.com/a/xBpfEDY

A second datasource is called weather-influx, which comes from my weatherstation, passed in through http://www.weewx.com/ - but but if you don't have a weatherstation or weewx, you can find another way to get outside temps into influxdb. Otherwise, you can remove that outTemp_F stat.

requirements.txt (pip install):

prometheus_client
waterfurnace

To start, I use a shell script:

#!/bin/bash

WF_USERNAME="[email protected]"
WF_PASSWORD="password"
WF_UNIT="00M4C0FUN1T"

export WF_USERNAME
export WF_PASSWORD
export WF_UNIT

cd /opt/waterfurnace
/opt/waterfurnace/bin/python waterfurnaceexporter.py

I'm using telegraf to dump these into influxdb with its prometheus input.

# Read metrics from one or many prometheus clients
[[inputs.prometheus]]
  ## An array of urls to scrape metrics from.
  urls = ["http://inveigh:8912"]

In weewx.conf

[StdRESTful]
    [[Influx]]
        host = inveigh
        database = weather
        tags = station=stthomas
{
"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": 2,
"links": [],
"panels": [
{
"cacheTimeout": null,
"colorBackground": true,
"colorValue": false,
"colors": [
"#447ebc",
"#629e51",
"#d44a3a"
],
"datasource": "weather-influx",
"format": "none",
"gauge": {
"maxValue": 100,
"minValue": 0,
"show": true,
"thresholdLabels": true,
"thresholdMarkers": true
},
"gridPos": {
"h": 6,
"w": 3,
"x": 0,
"y": 0
},
"id": 23,
"interval": null,
"links": [],
"mappingType": 1,
"mappingTypes": [
{
"name": "value to text",
"value": 1
},
{
"name": "range to text",
"value": 2
}
],
"maxDataPoints": 100,
"nullPointMode": "connected",
"nullText": null,
"postfix": "",
"postfixFontSize": "50%",
"prefix": "",
"prefixFontSize": "50%",
"rangeMaps": [
{
"from": "null",
"text": "N/A",
"to": "null"
}
],
"sparkline": {
"fillColor": "rgba(31, 118, 189, 0.18)",
"full": false,
"lineColor": "#e5ac0e",
"show": true
},
"tableColumn": "",
"targets": [
{
"groupBy": [
{
"params": [
"$__interval"
],
"type": "time"
},
{
"params": [
"null"
],
"type": "fill"
}
],
"measurement": "record",
"orderByTime": "ASC",
"policy": "default",
"refId": "A",
"resultFormat": "time_series",
"select": [
[
{
"params": [
"outTemp_F"
],
"type": "field"
},
{
"params": [],
"type": "mean"
}
]
],
"tags": []
}
],
"thresholds": "50,79",
"title": "Outdoor Temp",
"type": "singlestat",
"valueFontSize": "80%",
"valueMaps": [
{
"op": "=",
"text": "N/A",
"value": "null"
}
],
"valueName": "avg"
},
{
"cacheTimeout": null,
"colorBackground": true,
"colorValue": false,
"colors": [
"#0a50a1",
"#7eb26d",
"#d44a3a"
],
"datasource": null,
"format": "none",
"gauge": {
"maxValue": 100,
"minValue": 0,
"show": false,
"thresholdLabels": false,
"thresholdMarkers": true
},
"gridPos": {
"h": 6,
"w": 3,
"x": 3,
"y": 0
},
"id": 12,
"interval": null,
"links": [],
"mappingType": 1,
"mappingTypes": [
{
"name": "value to text",
"value": 1
},
{
"name": "range to text",
"value": 2
}
],
"maxDataPoints": 100,
"nullPointMode": "connected",
"nullText": null,
"postfix": "F",
"postfixFontSize": "80%",
"prefix": "",
"prefixFontSize": "50%",
"rangeMaps": [
{
"from": "null",
"text": "N/A",
"to": "null"
}
],
"sparkline": {
"fillColor": "rgba(31, 118, 189, 0.18)",
"full": false,
"lineColor": "rgb(31, 120, 193)",
"show": true
},
"tableColumn": "",
"targets": [
{
"alias": "Room Temp",
"groupBy": [
{
"params": [
"$__interval"
],
"type": "time"
},
{
"params": [
"null"
],
"type": "fill"
}
],
"measurement": "wf_tstatroomtemp",
"orderByTime": "ASC",
"policy": "default",
"refId": "A",
"resultFormat": "time_series",
"select": [
[
{
"params": [
"gauge"
],
"type": "field"
},
{
"params": [],
"type": "mean"
}
]
],
"tags": []
}
],
"thresholds": "66,73",
"title": "Indoor",
"type": "singlestat",
"valueFontSize": "80%",
"valueMaps": [
{
"op": "=",
"text": "N/A",
"value": "null"
}
],
"valueName": "current"
},
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": null,
"decimals": 2,
"fill": 1,
"gridPos": {
"h": 6,
"w": 5,
"x": 6,
"y": 0
},
"id": 21,
"legend": {
"alignAsTable": true,
"avg": true,
"current": true,
"max": true,
"min": true,
"rightSide": false,
"show": true,
"sort": "avg",
"sortDesc": true,
"total": false,
"values": true
},
"lines": true,
"linewidth": 1,
"links": [],
"nullPointMode": "null",
"percentage": false,
"pointradius": 5,
"points": false,
"renderer": "flot",
"seriesOverrides": [],
"spaceLength": 10,
"stack": false,
"steppedLine": false,
"targets": [
{
"alias": "Observed",
"groupBy": [
{
"params": [
"$__interval"
],
"type": "time"
},
{
"params": [
"null"
],
"type": "fill"
}
],
"measurement": "wf_tstatroomtemp",
"orderByTime": "ASC",
"policy": "default",
"refId": "C",
"resultFormat": "time_series",
"select": [
[
{
"params": [
"gauge"
],
"type": "field"
},
{
"params": [],
"type": "mean"
}
]
],
"tags": []
},
{
"alias": "Set",
"groupBy": [
{
"params": [
"$__interval"
],
"type": "time"
},
{
"params": [
"null"
],
"type": "fill"
}
],
"measurement": "wf_tstatactivesetpoint",
"orderByTime": "ASC",
"policy": "default",
"refId": "A",
"resultFormat": "time_series",
"select": [
[
{
"params": [
"gauge"
],
"type": "field"
},
{
"params": [],
"type": "mean"
}
]
],
"tags": []
}
],
"thresholds": [],
"timeFrom": null,
"timeShift": null,
"title": "Set vs Actual",
"tooltip": {
"shared": true,
"sort": 0,
"value_type": "individual"
},
"transparent": true,
"type": "graph",
"xaxis": {
"buckets": null,
"mode": "time",
"name": null,
"show": true,
"values": []
},
"yaxes": [
{
"format": "short",
"label": "",
"logBase": 1,
"max": null,
"min": null,
"show": true
},
{
"format": "farenheit",
"label": "",
"logBase": 1,
"max": null,
"min": null,
"show": true
}
],
"yaxis": {
"align": false,
"alignLevel": null
}
},
{
"cacheTimeout": null,
"colorBackground": false,
"colorValue": false,
"colors": [
"#1f78c1",
"#508642",
"#890f02"
],
"datasource": null,
"decimals": null,
"format": "farenheit",
"gauge": {
"maxValue": 80,
"minValue": 55,
"show": true,
"thresholdLabels": true,
"thresholdMarkers": true
},
"gridPos": {
"h": 6,
"w": 3,
"x": 11,
"y": 0
},
"id": 10,
"interval": null,
"links": [],
"mappingType": 1,
"mappingTypes": [
{
"name": "value to text",
"value": 1
},
{
"name": "range to text",
"value": 2
}
],
"maxDataPoints": 100,
"nullPointMode": "connected",
"nullText": null,
"postfix": "",
"postfixFontSize": "80%",
"prefix": "",
"prefixFontSize": "50%",
"rangeMaps": [
{
"from": "null",
"text": "N/A",
"to": "null"
}
],
"sparkline": {
"fillColor": "rgba(31, 118, 189, 0.18)",
"full": false,
"lineColor": "rgb(31, 120, 193)",
"show": false
},
"tableColumn": "",
"targets": [
{
"groupBy": [
{
"params": [
"$__interval"
],
"type": "time"
},
{
"params": [
"null"
],
"type": "fill"
}
],
"measurement": "wf_tstatactivesetpoint",
"orderByTime": "ASC",
"policy": "default",
"refId": "A",
"resultFormat": "time_series",
"select": [
[
{
"params": [
"gauge"
],
"type": "field"
},
{
"params": [],
"type": "mean"
}
]
],
"tags": []
}
],
"thresholds": "64,75",
"title": "Thermostat Set Point",
"type": "singlestat",
"valueFontSize": "80%",
"valueMaps": [
{
"op": "=",
"text": "N/A",
"value": "null"
}
],
"valueName": "current"
},
{
"cacheTimeout": null,
"colorBackground": false,
"colorValue": false,
"colors": [
"#299c46",
"rgba(237, 129, 40, 0.89)",
"#d44a3a"
],
"datasource": null,
"format": "none",
"gauge": {
"maxValue": 100,
"minValue": 0,
"show": false,
"thresholdLabels": false,
"thresholdMarkers": true
},
"gridPos": {
"h": 6,
"w": 2,
"x": 14,
"y": 0
},
"id": 18,
"interval": null,
"links": [],
"mappingType": 1,
"mappingTypes": [
{
"name": "value to text",
"value": 1
},
{
"name": "range to text",
"value": 2
}
],
"maxDataPoints": 100,
"nullPointMode": "connected",
"nullText": null,
"postfix": "",
"postfixFontSize": "50%",
"prefix": "",
"prefixFontSize": "50%",
"rangeMaps": [
{
"from": "null",
"text": "N/A",
"to": "null"
}
],
"sparkline": {
"fillColor": "rgba(31, 118, 189, 0.18)",
"full": false,
"lineColor": "rgb(31, 120, 193)",
"show": true
},
"tableColumn": "",
"targets": [
{
"groupBy": [
{
"params": [
"$__interval"
],
"type": "time"
},
{
"params": [
"null"
],
"type": "fill"
}
],
"measurement": "wf_modeofoperation",
"orderByTime": "ASC",
"policy": "default",
"refId": "A",
"resultFormat": "time_series",
"select": [
[
{
"params": [
"gauge"
],
"type": "field"
},
{
"params": [],
"type": "mean"
}
]
],
"tags": []
}
],
"thresholds": "",
"title": "Mode",
"type": "singlestat",
"valueFontSize": "80%",
"valueMaps": [
{
"op": "=",
"text": "Standby",
"value": "0"
},
{
"op": "=",
"text": "Fan",
"value": "1"
},
{
"op": "=",
"text": "Cool 1",
"value": "2"
},
{
"op": "=",
"text": "Cool 2",
"value": "3"
},
{
"op": "=",
"text": "Reheat",
"value": "4"
},
{
"op": "=",
"text": "Heat 1",
"value": "5"
},
{
"op": "=",
"text": "Heat 2",
"value": "6"
},
{
"op": "=",
"text": "E-Heat",
"value": "7"
},
{
"op": "=",
"text": "Aux Heat",
"value": "8"
},
{
"op": "=",
"text": "Lockout",
"value": "9"
}
],
"valueName": "current"
},
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": null,
"decimals": 0,
"fill": 1,
"gridPos": {
"h": 6,
"w": 2,
"x": 16,
"y": 0
},
"id": 20,
"legend": {
"alignAsTable": true,
"avg": true,
"current": true,
"max": true,
"min": true,
"show": true,
"total": false,
"values": true
},
"lines": true,
"linewidth": 1,
"links": [],
"nullPointMode": "null",
"percentage": false,
"pointradius": 5,
"points": false,
"renderer": "flot",
"seriesOverrides": [],
"spaceLength": 10,
"stack": false,
"steppedLine": false,
"targets": [
{
"alias": "Fan Speed",
"groupBy": [
{
"params": [
"$__interval"
],
"type": "time"
},
{
"params": [
"null"
],
"type": "fill"
}
],
"measurement": "wf_airflowcurrentspeed",
"orderByTime": "ASC",
"policy": "default",
"refId": "A",
"resultFormat": "time_series",
"select": [
[
{
"params": [
"gauge"
],
"type": "field"
},
{
"params": [],
"type": "mean"
}
]
],
"tags": []
}
],
"thresholds": [],
"timeFrom": null,
"timeShift": null,
"title": "Fan Speed",
"tooltip": {
"shared": true,
"sort": 0,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"buckets": null,
"mode": "time",
"name": null,
"show": true,
"values": []
},
"yaxes": [
{
"format": "short",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
},
{
"format": "short",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
}
],
"yaxis": {
"align": false,
"alignLevel": null
}
},
{
"cacheTimeout": null,
"colorBackground": true,
"colorValue": false,
"colors": [
"#299c46",
"#000000",
"#d44a3a"
],
"datasource": null,
"format": "watt",
"gauge": {
"maxValue": 2300,
"minValue": 0,
"show": true,
"thresholdLabels": true,
"thresholdMarkers": true
},
"gridPos": {
"h": 6,
"w": 5,
"x": 18,
"y": 0
},
"id": 14,
"interval": null,
"links": [],
"mappingType": 1,
"mappingTypes": [
{
"name": "value to text",
"value": 1
},
{
"name": "range to text",
"value": 2
}
],
"maxDataPoints": 100,
"nullPointMode": "connected",
"nullText": null,
"postfix": "",
"postfixFontSize": "80%",
"prefix": "",
"prefixFontSize": "50%",
"rangeMaps": [
{
"from": "null",
"text": "N/A",
"to": "null"
}
],
"sparkline": {
"fillColor": "rgba(31, 118, 189, 0.18)",
"full": false,
"lineColor": "rgb(31, 120, 193)",
"show": true
},
"tableColumn": "",
"targets": [
{
"groupBy": [
{
"params": [
"$__interval"
],
"type": "time"
},
{
"params": [
"null"
],
"type": "fill"
}
],
"measurement": "wf_totalunitpower",
"orderByTime": "ASC",
"policy": "default",
"refId": "A",
"resultFormat": "time_series",
"select": [
[
{
"params": [
"gauge"
],
"type": "field"
},
{
"params": [],
"type": "mean"
}
]
],
"tags": []
}
],
"thresholds": "600,1800",
"title": "Total Power",
"type": "singlestat",
"valueFontSize": "80%",
"valueMaps": [
{
"op": "=",
"text": "N/A",
"value": "null"
}
],
"valueName": "current"
},
{
"collapsed": false,
"gridPos": {
"h": 1,
"w": 24,
"x": 0,
"y": 6
},
"id": 16,
"panels": [],
"title": "Stats",
"type": "row"
},
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": "-- Mixed --",
"fill": 0,
"gridPos": {
"h": 14,
"w": 11,
"x": 0,
"y": 7
},
"id": 6,
"legend": {
"alignAsTable": true,
"avg": true,
"current": true,
"max": true,
"min": true,
"rightSide": false,
"show": true,
"sort": "avg",
"sortDesc": true,
"total": false,
"values": true
},
"lines": true,
"linewidth": 1,
"links": [],
"nullPointMode": "connected",
"percentage": false,
"pointradius": 5,
"points": false,
"renderer": "flot",
"seriesOverrides": [
{
"alias": "Outside",
"color": "#962d82",
"linewidth": 3
},
{
"alias": "Tstat Room Temp",
"linewidth": 3
}
],
"spaceLength": 10,
"stack": false,
"steppedLine": false,
"targets": [
{
"alias": "Leaving AIr Temp",
"datasource": "influx",
"groupBy": [
{
"params": [
"$__interval"
],
"type": "time"
},
{
"params": [
"null"
],
"type": "fill"
}
],
"hide": false,
"measurement": "wf_leavingairtemp",
"orderByTime": "ASC",
"policy": "default",
"refId": "A",
"resultFormat": "time_series",
"select": [
[
{
"params": [
"gauge"
],
"type": "field"
},
{
"params": [],
"type": "mean"
}
]
],
"tags": []
},
{
"alias": "Outside",
"datasource": "weather-influx",
"groupBy": [
{
"params": [
"$__interval"
],
"type": "time"
},
{
"params": [
"null"
],
"type": "fill"
}
],
"measurement": "record",
"orderByTime": "ASC",
"policy": "default",
"refId": "E",
"resultFormat": "time_series",
"select": [
[
{
"params": [
"outTemp_F"
],
"type": "field"
},
{
"params": [],
"type": "mean"
}
]
],
"tags": []
},
{
"alias": "Cooling Set Point",
"datasource": "influx",
"groupBy": [
{
"params": [
"$__interval"
],
"type": "time"
},
{
"params": [
"null"
],
"type": "fill"
}
],
"measurement": "wf_tstatcoolingsetpoint",
"orderByTime": "ASC",
"policy": "default",
"refId": "F",
"resultFormat": "time_series",
"select": [
[
{
"params": [
"gauge"
],
"type": "field"
},
{
"params": [],
"type": "mean"
}
]
],
"tags": []
},
{
"alias": "Tstat Room Temp",
"datasource": "influx",
"groupBy": [
{
"params": [
"$__interval"
],
"type": "time"
},
{
"params": [
"null"
],
"type": "fill"
}
],
"measurement": "wf_tstatroomtemp",
"orderByTime": "ASC",
"policy": "default",
"refId": "C",
"resultFormat": "time_series",
"select": [
[
{
"params": [
"gauge"
],
"type": "field"
},
{
"params": [],
"type": "mean"
}
]
],
"tags": []
},
{
"alias": "Heat Set Point",
"datasource": "influx",
"groupBy": [
{
"params": [
"$__interval"
],
"type": "time"
},
{
"params": [
"null"
],
"type": "fill"
}
],
"measurement": "wf_tstatheatingsetpoint",
"orderByTime": "ASC",
"policy": "default",
"refId": "D",
"resultFormat": "time_series",
"select": [
[
{
"params": [
"gauge"
],
"type": "field"
},
{
"params": [],
"type": "mean"
}
]
],
"tags": []
},
{
"alias": "Ground Loop Entering Water Temp",
"datasource": "influx",
"groupBy": [
{
"params": [
"$__interval"
],
"type": "time"
},
{
"params": [
"null"
],
"type": "fill"
}
],
"measurement": "wf_enteringwatertemp",
"orderByTime": "ASC",
"policy": "default",
"refId": "B",
"resultFormat": "time_series",
"select": [
[
{
"params": [
"gauge"
],
"type": "field"
},
{
"params": [],
"type": "mean"
}
]
],
"tags": []
}
],
"thresholds": [],
"timeFrom": null,
"timeShift": null,
"title": "Temperatures",
"tooltip": {
"shared": true,
"sort": 0,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"buckets": null,
"mode": "time",
"name": null,
"show": true,
"values": []
},
"yaxes": [
{
"format": "short",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
},
{
"format": "farenheit",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
}
],
"yaxis": {
"align": false,
"alignLevel": null
}
},
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": null,
"fill": 1,
"gridPos": {
"h": 14,
"w": 12,
"x": 11,
"y": 7
},
"id": 4,
"legend": {
"alignAsTable": true,
"avg": true,
"current": true,
"max": true,
"min": true,
"rightSide": false,
"show": true,
"sort": "avg",
"sortDesc": true,
"total": false,
"values": true
},
"lines": true,
"linewidth": 1,
"links": [],
"nullPointMode": "null",
"percentage": false,
"pointradius": 5,
"points": false,
"renderer": "flot",
"seriesOverrides": [],
"spaceLength": 10,
"stack": false,
"steppedLine": false,
"targets": [
{
"alias": "Total Power (W)",
"groupBy": [
{
"params": [
"$__interval"
],
"type": "time"
},
{
"params": [
"null"
],
"type": "fill"
}
],
"measurement": "wf_totalunitpower",
"orderByTime": "ASC",
"policy": "default",
"refId": "A",
"resultFormat": "time_series",
"select": [
[
{
"params": [
"gauge"
],
"type": "field"
},
{
"params": [],
"type": "mean"
}
]
],
"tags": []
},
{
"alias": "Compressor Power",
"groupBy": [
{
"params": [
"$__interval"
],
"type": "time"
},
{
"params": [
"null"
],
"type": "fill"
}
],
"measurement": "wf_compressorpower",
"orderByTime": "ASC",
"policy": "default",
"refId": "C",
"resultFormat": "time_series",
"select": [
[
{
"params": [
"gauge"
],
"type": "field"
},
{
"params": [],
"type": "mean"
}
]
],
"tags": []
},
{
"alias": "Fan Power (W)",
"groupBy": [
{
"params": [
"$__interval"
],
"type": "time"
},
{
"params": [
"null"
],
"type": "fill"
}
],
"measurement": "wf_fanpower",
"orderByTime": "ASC",
"policy": "default",
"refId": "D",
"resultFormat": "time_series",
"select": [
[
{
"params": [
"gauge"
],
"type": "field"
},
{
"params": [],
"type": "mean"
}
]
],
"tags": []
},
{
"alias": "Aux Heat Power (W)",
"groupBy": [
{
"params": [
"$__interval"
],
"type": "time"
},
{
"params": [
"null"
],
"type": "fill"
}
],
"measurement": "wf_auxpower",
"orderByTime": "ASC",
"policy": "default",
"refId": "B",
"resultFormat": "time_series",
"select": [
[
{
"params": [
"gauge"
],
"type": "field"
},
{
"params": [],
"type": "mean"
}
]
],
"tags": []
},
{
"alias": "Loop Pump Power (W)",
"groupBy": [
{
"params": [
"$__interval"
],
"type": "time"
},
{
"params": [
"null"
],
"type": "fill"
}
],
"measurement": "wf_looppumppower",
"orderByTime": "ASC",
"policy": "default",
"refId": "E",
"resultFormat": "time_series",
"select": [
[
{
"params": [
"gauge"
],
"type": "field"
},
{
"params": [],
"type": "mean"
}
]
],
"tags": []
}
],
"thresholds": [],
"timeFrom": null,
"timeShift": null,
"title": "Power",
"tooltip": {
"shared": true,
"sort": 0,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"buckets": null,
"mode": "time",
"name": null,
"show": true,
"values": []
},
"yaxes": [
{
"format": "short",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
},
{
"decimals": null,
"format": "short",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
}
],
"yaxis": {
"align": false,
"alignLevel": null
}
}
],
"refresh": "30s",
"schemaVersion": 16,
"style": "dark",
"tags": [],
"templating": {
"list": []
},
"time": {
"from": "now-12h",
"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": "WaterFurnace",
"uid": "j5QopZLiz",
"version": 7
}
from prometheus_client import start_http_server, Summary
from prometheus_client.core import GaugeMetricFamily
from prometheus_client import Gauge
from waterfurnace.waterfurnace import WaterFurnace
import os
import sys
import random
import time
import logging
logging.basicConfig()
logger = logging.getLogger()
logger.setLevel(logging.WARN)
# REQUEST_TIME = Summary('request_processing_seconds', 'Time spent processing request', ["unit"])
# Create a metric to track time spent and requests made.
#c = Counter('my_requests_total', 'HTTP Failures', ['method', 'endpoint'])
airflowcurrentspeed = Gauge(
"wf_airflowcurrentspeed", "Current Air Speed", ["unit"])
auxpower = Gauge(
"wf_auxpower", "Aux Heat Power in Watts", ["unit"])
compressorpower = Gauge(
"wf_compressorpower", "Compressor Power Usage in Watts", ["unit"])
enteringwatertemp = Gauge("wf_enteringwatertemp", "Entering Water Tem (F)", ["unit"])
fanpower = Gauge("wf_fanpower", "Fan Power Usage in Watts", ["unit"])
leavingairtemp = Gauge("wf_leavingairtemp", "Leavin Air Temp (F)", ["unit"])
looppumppower = Gauge("wf_looppumppower", "Loop Pump Power in Watts", ["unit"])
modeofoperation = Gauge("wf_modeofoperation", "System current mode", ["unit"])
totalunitpower = Gauge("wf_totalunitpower", "Total Power Usage in Watts", ["unit"])
tstatactivesetpoint = Gauge("wf_tstatactivesetpoint", "Thermostat active set point (F)", ["unit"])
tstatcoolingsetpoint = Gauge("wf_tstatcoolingsetpoint", "Thermostat Cooling set point (F)", ["unit"])
tstatdehumidsetpoint = Gauge("wf_tstatdehumidsetpoint", "Thermostat Dehumidier set point (%)", ["unit"])
tstatheatingsetpoint = Gauge("wf_tstatheatingsetpoint", "Thermostat Heating set point (F)", ["unit"])
tstathumidsetpoint = Gauge("wf_tstathumidsetpoint", "Thermostat Humidifier set point (%)", ["unit"])
tstatrelativehumidity = Gauge("wf_tstatrelativehumidity", "Thermostat relevite humidity (%)", ["unit"])
tstatroomtemp = Gauge("wf_tstatroomtemp", "Thermostat Room Temp (F)", ["unit"])
class Settings(object):
def __init__(self):
self.username = os.environ.get('WF_USERNAME', False)
self.password = os.environ.get('WF_PASSWORD', False)
self.unit = os.environ.get('WF_UNIT', False)
# @REQUEST_TIME.time('placeholder')
def update_metrics(waterfurnace):
"""Fetch metrics from waterfurnace and add to metrics.
Input:
waterfurnace (object): waterfurnace client.
"""
data = waterfurnace.read()
logger.debug("{}".format(data))
unit = data.awlid
airflowcurrentspeed.labels(unit).set(data.airflowcurrentspeed)
auxpower.labels(unit).set(data.auxpower)
compressorpower.labels(unit).set(data.compressorpower)
enteringwatertemp.labels(unit).set(data.enteringwatertemp)
fanpower.labels(unit).set(data.fanpower)
leavingairtemp.labels(unit).set(data.leavingairtemp)
looppumppower.labels(unit).set(data.looppumppower)
modeofoperation.labels(unit).set(data.modeofoperation)
totalunitpower.labels(unit).set(data.totalunitpower)
tstatactivesetpoint.labels(unit).set(data.tstatactivesetpoint)
tstatcoolingsetpoint.labels(unit).set(data.tstatcoolingsetpoint)
tstatdehumidsetpoint.labels(unit).set(data.tstatdehumidsetpoint)
tstatheatingsetpoint.labels(unit).set(data.tstatheatingsetpoint)
tstathumidsetpoint.labels(unit).set(data.tstathumidsetpoint)
tstatrelativehumidity.labels(unit).set(data.tstatrelativehumidity)
tstatroomtemp.labels(unit).set(data.tstatroomtemp)
if __name__ == '__main__':
# Start up the server to expose the metrics.
start_http_server(8912)
logger.debug("started server")
settings = Settings()
if not (settings.username and settings.password and settings.unit):
sys.exit("You must set WF_USERNAME, WF_PASSWORD, WF_UNIT")
wf = WaterFurnace(settings.username, settings.password, settings.unit)
wf.login()
logger.debug("logged into waterfurnace, we hope")
# Generate some requests.
while True:
logger.debug("about to update metrics")
update_metrics(wf)
time.sleep(9)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment