Skip to content

Instantly share code, notes, and snippets.

@savetheclocktower
Created April 15, 2018 23:56
Show Gist options
  • Save savetheclocktower/686d23a46764b92a4d98088a7980d647 to your computer and use it in GitHub Desktop.
Save savetheclocktower/686d23a46764b92a4d98088a7980d647 to your computer and use it in GitHub Desktop.
[
{
"id": "23b3cd96.cb1572",
"type": "mqtt in",
"z": "2e895c69.cf1ab4",
"name": "",
"topic": "laundry/washer/state",
"qos": "2",
"broker": "959b6b25.93e438",
"x": 158,
"y": 98,
"wires": [
[
"36b89068.4c883"
]
]
},
{
"id": "4cf636c9.b2a6a",
"type": "mqtt in",
"z": "2e895c69.cf1ab4",
"name": "",
"topic": "laundry/dryer/state",
"qos": "2",
"broker": "959b6b25.93e438",
"x": 168,
"y": 160,
"wires": [
[
"36b89068.4c883"
]
]
},
{
"id": "33ebc164.b809b6",
"type": "function",
"z": "2e895c69.cf1ab4",
"name": "Format message",
"func": "\nlet appliance;\nif (msg.topic.indexOf('washer') > -1) {\n appliance = \"Washer\";\n} else if (msg.topic.indexOf('dryer') > -1) {\n appliance = \"Dryer\";\n}\n\nreturn {\n topic: 'Laundry',\n payload: appliance + ' cycle is done'\n};",
"outputs": 1,
"noerr": 0,
"x": 536,
"y": 129,
"wires": [
[
"810b5a5c.aecec"
]
]
},
{
"id": "36b89068.4c883",
"type": "switch",
"z": "2e895c69.cf1ab4",
"name": "done?",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "4",
"vt": "str"
}
],
"checkall": "true",
"outputs": 1,
"x": 369,
"y": 129,
"wires": [
[
"33ebc164.b809b6"
]
]
},
{
"id": "810b5a5c.aecec",
"type": "pushover",
"z": "2e895c69.cf1ab4",
"name": "notify me",
"device": "",
"title": "",
"priority": 0,
"sound": "",
"url": "",
"url_title": "",
"x": 708,
"y": 129,
"wires": []
},
{
"id": "959b6b25.93e438",
"type": "mqtt-broker",
"z": "",
"broker": "localhost",
"port": "1883",
"clientid": "",
"usetls": false,
"compatmode": true,
"keepalive": "60",
"cleansession": true,
"willTopic": "",
"willQos": "0",
"willPayload": "",
"birthTopic": "",
"birthQos": "0",
"birthPayload": ""
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment