Skip to content

Instantly share code, notes, and snippets.

@abhishekjain14
Created October 18, 2019 17:41
Show Gist options
  • Save abhishekjain14/d5950147bee80f8c244d8d53cd5efa2b to your computer and use it in GitHub Desktop.
Save abhishekjain14/d5950147bee80f8c244d8d53cd5efa2b to your computer and use it in GitHub Desktop.
Node-RED Washer/dryer notifications using Home Assistant
[
{
"id": "5bbc5ca3.4c4764",
"type": "tab",
"label": "Laundry",
"disabled": false,
"info": "Automate washer/dryer notifications and store stats in Influx"
},
{
"id": "645cc0df.e38ee8",
"type": "change",
"z": "5bbc5ca3.4c4764",
"name": "Reset",
"rules": [
{
"t": "set",
"p": "reset",
"pt": "msg",
"to": "reset",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 950,
"y": 120,
"wires": [
[
"ef6e3383.dc9668"
]
]
},
{
"id": "34251f01.6019d8",
"type": "change",
"z": "5bbc5ca3.4c4764",
"name": "Washer Reset Counter",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "00:00:00",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 640,
"y": 460,
"wires": [
[
"10913162.b17d8f",
"a24a45e8.20f678"
]
]
},
{
"id": "a22c4304.f7c528",
"type": "looptimer",
"z": "5bbc5ca3.4c4764",
"duration": "1",
"units": "Second",
"maxloops": "10800",
"maxtimeout": "2",
"maxtimeoutunits": "Hour",
"name": "Washing machine counter",
"x": 890,
"y": 80,
"wires": [
[
"ef6e3383.dc9668"
],
[]
]
},
{
"id": "ef6e3383.dc9668",
"type": "counter",
"z": "5bbc5ca3.4c4764",
"name": "Washing machine timer",
"init": "0",
"step": "1",
"lower": null,
"upper": null,
"mode": "increment",
"outputs": "1",
"x": 1150,
"y": 80,
"wires": [
[
"a19fcf5c.0ed11"
]
]
},
{
"id": "c619c9df.f188d",
"type": "change",
"z": "5bbc5ca3.4c4764",
"name": "Stop washer counter",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "stop",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 500,
"y": 80,
"wires": [
[
"a22c4304.f7c528"
]
]
},
{
"id": "10913162.b17d8f",
"type": "mqtt out",
"z": "5bbc5ca3.4c4764",
"name": "washer/runtime",
"topic": "washer/runtime",
"qos": "1",
"retain": "true",
"broker": "a858c843.371898",
"x": 1860,
"y": 360,
"wires": []
},
{
"id": "1a2d124c.071bee",
"type": "inject",
"z": "5bbc5ca3.4c4764",
"name": "",
"topic": "",
"payload": "00:00:00",
"payloadType": "str",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 1660,
"y": 460,
"wires": [
[
"10913162.b17d8f"
]
]
},
{
"id": "a24a45e8.20f678",
"type": "debug",
"z": "5bbc5ca3.4c4764",
"name": "Washer debug",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"x": 860,
"y": 400,
"wires": []
},
{
"id": "a19fcf5c.0ed11",
"type": "function",
"z": "5bbc5ca3.4c4764",
"name": "Washer transformation from seconds to hh:mm:ss",
"func": "var sec_num=msg.count;\nvar hours=Math.floor(sec_num/3600)\nvar minutes=Math.floor((sec_num-(hours*3600))/60)\nvar seconds=Math.floor((sec_num-(hours*3600)-(minutes*60)))\n if (hours < 10) {hours = \"0\"+hours;}\n if (minutes < 10) {minutes = \"0\"+minutes;}\n if (seconds < 10) {seconds = \"0\"+seconds;}\nvar msg = {payload:hours+':'+minutes+':'+seconds};\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 1530,
"y": 140,
"wires": [
[
"10913162.b17d8f"
]
]
},
{
"id": "b5f81840.9081b",
"type": "trigger-state",
"z": "5bbc5ca3.4c4764",
"name": "Washer power usage",
"server": "91a71a1e.b30f98",
"entityid": "sensor.washer_usage",
"entityidfiltertype": "exact",
"debugenabled": false,
"constraints": [],
"constraintsmustmatch": "all",
"outputs": 2,
"customoutputs": [],
"outputinitially": true,
"state_type": "str",
"x": 160,
"y": 60,
"wires": [
[
"b1f17340.ef452"
],
[]
]
},
{
"id": "56214c06.7432e4",
"type": "power-monitor",
"z": "5bbc5ca3.4c4764",
"name": "Washer power monitor",
"threshold": "2",
"startafter": "4",
"stopafter": "30",
"x": 360,
"y": 160,
"wires": [
[
"252a0071.de5b38",
"8406d511.227aa8",
"a22c4304.f7c528",
"c60bb08e.574b9"
],
[
"252a0071.de5b38",
"c619c9df.f188d",
"34251f01.6019d8",
"645cc0df.e38ee8",
"2e5f1c6.5dc62e4",
"43d6d02c.828c3",
"2e8384a1.024b7c"
]
]
},
{
"id": "252a0071.de5b38",
"type": "debug",
"z": "5bbc5ca3.4c4764",
"name": "Washer power monitor",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"x": 880,
"y": 280,
"wires": []
},
{
"id": "8406d511.227aa8",
"type": "pushbullet",
"z": "5bbc5ca3.4c4764",
"config": "c56541a0.6cbe8",
"pushtype": "note",
"title": "Washer started test",
"chan": "",
"name": "Washer started test",
"x": 870,
"y": 40,
"wires": []
},
{
"id": "2e5f1c6.5dc62e4",
"type": "change",
"z": "5bbc5ca3.4c4764",
"name": "Washer stats transformation - time and time taken",
"rules": [
{
"t": "set",
"p": "payload.timetaken",
"pt": "msg",
"to": "payload.time",
"tot": "msg"
},
{
"t": "set",
"p": "payload.time",
"pt": "msg",
"to": "",
"tot": "date"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 890,
"y": 240,
"wires": [
[
"5936594f.832e08"
]
]
},
{
"id": "5936594f.832e08",
"type": "influxdb out",
"z": "5bbc5ca3.4c4764",
"influxdb": "b17e5018.f0afa",
"name": "Washer usage stats upon stop",
"measurement": "washermetrics",
"precision": "ms",
"retentionPolicy": "",
"x": 1350,
"y": 240,
"wires": []
},
{
"id": "ba5f60b8.7611d8",
"type": "change",
"z": "5bbc5ca3.4c4764",
"name": "Reset",
"rules": [
{
"t": "set",
"p": "reset",
"pt": "msg",
"to": "reset",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 710,
"y": 940,
"wires": [
[
"c95fab2c.30259"
]
]
},
{
"id": "5e06e5a0.f835a4",
"type": "pushbullet",
"z": "5bbc5ca3.4c4764",
"config": "c56541a0.6cbe8",
"pushtype": "note",
"title": "Dryer started from node-red",
"chan": "",
"name": "Dryer started",
"x": 590,
"y": 680,
"wires": []
},
{
"id": "f9510943.a827b",
"type": "looptimer",
"z": "5bbc5ca3.4c4764",
"duration": "1",
"units": "Second",
"maxloops": "10800",
"maxtimeout": "2",
"maxtimeoutunits": "Hour",
"name": "Dryer counter",
"x": 720,
"y": 840,
"wires": [
[
"c95fab2c.30259"
],
[]
]
},
{
"id": "c95fab2c.30259",
"type": "counter",
"z": "5bbc5ca3.4c4764",
"name": "Dryer timer",
"init": "0",
"step": "1",
"lower": null,
"upper": null,
"mode": "increment",
"outputs": "1",
"x": 870,
"y": 900,
"wires": [
[
"d455930a.db8ce8"
]
]
},
{
"id": "b0338764.2b5e1",
"type": "change",
"z": "5bbc5ca3.4c4764",
"name": "Stop dryer counter",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "stop",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 690,
"y": 780,
"wires": [
[
"f9510943.a827b"
]
]
},
{
"id": "6f5973a1.6f0e7c",
"type": "mqtt out",
"z": "5bbc5ca3.4c4764",
"name": "dryer/runtime",
"topic": "dryer/runtime",
"qos": "",
"retain": "true",
"broker": "a858c843.371898",
"x": 1440,
"y": 740,
"wires": []
},
{
"id": "6e8badc6.f2b82c",
"type": "inject",
"z": "5bbc5ca3.4c4764",
"name": "",
"topic": "",
"payload": "00:00:00",
"payloadType": "str",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 1080,
"y": 960,
"wires": [
[
"6f5973a1.6f0e7c"
]
]
},
{
"id": "7a7e1dc2.cb5684",
"type": "change",
"z": "5bbc5ca3.4c4764",
"name": "Reset Counter",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "00:00:00",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1120,
"y": 740,
"wires": [
[
"6f5973a1.6f0e7c"
]
]
},
{
"id": "d455930a.db8ce8",
"type": "function",
"z": "5bbc5ca3.4c4764",
"name": "Dryer transformation",
"func": "var sec_num=msg.count;\nvar hours=Math.floor(sec_num/3600)\nvar minutes=Math.floor((sec_num-(hours*3600))/60)\nvar seconds=Math.floor((sec_num-(hours*3600)-(minutes*60)))\n if (hours < 10) {hours = \"0\"+hours;}\n if (minutes < 10) {minutes = \"0\"+minutes;}\n if (seconds < 10) {seconds = \"0\"+seconds;}\nvar msg = {payload:hours+':'+minutes+':'+seconds};\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 1080,
"y": 900,
"wires": [
[
"6f5973a1.6f0e7c"
]
]
},
{
"id": "ae50e73b.bca6b",
"type": "api-call-service",
"z": "5bbc5ca3.4c4764",
"name": "Alexa bedroom dryer done",
"server": "91a71a1e.b30f98",
"version": 1,
"service_domain": "notify",
"service": "alexa_media_bedroom_echo",
"entityId": "",
"data": "{\"message\":\"Dryer is done!\",\"data\":{\"type\":\"tts\"}}",
"dataType": "json",
"mergecontext": "",
"output_location": "",
"output_location_type": "none",
"mustacheAltTags": false,
"x": 720,
"y": 1020,
"wires": [
[
"800c5bd6.27d4a8"
]
]
},
{
"id": "3280e791.114268",
"type": "power-monitor",
"z": "5bbc5ca3.4c4764",
"name": "Dryer power monitor",
"threshold": "10",
"startafter": 1,
"stopafter": "10",
"x": 360,
"y": 740,
"wires": [
[
"5e06e5a0.f835a4",
"f9510943.a827b",
"eb3e03e0.9ba1d"
],
[
"b0338764.2b5e1",
"ba5f60b8.7611d8",
"ae50e73b.bca6b",
"7a7e1dc2.cb5684",
"3d528595.524032",
"952d9935.3abb78",
"800c5bd6.27d4a8"
]
]
},
{
"id": "3d528595.524032",
"type": "change",
"z": "5bbc5ca3.4c4764",
"name": "Dryer stats transformation",
"rules": [
{
"t": "set",
"p": "payload.timetaken",
"pt": "msg",
"to": "payload.time",
"tot": "msg"
},
{
"t": "set",
"p": "payload.time",
"pt": "msg",
"to": "",
"tot": "date"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 630,
"y": 720,
"wires": [
[
"1ceccd86.2c1082"
]
]
},
{
"id": "1ceccd86.2c1082",
"type": "influxdb out",
"z": "5bbc5ca3.4c4764",
"influxdb": "b17e5018.f0afa",
"name": "Dryer usage stats upon stop",
"measurement": "dryermetrics",
"precision": "ms",
"retentionPolicy": "",
"x": 900,
"y": 720,
"wires": []
},
{
"id": "62e2bd2.38a7944",
"type": "poll-state",
"z": "5bbc5ca3.4c4764",
"name": "Washer usage poller",
"server": "91a71a1e.b30f98",
"version": 1,
"updateinterval": "10",
"updateIntervalUnits": "seconds",
"outputinitially": true,
"outputonchanged": true,
"entity_id": "sensor.washer_usage",
"state_type": "str",
"halt_if": "",
"halt_if_type": "str",
"halt_if_compare": "is",
"outputs": 1,
"x": 110,
"y": 160,
"wires": [
[
"56214c06.7432e4",
"d17226f1.22f828"
]
]
},
{
"id": "d17226f1.22f828",
"type": "debug",
"z": "5bbc5ca3.4c4764",
"name": "Washer power debug",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"x": 360,
"y": 240,
"wires": []
},
{
"id": "b1f17340.ef452",
"type": "debug",
"z": "5bbc5ca3.4c4764",
"name": "Washer usage debug",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"x": 420,
"y": 40,
"wires": []
},
{
"id": "9359b56b.d21958",
"type": "poll-state",
"z": "5bbc5ca3.4c4764",
"name": "Dryer usage poller",
"server": "91a71a1e.b30f98",
"updateinterval": "10",
"updateIntervalUnits": "seconds",
"outputinitially": true,
"outputonchanged": true,
"entity_id": "sensor.dryer_usage",
"state_type": "str",
"halt_if": "",
"halt_if_type": "str",
"halt_if_compare": "is",
"outputs": 1,
"x": 110,
"y": 900,
"wires": [
[
"3280e791.114268"
]
]
},
{
"id": "c60bb08e.574b9",
"type": "pushover api",
"z": "5bbc5ca3.4c4764",
"keys": "351967f3.b7ba48",
"title": "Washer started",
"name": "Washer started",
"x": 680,
"y": 180,
"wires": []
},
{
"id": "eb3e03e0.9ba1d",
"type": "pushover api",
"z": "5bbc5ca3.4c4764",
"keys": "351967f3.b7ba48",
"title": "Dryer started",
"name": "Dryer started",
"x": 590,
"y": 640,
"wires": []
},
{
"id": "800c5bd6.27d4a8",
"type": "debug",
"z": "5bbc5ca3.4c4764",
"name": "Dryer time debugger",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"x": 1060,
"y": 1140,
"wires": []
},
{
"id": "952d9935.3abb78",
"type": "function",
"z": "5bbc5ca3.4c4764",
"name": "Dryer transformation",
"func": "var sec_num=msg.payload.time;\nvar hours=Math.floor(sec_num/3600)\nvar minutes=Math.floor((sec_num-(hours*3600))/60)\nvar seconds=Math.floor((sec_num-(hours*3600)-(minutes*60)))\n if (hours < 10) {hours = \"0\"+hours;}\n if (minutes < 10) {minutes = \"0\"+minutes;}\n if (seconds < 10) {seconds = \"0\"+seconds;}\nmsg.payload.time = hours+':'+minutes+':'+seconds;\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 760,
"y": 1140,
"wires": [
[
"800c5bd6.27d4a8",
"476a34ae.e674dc",
"dcae42a3.8e4a3"
]
]
},
{
"id": "476a34ae.e674dc",
"type": "pushover api",
"z": "5bbc5ca3.4c4764",
"keys": "351967f3.b7ba48",
"title": "Dryer done HHMMSS!",
"name": "Dryer is done!",
"x": 1000,
"y": 1220,
"wires": []
},
{
"id": "43d6d02c.828c3",
"type": "function",
"z": "5bbc5ca3.4c4764",
"name": "Washer transformation from seconds to hh:mm:ss",
"func": "var sec_num=msg.payload.time;\nvar hours=Math.floor(sec_num/3600)\nvar minutes=Math.floor((sec_num-(hours*3600))/60)\nvar seconds=Math.floor((sec_num-(hours*3600)-(minutes*60)))\n if (hours < 10) {hours = \"0\"+hours;}\n if (minutes < 10) {minutes = \"0\"+minutes;}\n if (seconds < 10) {seconds = \"0\"+seconds;}\nmsg.payload.time = hours+':'+minutes+':'+seconds;\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 770,
"y": 320,
"wires": [
[
"4f067424.0f9d1c",
"f486f5d9.cc5618"
]
]
},
{
"id": "4f067424.0f9d1c",
"type": "pushover api",
"z": "5bbc5ca3.4c4764",
"keys": "351967f3.b7ba48",
"title": "Washer done HHMMSS!",
"name": "Washer done!",
"x": 1160,
"y": 320,
"wires": []
},
{
"id": "f486f5d9.cc5618",
"type": "pushbullet",
"z": "5bbc5ca3.4c4764",
"config": "c56541a0.6cbe8",
"pushtype": "note",
"title": "Washer done!",
"chan": "",
"name": "Washer done HHMMSS",
"x": 1130,
"y": 380,
"wires": []
},
{
"id": "dcae42a3.8e4a3",
"type": "pushbullet",
"z": "5bbc5ca3.4c4764",
"config": "c56541a0.6cbe8",
"pushtype": "note",
"title": "Dryer done!",
"chan": "",
"name": "Dryer done HHMMSS",
"x": 1040,
"y": 1180,
"wires": []
},
{
"id": "2e8384a1.024b7c",
"type": "api-call-service",
"z": "5bbc5ca3.4c4764",
"name": "Alexa bedroom washer done",
"server": "91a71a1e.b30f98",
"version": 1,
"service_domain": "notify",
"service": "alexa_media_bedroom_echo",
"entityId": "",
"data": "{\"message\":\"Washer is done!\",\"data\":{\"type\":\"tts\"}}",
"dataType": "json",
"mergecontext": "",
"output_location": "",
"output_location_type": "none",
"mustacheAltTags": false,
"x": 960,
"y": 500,
"wires": [
[]
]
},
{
"id": "a858c843.371898",
"type": "mqtt-broker",
"z": "",
"name": "Mosquitto",
"broker": "core-mosquitto",
"port": "1883",
"tls": "",
"clientid": "NodeRed",
"usetls": false,
"compatmode": true,
"keepalive": "300",
"cleansession": true,
"birthTopic": "",
"birthQos": "0",
"birthPayload": "",
"closeTopic": "",
"closeQos": "0",
"closePayload": "",
"willTopic": "",
"willQos": "0",
"willPayload": ""
},
{
"id": "91a71a1e.b30f98",
"type": "server",
"z": "",
"name": "Home Assistant"
},
{
"id": "c56541a0.6cbe8",
"type": "pushbullet-config",
"z": "",
"name": "**** pushbullet"
},
{
"id": "b17e5018.f0afa",
"type": "influxdb",
"z": "",
"hostname": "127.0.0.1",
"port": "8086",
"protocol": "http",
"database": "homeassistant",
"name": "Hass.io influxdb",
"usetls": false,
"tls": ""
},
{
"id": "351967f3.b7ba48",
"type": "pushover-keys",
"z": "",
"name": "pushover config"
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment