Skip to content

Instantly share code, notes, and snippets.

@bdwilson
Created January 9, 2021 19:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bdwilson/bfebf4ffad25fee4f3bffbb7cf1b6f17 to your computer and use it in GitHub Desktop.
Save bdwilson/bfebf4ffad25fee4f3bffbb7cf1b6f17 to your computer and use it in GitHub Desktop.
Hubitat Performance Node-red Node - requires influxdb node, pushover node, note at top of flow has config instructions.
[
{
"id": "43ac6c1.6e31c94",
"type": "subflow",
"name": "Check Mem",
"info": "",
"category": "",
"in": [
{
"x": 50,
"y": 30,
"wires": [
{
"id": "aae357be.dd5bc8"
}
]
}
],
"out": [
{
"x": 820,
"y": 280,
"wires": [
{
"id": "6aeb7ef4.8dfae",
"port": 0
}
]
}
],
"env": [],
"color": "#DDAA99"
},
{
"id": "68199469.2e8c1c",
"type": "http request",
"z": "43ac6c1.6e31c94",
"name": "Get Free Mem",
"method": "GET",
"ret": "txt",
"paytoqs": "ignore",
"url": "",
"tls": "",
"persist": false,
"proxy": "",
"authType": "",
"x": 360,
"y": 100,
"wires": [
[
"6888c7ab.da6ba8"
]
]
},
{
"id": "aae357be.dd5bc8",
"type": "function",
"z": "43ac6c1.6e31c94",
"name": "Build Free Memory URL",
"func": "msg.url = \"http://\" + flow.get(\"$parent.hubIP\") + \"/hub/advanced/freeOSMemory\"\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 150,
"y": 100,
"wires": [
[
"68199469.2e8c1c"
]
]
},
{
"id": "6aeb7ef4.8dfae",
"type": "change",
"z": "43ac6c1.6e31c94",
"name": "Add freeMemValue",
"rules": [
{
"t": "set",
"p": "freeMemValue",
"pt": "msg",
"to": "payload",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 810,
"y": 100,
"wires": [
[]
]
},
{
"id": "6888c7ab.da6ba8",
"type": "switch",
"z": "43ac6c1.6e31c94",
"name": "Did we get a value > 0?",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "gt",
"v": "0",
"vt": "num"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 570,
"y": 100,
"wires": [
[
"6aeb7ef4.8dfae"
]
]
},
{
"id": "9d92739f.d0d64",
"type": "subflow",
"name": "Check Time",
"info": "",
"category": "",
"in": [
{
"x": 60,
"y": 100,
"wires": [
{
"id": "e7bb410b.23be4"
}
]
}
],
"out": [
{
"x": 1050,
"y": 100,
"wires": [
{
"id": "1b1bcd68.5341b3",
"port": 0
}
]
}
],
"env": []
},
{
"id": "e7bb410b.23be4",
"type": "time-range-switch",
"z": "9d92739f.d0d64",
"name": "Am I Awake?",
"lat": "35.66797",
"lon": "-78.62354",
"startTime": "07:30",
"endTime": "22:30",
"startOffset": 0,
"endOffset": 0,
"x": 180,
"y": 100,
"wires": [
[
"6a1a35f2.e1ef9c"
],
[
"c2b68233.30716"
]
]
},
{
"id": "74587240.2245ec",
"type": "time-range-switch",
"z": "9d92739f.d0d64",
"name": "Maintenance Window?",
"lat": "35.66797",
"lon": "-78.62354",
"startTime": "02:00",
"endTime": "03:00",
"startOffset": 0,
"endOffset": 0,
"x": 550,
"y": 100,
"wires": [
[
"22e93162.f1ae3e"
],
[
"b1d549cf.166e38"
]
]
},
{
"id": "22e93162.f1ae3e",
"type": "change",
"z": "9d92739f.d0d64",
"name": "Yes",
"rules": [
{
"t": "set",
"p": "inMaintenance",
"pt": "msg",
"to": "true",
"tot": "bool"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 750,
"y": 50,
"wires": [
[
"1b1bcd68.5341b3"
]
]
},
{
"id": "b1d549cf.166e38",
"type": "change",
"z": "9d92739f.d0d64",
"name": "No",
"rules": [
{
"t": "set",
"p": "inMaintenance",
"pt": "msg",
"to": "false",
"tot": "bool"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 750,
"y": 150,
"wires": [
[
"1b1bcd68.5341b3"
]
]
},
{
"id": "6a1a35f2.e1ef9c",
"type": "change",
"z": "9d92739f.d0d64",
"name": "Yes",
"rules": [
{
"t": "set",
"p": "awake",
"pt": "msg",
"to": "true",
"tot": "bool"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 350,
"y": 50,
"wires": [
[
"74587240.2245ec"
]
]
},
{
"id": "c2b68233.30716",
"type": "change",
"z": "9d92739f.d0d64",
"name": "No",
"rules": [
{
"t": "set",
"p": "awake",
"pt": "msg",
"to": "false",
"tot": "bool"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 350,
"y": 150,
"wires": [
[
"74587240.2245ec"
]
]
},
{
"id": "1b1bcd68.5341b3",
"type": "change",
"z": "9d92739f.d0d64",
"name": "Adjust Fields",
"rules": [
{
"t": "delete",
"p": "headers",
"pt": "msg"
},
{
"t": "delete",
"p": "starttime",
"pt": "msg"
},
{
"t": "delete",
"p": "endtime",
"pt": "msg"
},
{
"t": "delete",
"p": "redirectList",
"pt": "msg"
},
{
"t": "delete",
"p": "responseCookies",
"pt": "msg"
},
{
"t": "delete",
"p": "topic",
"pt": "msg"
},
{
"t": "delete",
"p": "payload",
"pt": "msg"
},
{
"t": "set",
"p": "reboot",
"pt": "msg",
"to": "false",
"tot": "bool"
},
{
"t": "delete",
"p": "url",
"pt": "msg"
},
{
"t": "delete",
"p": "responseUrl",
"pt": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 930,
"y": 100,
"wires": [
[]
]
},
{
"id": "588f2940.1ba848",
"type": "subflow",
"name": "Check Page",
"info": "",
"category": "",
"in": [
{
"x": 40,
"y": 80,
"wires": [
{
"id": "e1a197b2.ce6208"
}
]
}
],
"out": [
{
"x": 1150,
"y": 80,
"wires": [
{
"id": "9156ff4a.f5a61",
"port": 0
}
]
}
],
"env": []
},
{
"id": "ed4d8669.d3fe48",
"type": "http request",
"z": "588f2940.1ba848",
"name": "Get App List",
"method": "GET",
"ret": "bin",
"paytoqs": "ignore",
"url": "",
"tls": "",
"persist": false,
"proxy": "",
"authType": "",
"x": 500,
"y": 80,
"wires": [
[
"d5b40c47.eec4a"
]
]
},
{
"id": "d5b40c47.eec4a",
"type": "change",
"z": "588f2940.1ba848",
"name": "Add endtime",
"rules": [
{
"t": "set",
"p": "endtime",
"pt": "msg",
"to": "",
"tot": "date"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 670,
"y": 80,
"wires": [
[
"82fc59e4.931628"
]
]
},
{
"id": "e1a197b2.ce6208",
"type": "change",
"z": "588f2940.1ba848",
"name": "Add starttime & name",
"rules": [
{
"t": "set",
"p": "starttime",
"pt": "msg",
"to": "",
"tot": "date"
},
{
"t": "set",
"p": "displayName",
"pt": "msg",
"to": "Driver List Data",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 190,
"y": 80,
"wires": [
[
"a81ec577.c0b588"
]
]
},
{
"id": "9156ff4a.f5a61",
"type": "function",
"z": "588f2940.1ba848",
"name": "Do Math",
"func": "msg.responseTime = msg.endtime - msg.starttime;\nmsg.responseTime = msg.responseTime / 1000;\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 1040,
"y": 80,
"wires": [
[]
]
},
{
"id": "82fc59e4.931628",
"type": "change",
"z": "588f2940.1ba848",
"name": "This is not a test.",
"rules": [
{
"t": "set",
"p": "test",
"pt": "msg",
"to": "false",
"tot": "bool"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 860,
"y": 80,
"wires": [
[
"9156ff4a.f5a61"
]
]
},
{
"id": "a81ec577.c0b588",
"type": "function",
"z": "588f2940.1ba848",
"name": "Build URL",
"func": "msg.url = \"http://\" + flow.get(\"$parent.hubIP\") + \"/driver/list/data\"\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 360,
"y": 80,
"wires": [
[
"ed4d8669.d3fe48"
]
]
},
{
"id": "33ae8b6d.804ef4",
"type": "comment",
"z": "588f2940.1ba848",
"name": "URL's",
"info": "was /installedapp/list\n\nnow /driver/list/data\n\nAlso update displayName in the change node",
"x": 140,
"y": 160,
"wires": []
},
{
"id": "bcf0cb4f.bf9c88",
"type": "tab",
"label": "Hubitat Performance (LAN)",
"disabled": false,
"info": ""
},
{
"id": "6779c405.9249ac",
"type": "inject",
"z": "bcf0cb4f.bf9c88",
"name": "5 mins.",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "300",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 120,
"y": 80,
"wires": [
[
"7b3024a0.cff3ac",
"bd4f96a1.e05098"
]
]
},
{
"id": "5b3988b4.e22928",
"type": "http request",
"z": "bcf0cb4f.bf9c88",
"name": "Reboot Hub",
"method": "POST",
"ret": "obj",
"paytoqs": "ignore",
"url": "http://192.168.1.30/hub/reboot",
"tls": "",
"persist": false,
"proxy": "",
"authType": "",
"x": 1330,
"y": 590,
"wires": [
[]
]
},
{
"id": "427452fd.258c9c",
"type": "pushover api",
"z": "bcf0cb4f.bf9c88",
"keys": "b3ffec8b.aa42d",
"title": "Hubitat Watchdog",
"name": "Alert",
"x": 1210,
"y": 350,
"wires": []
},
{
"id": "1eeed210.271b0e",
"type": "delay",
"z": "bcf0cb4f.bf9c88",
"name": "YES: 1x/Hour",
"pauseType": "rate",
"timeout": "5",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "hour",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": true,
"x": 920,
"y": 310,
"wires": [
[
"71c5af71.65087"
]
]
},
{
"id": "5d44de04.5f9c9",
"type": "delay",
"z": "bcf0cb4f.bf9c88",
"name": "NO: Only Once",
"pauseType": "rate",
"timeout": "5",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "9",
"rateUnits": "hour",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": true,
"x": 920,
"y": 350,
"wires": [
[
"71c5af71.65087"
]
]
},
{
"id": "b6e5f1ea.e8d25",
"type": "config",
"z": "bcf0cb4f.bf9c88",
"name": "Configuration",
"properties": [
{
"p": "criticalsForReboot",
"pt": "flow",
"to": "2",
"tot": "num"
},
{
"p": "criticalsForRebootDuringMaintenance",
"pt": "flow",
"to": "3",
"tot": "num"
},
{
"p": "hubIP",
"pt": "flow",
"to": "192.168.1.30",
"tot": "str"
},
{
"p": "thresholdWarning",
"pt": "flow",
"to": "5",
"tot": "num"
},
{
"p": "thresholdCritical",
"pt": "flow",
"to": "15",
"tot": "num"
},
{
"p": "hubName",
"pt": "flow",
"to": "LAN",
"tot": "str"
},
{
"p": "deviceId",
"pt": "flow",
"to": "2",
"tot": "str"
},
{
"p": "supportsMemCheck",
"pt": "flow",
"to": "1",
"tot": "num"
},
{
"p": "memCritical",
"pt": "flow",
"to": "75000",
"tot": "num"
}
],
"active": true,
"x": 140,
"y": 40,
"wires": []
},
{
"id": "36d88dbb.bcd6c2",
"type": "change",
"z": "bcf0cb4f.bf9c88",
"name": "Log Auto Reboot",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "$.payload & \" CRITICAL! Rebooting Hub!\"",
"tot": "jsonata"
},
{
"t": "set",
"p": "rebootType",
"pt": "msg",
"to": "automatic",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 740,
"y": 530,
"wires": [
[
"d3c1b42b.60a0d8"
]
]
},
{
"id": "d7c1b6b0.215418",
"type": "function",
"z": "bcf0cb4f.bf9c88",
"name": "Crit",
"func": "flow.set(\"criticals\", flow.get(\"criticals\") + 1);\nmsg.severity = \"crit\";\nmsg.payload = \"Response time above CRITICAL threshold for Hub: \" + flow.get(\"hubName\");\n\nif (msg.inMaintenance) {\n msg.critsNeeded = flow.get(\"criticalsForRebootDuringMaintenance\");\n} else {\n msg.critsNeeded = flow.get(\"criticalsForReboot\");\n}\n\nif (flow.get(\"criticals\") >= msg.critsNeeded) {\n msg.reboot = true;\n flow.set(\"lastReboot\", Date.now());\n return msg;\n} else {\n return null;\n}",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 520,
"y": 370,
"wires": [
[
"36d88dbb.bcd6c2",
"35902faa.5ad7c",
"9963153b.9c0888"
]
]
},
{
"id": "77158b2c.a26b74",
"type": "switch",
"z": "bcf0cb4f.bf9c88",
"name": "Severity",
"property": "responseTime",
"propertyType": "msg",
"rules": [
{
"t": "lt",
"v": "thresholdWarning",
"vt": "flow"
},
{
"t": "lt",
"v": "thresholdCritical",
"vt": "flow"
},
{
"t": "gte",
"v": "thresholdCritical",
"vt": "flow"
}
],
"checkall": "false",
"repair": false,
"outputs": 3,
"x": 380,
"y": 330,
"wires": [
[
"c2767220.d8077"
],
[
"1450f867.ad7878"
],
[
"d7c1b6b0.215418"
]
]
},
{
"id": "5c002bfa.4c8be4",
"type": "inject",
"z": "bcf0cb4f.bf9c88",
"name": "Manually Reboot Now",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 160,
"y": 590,
"wires": [
[
"85749dd4.a378a"
]
]
},
{
"id": "7b3024a0.cff3ac",
"type": "function",
"z": "bcf0cb4f.bf9c88",
"name": "Initialize",
"func": "if (typeof flow.get(\"criticals\") == 'undefined') {\n flow.set(\"criticals\", 0);\n}\nif (typeof flow.get(\"warnings\") == 'undefined') {\n flow.set(\"warnings\", 0);\n}\nif (typeof flow.get(\"clears\") == 'undefined') {\n flow.set(\"clears\", 0);\n}\nflow.set(\"lastRun\", new Date());\n//flow.set(\"criticalsForReboot\", 2);\n//flow.set(\"criticalsForRebootDuringMaintenance\", 3);\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 120,
"y": 120,
"wires": [
[
"e3439b3b.228bf8"
]
]
},
{
"id": "1450f867.ad7878",
"type": "function",
"z": "bcf0cb4f.bf9c88",
"name": "Warn",
"func": "flow.set(\"warnings\", flow.get(\"warnings\") + 1);\nmsg.severity = \"warn\";\nmsg.payload = \"Response time above warning threshold for Hub: \" + flow.get(\"hubName\");\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 520,
"y": 330,
"wires": [
[
"ae8a4e1b.db5a1",
"9963153b.9c0888"
]
]
},
{
"id": "85749dd4.a378a",
"type": "change",
"z": "bcf0cb4f.bf9c88",
"name": "Log Manual Reboot",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "MANUALLY REBOOTING HUB",
"tot": "str"
},
{
"t": "set",
"p": "rebootType",
"pt": "msg",
"to": "manual",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 740,
"y": 590,
"wires": [
[
"d3c1b42b.60a0d8"
]
]
},
{
"id": "f7f66ccd.ac8d2",
"type": "inject",
"z": "bcf0cb4f.bf9c88",
"name": "OK",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 110,
"y": 440,
"wires": [
[
"4c3ddce3.032e24"
]
]
},
{
"id": "9b886bd2.79bef8",
"type": "inject",
"z": "bcf0cb4f.bf9c88",
"name": "Warn",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 110,
"y": 470,
"wires": [
[
"1c0159ee.41de56"
]
]
},
{
"id": "a6921f96.31cb",
"type": "inject",
"z": "bcf0cb4f.bf9c88",
"name": "Critical",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 110,
"y": 500,
"wires": [
[
"62c01a66.96aec4"
]
]
},
{
"id": "4c3ddce3.032e24",
"type": "change",
"z": "bcf0cb4f.bf9c88",
"name": "",
"rules": [
{
"t": "set",
"p": "responseTime",
"pt": "msg",
"to": "$flowContext('thresholdWarning') / 2",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 185,
"y": 440,
"wires": [
[
"5b69dac3.159b74"
]
],
"l": false
},
{
"id": "1c0159ee.41de56",
"type": "change",
"z": "bcf0cb4f.bf9c88",
"name": "",
"rules": [
{
"t": "set",
"p": "responseTime",
"pt": "msg",
"to": "($flowContext('thresholdWarning') + $flowContext('thresholdCritical')) / 2",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 185,
"y": 470,
"wires": [
[
"5b69dac3.159b74"
]
],
"l": false
},
{
"id": "62c01a66.96aec4",
"type": "change",
"z": "bcf0cb4f.bf9c88",
"name": "",
"rules": [
{
"t": "set",
"p": "responseTime",
"pt": "msg",
"to": "$flowContext('thresholdCritical')",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 185,
"y": 500,
"wires": [
[
"5b69dac3.159b74"
]
],
"l": false
},
{
"id": "e3439b3b.228bf8",
"type": "subflow:588f2940.1ba848",
"z": "bcf0cb4f.bf9c88",
"name": "Check Page",
"env": [],
"x": 130,
"y": 160,
"wires": [
[
"444e4b8c.56c604"
]
]
},
{
"id": "444e4b8c.56c604",
"type": "subflow:9d92739f.d0d64",
"z": "bcf0cb4f.bf9c88",
"name": "Check Time",
"env": [],
"x": 180,
"y": 200,
"wires": [
[
"77158b2c.a26b74",
"cbd375bf.440268"
]
]
},
{
"id": "96756e63.5b651",
"type": "comment",
"z": "bcf0cb4f.bf9c88",
"name": "Test Injects",
"info": "",
"x": 100,
"y": 410,
"wires": []
},
{
"id": "c2767220.d8077",
"type": "function",
"z": "bcf0cb4f.bf9c88",
"name": "Info",
"func": "flow.set(\"warnings\", 0);\nflow.set(\"criticals\", 0);\nmsg.severity = \"info\";\nmsg.payload = \"All Clear\";\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 520,
"y": 290,
"wires": [
[
"9963153b.9c0888"
]
]
},
{
"id": "f8273758.4fdb18",
"type": "inject",
"z": "bcf0cb4f.bf9c88",
"name": "Simulate Hub Reboot",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 450,
"y": 650,
"wires": [
[
"b79e4927.c0d618"
]
]
},
{
"id": "5b69dac3.159b74",
"type": "change",
"z": "bcf0cb4f.bf9c88",
"name": "Init",
"rules": [
{
"t": "set",
"p": "test",
"pt": "msg",
"to": "true",
"tot": "bool"
},
{
"t": "set",
"p": "reboot",
"pt": "msg",
"to": "false",
"tot": "bool"
},
{
"t": "set",
"p": "inMaintenance",
"pt": "msg",
"to": "false",
"tot": "bool"
},
{
"t": "set",
"p": "awake",
"pt": "msg",
"to": "true",
"tot": "bool"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 235,
"y": 470,
"wires": [
[
"77158b2c.a26b74"
]
],
"l": false
},
{
"id": "ae8a4e1b.db5a1",
"type": "switch",
"z": "bcf0cb4f.bf9c88",
"name": "Awake?",
"property": "awake",
"propertyType": "msg",
"rules": [
{
"t": "true"
},
{
"t": "false"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 710,
"y": 330,
"wires": [
[
"1eeed210.271b0e"
],
[
"5d44de04.5f9c9"
]
]
},
{
"id": "5a1284a1.31ca5c",
"type": "delay",
"z": "bcf0cb4f.bf9c88",
"name": "YES: 1x/Hour",
"pauseType": "rate",
"timeout": "5",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "hour",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": true,
"x": 920,
"y": 410,
"wires": [
[
"71c5af71.65087"
]
]
},
{
"id": "7e30e5ba.d5eaec",
"type": "delay",
"z": "bcf0cb4f.bf9c88",
"name": "NO: Only Once",
"pauseType": "rate",
"timeout": "5",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "9",
"rateUnits": "hour",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": true,
"x": 920,
"y": 450,
"wires": [
[
"71c5af71.65087"
]
]
},
{
"id": "b79e4927.c0d618",
"type": "change",
"z": "bcf0cb4f.bf9c88",
"name": "Log Reboot Sim.",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "CRITICAL! Simulating Hub Rebooting!",
"tot": "str"
},
{
"t": "set",
"p": "test",
"pt": "msg",
"to": "true",
"tot": "bool"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 740,
"y": 650,
"wires": [
[
"d3c1b42b.60a0d8"
]
]
},
{
"id": "71c5af71.65087",
"type": "no-op",
"z": "bcf0cb4f.bf9c88",
"name": "",
"x": 1095,
"y": 380,
"wires": [
[
"427452fd.258c9c",
"b4c8039e.a10db"
]
],
"l": false
},
{
"id": "d3c1b42b.60a0d8",
"type": "no-op",
"z": "bcf0cb4f.bf9c88",
"name": "",
"x": 895,
"y": 590,
"wires": [
[
"458d18ef.3648f8",
"5bc228f.1e003d8",
"b4c8039e.a10db"
]
],
"l": false
},
{
"id": "5dfa3200.9efcf",
"type": "comment",
"z": "bcf0cb4f.bf9c88",
"name": "Read for config info. ",
"info": "1) Edit items in flow configuration item\n - if hub version is >= 2.2.3, set supportsMemCheck =1 \n - set hubName to be whatever you call your hub (main, LAN, etc)\n - deviceId will be whatever device you have (1 would be 1, if you have 2, make 1 be 1, and another be 2). I only need this because I have 2 devices and need to keep the flows and responses separate. \n \n2) Edit the \"reboot hub\" node with the right IP\n\n3) Configure all other config nodes - influx db, pushover",
"x": 610,
"y": 40,
"wires": []
},
{
"id": "5bf079ac.3b8668",
"type": "delay",
"z": "bcf0cb4f.bf9c88",
"name": "1/hr",
"pauseType": "rate",
"timeout": "5",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "hour",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": true,
"x": 1170,
"y": 590,
"wires": [
[
"5b3988b4.e22928",
"baa81579.8a1458",
"720c511.2a4fdb"
]
]
},
{
"id": "baa81579.8a1458",
"type": "function",
"z": "bcf0cb4f.bf9c88",
"d": true,
"name": "INSERT",
"func": "var query = \"INSERT INTO reboottimes(displayName, `type`) VALUES(\";\nquery += \"'Hub Reboot',\";\nquery += \"'\" + msg.rebootType + \"'\";\nquery += \")\";\n\nmsg.topic = query;\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 1320,
"y": 630,
"wires": [
[]
]
},
{
"id": "35902faa.5ad7c",
"type": "switch",
"z": "bcf0cb4f.bf9c88",
"name": "Awake?",
"property": "awake",
"propertyType": "msg",
"rules": [
{
"t": "true"
},
{
"t": "false"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 710,
"y": 430,
"wires": [
[
"5a1284a1.31ca5c"
],
[
"7e30e5ba.d5eaec"
]
]
},
{
"id": "720c511.2a4fdb",
"type": "pushover api",
"z": "bcf0cb4f.bf9c88",
"keys": "b3ffec8b.aa42d",
"title": "Hubitat Watchdog",
"name": "Alert",
"x": 1310,
"y": 550,
"wires": []
},
{
"id": "458d18ef.3648f8",
"type": "function",
"z": "bcf0cb4f.bf9c88",
"name": "Not Testing?",
"func": "if (msg.test) {\n return null;\n}\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 1020,
"y": 590,
"wires": [
[
"5bf079ac.3b8668"
]
]
},
{
"id": "5bc228f.1e003d8",
"type": "function",
"z": "bcf0cb4f.bf9c88",
"name": "Testing?",
"func": "if (msg.test) {\n return msg;\n}\n\nreturn null;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 1010,
"y": 550,
"wires": [
[
"720c511.2a4fdb"
]
]
},
{
"id": "ff8a757f.775388",
"type": "function",
"z": "bcf0cb4f.bf9c88",
"name": "Set Influx Data",
"func": "var v = {\n 'value' : Number(msg.value),\n 'isBinary' : false\n};\n\nmsg.payload = [\n {\n measurement: msg.name,\n fields: {\n value: v.value,\n },\n tags:{\n hub: flow.get(\"hubName\"),\n deviceId: flow.get(\"deviceId\"),\n displayName: msg.displayName,\n unit: msg.unit\n },\n timestamp: new Date()\n }\n]\n\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 700,
"y": 200,
"wires": [
[
"ebdee023.e5b7"
]
]
},
{
"id": "ebdee023.e5b7",
"type": "influxdb batch",
"z": "bcf0cb4f.bf9c88",
"influxdb": "874550d1.5e385",
"precision": "",
"retentionPolicy": "",
"name": "",
"x": 890,
"y": 200,
"wires": []
},
{
"id": "cbd375bf.440268",
"type": "change",
"z": "bcf0cb4f.bf9c88",
"name": "Format",
"rules": [
{
"t": "set",
"p": "name",
"pt": "msg",
"to": "responseTime",
"tot": "str"
},
{
"t": "set",
"p": "value",
"pt": "msg",
"to": "responseTime",
"tot": "msg"
},
{
"t": "set",
"p": "deviceId",
"pt": "msg",
"to": "1",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 540,
"y": 200,
"wires": [
[
"ff8a757f.775388"
]
]
},
{
"id": "b031a120.c8177",
"type": "config",
"z": "bcf0cb4f.bf9c88",
"name": "Initial State - Do Not Edit",
"properties": [
{
"p": "clears",
"pt": "flow",
"to": "0",
"tot": "num"
},
{
"p": "warnings",
"pt": "flow",
"to": "0",
"tot": "num"
},
{
"p": "criticals",
"pt": "flow",
"to": "0",
"tot": "num"
},
{
"p": "lastReboot",
"pt": "flow",
"to": "",
"tot": "date"
}
],
"active": true,
"x": 380,
"y": 40,
"wires": []
},
{
"id": "b4c8039e.a10db",
"type": "debug",
"z": "bcf0cb4f.bf9c88",
"name": "Hubitat Performace (LAN)",
"active": true,
"tosidebar": true,
"console": true,
"tostatus": true,
"complete": "true",
"targetType": "full",
"statusVal": "payload",
"statusType": "auto",
"x": 1200,
"y": 480,
"wires": []
},
{
"id": "9963153b.9c0888",
"type": "debug",
"z": "bcf0cb4f.bf9c88",
"name": "Hubitat Performance (LAN)",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": true,
"complete": "payload",
"targetType": "msg",
"statusVal": "payload",
"statusType": "auto",
"x": 760,
"y": 240,
"wires": []
},
{
"id": "61e6858.64b197c",
"type": "inject",
"z": "bcf0cb4f.bf9c88",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 130,
"y": 320,
"wires": [
[]
]
},
{
"id": "b841304.e58bad",
"type": "influxdb batch",
"z": "bcf0cb4f.bf9c88",
"influxdb": "874550d1.5e385",
"precision": "",
"retentionPolicy": "",
"name": "",
"x": 1350,
"y": 160,
"wires": []
},
{
"id": "3282dd51.6e17a2",
"type": "debug",
"z": "bcf0cb4f.bf9c88",
"name": "Mem Check (LAN)",
"active": true,
"tosidebar": true,
"console": true,
"tostatus": true,
"complete": "payload",
"targetType": "msg",
"statusVal": "payload",
"statusType": "auto",
"x": 1380,
"y": 100,
"wires": []
},
{
"id": "bd4f96a1.e05098",
"type": "switch",
"z": "bcf0cb4f.bf9c88",
"name": "Supports Mem Check? (>2.2.3)",
"property": "supportsMemCheck",
"propertyType": "flow",
"rules": [
{
"t": "gte",
"v": "1",
"vt": "num"
}
],
"checkall": "false",
"repair": false,
"outputs": 1,
"x": 370,
"y": 80,
"wires": [
[
"6c55b325.50118c"
]
]
},
{
"id": "6c55b325.50118c",
"type": "delay",
"z": "bcf0cb4f.bf9c88",
"name": "5s delay ",
"pauseType": "delay",
"timeout": "5",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"x": 400,
"y": 140,
"wires": [
[
"1bfa8f10.fb27f1"
]
]
},
{
"id": "1bfa8f10.fb27f1",
"type": "subflow:43ac6c1.6e31c94",
"z": "bcf0cb4f.bf9c88",
"name": "",
"env": [],
"x": 550,
"y": 140,
"wires": [
[
"be22cd93.5d721"
]
]
},
{
"id": "be22cd93.5d721",
"type": "subflow:9d92739f.d0d64",
"z": "bcf0cb4f.bf9c88",
"name": "Check Time",
"env": [],
"x": 710,
"y": 140,
"wires": [
[
"d50ac2e1.d09a8",
"5d1b3f66.daed1"
]
]
},
{
"id": "d50ac2e1.d09a8",
"type": "change",
"z": "bcf0cb4f.bf9c88",
"name": "Format",
"rules": [
{
"t": "set",
"p": "name",
"pt": "msg",
"to": "freeMem",
"tot": "str"
},
{
"t": "set",
"p": "value",
"pt": "msg",
"to": "freeMemValue",
"tot": "msg"
},
{
"t": "set",
"p": "deviceId",
"pt": "msg",
"to": "1",
"tot": "str"
},
{
"t": "set",
"p": "displayName",
"pt": "msg",
"to": "Free Memory",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 880,
"y": 140,
"wires": [
[
"3b0d8ea1.105b52"
]
]
},
{
"id": "3b0d8ea1.105b52",
"type": "function",
"z": "bcf0cb4f.bf9c88",
"name": "Set Influx Data",
"func": "var v = {\n 'value' : Number(msg.value),\n 'isBinary' : false\n};\n\nmsg.payload = [\n {\n measurement: msg.name,\n fields: {\n value: v.value,\n },\n tags:{\n hub: flow.get(\"hubName\"),\n deviceId: flow.get(\"deviceId\"),\n displayName: msg.displayName,\n unit: msg.unit\n },\n timestamp: new Date()\n }\n]\n\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 1060,
"y": 140,
"wires": [
[
"3282dd51.6e17a2",
"b841304.e58bad"
]
]
},
{
"id": "5d1b3f66.daed1",
"type": "switch",
"z": "bcf0cb4f.bf9c88",
"name": "Memory Critical?",
"property": "freeMemValue",
"propertyType": "msg",
"rules": [
{
"t": "lt",
"v": "memCritical",
"vt": "flow"
}
],
"checkall": "false",
"repair": false,
"outputs": 1,
"x": 410,
"y": 420,
"wires": [
[
"9f4663f3.027bf"
]
]
},
{
"id": "9f4663f3.027bf",
"type": "function",
"z": "bcf0cb4f.bf9c88",
"name": "Crit",
"func": "flow.set(\"criticals\", flow.get(\"criticals\") + 1);\nmsg.severity = \"crit\";\nmsg.payload = \"Memory below CRITICAL threshold for Hub: \" + flow.get(\"hubName\") + \" (\" + msg.freeMemValue + \" < \" + flow.get(\"memCritical\") + \")\";\n\nif (msg.inMaintenance) {\n msg.critsNeeded = flow.get(\"criticalsForRebootDuringMaintenance\");\n} else {\n msg.critsNeeded = flow.get(\"criticalsForReboot\");\n}\n\nif (flow.get(\"criticals\") >= msg.critsNeeded) {\n msg.reboot = true;\n flow.set(\"lastReboot\", Date.now());\n return msg;\n} else {\n return null;\n}",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 470,
"y": 480,
"wires": [
[
"35902faa.5ad7c",
"36d88dbb.bcd6c2"
]
]
},
{
"id": "b3ffec8b.aa42d",
"type": "pushover-keys",
"z": "",
"name": "B's Pushover"
},
{
"id": "874550d1.5e385",
"type": "influxdb",
"z": "",
"hostname": "192.168.1.2",
"port": "8086",
"protocol": "http",
"database": "hubitat",
"name": "InfluxDB - hubitat",
"usetls": false,
"tls": ""
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment