Last active
June 16, 2019 03:48
-
-
Save sktaylortrash/703dbe93f1440618dd05ca27852c6e0e to your computer and use it in GitHub Desktop.
MQTT Subscription for MQTTDeconzBridge to read button presses from Ikea Tradfri remote
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"id": "15ba8429.2d756c", | |
"type": "mqtt in", | |
"z": "c0fc70c0.91035", | |
"name": "Tradfri Switch", | |
"topic": "/Deconz/switch/2", | |
"qos": "0", | |
"broker": "79ae0f24.e78a8", | |
"x": 150, | |
"y": 1260, | |
"wires": [ | |
[ | |
"69b1bfbc.01fd2" | |
] | |
] | |
}, | |
{ | |
"id": "69b1bfbc.01fd2", | |
"type": "switch", | |
"z": "c0fc70c0.91035", | |
"name": "On/Off or Dim", | |
"property": "payload", | |
"propertyType": "msg", | |
"rules": [ | |
{ | |
"t": "eq", | |
"v": "1002", | |
"vt": "str" | |
}, | |
{ | |
"t": "eq", | |
"v": "2002", | |
"vt": "str" | |
}, | |
{ | |
"t": "eq", | |
"v": "3002", | |
"vt": "str" | |
}, | |
{ | |
"t": "eq", | |
"v": "2001", | |
"vt": "str" | |
}, | |
{ | |
"t": "eq", | |
"v": "3001", | |
"vt": "str" | |
} | |
], | |
"checkall": "false", | |
"repair": false, | |
"outputs": 5, | |
"x": 340, | |
"y": 1260, | |
"wires": [ | |
[ | |
"150c7a8f.d37555" | |
], | |
[ | |
"20923fbe.8f31" | |
], | |
[ | |
"4d07b11c.bc05d" | |
], | |
[ | |
"d2712250.145a7" | |
], | |
[ | |
"ced647ef.b03ac8" | |
] | |
], | |
"outputLabels": [ | |
"On/Off", | |
"Brighter-ShortPress", | |
"Dimmer-ShortPress", | |
"Max-LongPress", | |
"Min-LongPress" | |
] | |
}, | |
{ | |
"id": "9923e9b2.c8ef58", | |
"type": "function", | |
"z": "c0fc70c0.91035", | |
"name": "Set Bright", | |
"func": "if (msg.payload.state.bri < 254) \n{\n msg.payload = msg.payload.state.bri + 30\n} \n\nif (msg.payload > 254)\n{\n msg.payload = 254;\n}\n\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 760, | |
"y": 1280, | |
"wires": [ | |
[ | |
"200c64ea.828f1c" | |
] | |
] | |
}, | |
{ | |
"id": "fa85bcfa.587aa", | |
"type": "http request", | |
"z": "c0fc70c0.91035", | |
"name": "", | |
"method": "PUT", | |
"ret": "obj", | |
"url": "http://deconz.local/api/<APIKEY>/lights/[ID#]/state", | |
"tls": "", | |
"x": 1330, | |
"y": 1260, | |
"wires": [ | |
[] | |
] | |
}, | |
{ | |
"id": "65ab6328.16b74c", | |
"type": "change", | |
"z": "c0fc70c0.91035", | |
"name": "On", | |
"rules": [ | |
{ | |
"t": "set", | |
"p": "payload", | |
"pt": "msg", | |
"to": "{\"on\":true}", | |
"tot": "json" | |
} | |
], | |
"action": "", | |
"property": "", | |
"from": "", | |
"to": "", | |
"reg": false, | |
"x": 950, | |
"y": 1220, | |
"wires": [ | |
[ | |
"fa85bcfa.587aa" | |
] | |
] | |
}, | |
{ | |
"id": "8629b20a.a8909", | |
"type": "change", | |
"z": "c0fc70c0.91035", | |
"name": "Off", | |
"rules": [ | |
{ | |
"t": "set", | |
"p": "payload", | |
"pt": "msg", | |
"to": "{\"on\":false}", | |
"tot": "json" | |
} | |
], | |
"action": "", | |
"property": "", | |
"from": "", | |
"to": "", | |
"reg": false, | |
"x": 950, | |
"y": 1260, | |
"wires": [ | |
[ | |
"fa85bcfa.587aa" | |
] | |
] | |
}, | |
{ | |
"id": "200c64ea.828f1c", | |
"type": "change", | |
"z": "c0fc70c0.91035", | |
"name": "Bright", | |
"rules": [ | |
{ | |
"t": "set", | |
"p": "payload", | |
"pt": "msg", | |
"to": "{\t \"bri\": msg.payload,\t \"transitiontime\": 1\t\t}", | |
"tot": "jsonata" | |
} | |
], | |
"action": "", | |
"property": "", | |
"from": "", | |
"to": "", | |
"reg": false, | |
"x": 1110, | |
"y": 1300, | |
"wires": [ | |
[ | |
"fa85bcfa.587aa" | |
] | |
] | |
}, | |
{ | |
"id": "150c7a8f.d37555", | |
"type": "http request", | |
"z": "c0fc70c0.91035", | |
"name": "Get State Light 1", | |
"method": "GET", | |
"ret": "obj", | |
"url": "http://deconz.local/api/<APIKEY>/lights/[ID#]", | |
"tls": "", | |
"x": 570, | |
"y": 1240, | |
"wires": [ | |
[ | |
"dc1204f5.169fd8" | |
] | |
] | |
}, | |
{ | |
"id": "dc1204f5.169fd8", | |
"type": "switch", | |
"z": "c0fc70c0.91035", | |
"name": "on/off", | |
"property": "payload.state.on", | |
"propertyType": "msg", | |
"rules": [ | |
{ | |
"t": "false" | |
}, | |
{ | |
"t": "true" | |
} | |
], | |
"checkall": "true", | |
"repair": false, | |
"outputs": 2, | |
"x": 750, | |
"y": 1240, | |
"wires": [ | |
[ | |
"65ab6328.16b74c" | |
], | |
[ | |
"8629b20a.a8909" | |
] | |
] | |
}, | |
{ | |
"id": "20923fbe.8f31", | |
"type": "http request", | |
"z": "c0fc70c0.91035", | |
"name": "Get State Light 1", | |
"method": "GET", | |
"ret": "obj", | |
"url": "http://deconz.local/api/<APIKEY>/lights/[ID#]", | |
"tls": "", | |
"x": 570, | |
"y": 1280, | |
"wires": [ | |
[ | |
"9923e9b2.c8ef58" | |
] | |
] | |
}, | |
{ | |
"id": "4d07b11c.bc05d", | |
"type": "http request", | |
"z": "c0fc70c0.91035", | |
"name": "Get State Light 1", | |
"method": "GET", | |
"ret": "obj", | |
"url": "http://deconz.local/api/<APIKEY>/lights/[ID#]", | |
"tls": "", | |
"x": 570, | |
"y": 1320, | |
"wires": [ | |
[ | |
"f4957475.c4c668" | |
] | |
] | |
}, | |
{ | |
"id": "f4957475.c4c668", | |
"type": "function", | |
"z": "c0fc70c0.91035", | |
"name": "Set Dim", | |
"func": "if (msg.payload.state.bri != 1) \n{\n msg.payload = msg.payload.state.bri - 30\n} \n\nif (msg.payload <= 20)\n{\n msg.payload = 20;\n}\n\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 760, | |
"y": 1320, | |
"wires": [ | |
[ | |
"200c64ea.828f1c" | |
] | |
] | |
}, | |
{ | |
"id": "d2712250.145a7", | |
"type": "http request", | |
"z": "c0fc70c0.91035", | |
"name": "Get State Light 1", | |
"method": "GET", | |
"ret": "obj", | |
"url": "http://deconz.local/api/<APIKEY>/lights/[ID#]", | |
"tls": "", | |
"x": 570, | |
"y": 1360, | |
"wires": [ | |
[ | |
"a4bda86.f992058" | |
] | |
] | |
}, | |
{ | |
"id": "ced647ef.b03ac8", | |
"type": "http request", | |
"z": "c0fc70c0.91035", | |
"name": "Get State Light 1", | |
"method": "GET", | |
"ret": "obj", | |
"url": "http://deconz.local/api/<APIKEY>/lights/[ID#]", | |
"tls": "", | |
"x": 570, | |
"y": 1400, | |
"wires": [ | |
[ | |
"811aab89.a03de8" | |
] | |
] | |
}, | |
{ | |
"id": "a4bda86.f992058", | |
"type": "function", | |
"z": "c0fc70c0.91035", | |
"name": "Set Max Bright", | |
"func": "msg.payload = 254;\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 780, | |
"y": 1360, | |
"wires": [ | |
[ | |
"200c64ea.828f1c" | |
] | |
] | |
}, | |
{ | |
"id": "811aab89.a03de8", | |
"type": "function", | |
"z": "c0fc70c0.91035", | |
"name": "Set Min Dim", | |
"func": "msg.payload = 20;\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 770, | |
"y": 1400, | |
"wires": [ | |
[ | |
"200c64ea.828f1c" | |
] | |
] | |
}, | |
{ | |
"id": "79ae0f24.e78a8", | |
"type": "mqtt-broker", | |
"z": "", | |
"name": "", | |
"broker": "localhost", | |
"port": "1883", | |
"clientid": "", | |
"usetls": false, | |
"compatmode": true, | |
"keepalive": "15", | |
"cleansession": true, | |
"birthTopic": "", | |
"birthQos": "0", | |
"birthPayload": "", | |
"closeTopic": "", | |
"closePayload": "", | |
"willTopic": "", | |
"willQos": "0", | |
"willPayload": "" | |
} | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment