Last active
March 26, 2020 19:44
-
-
Save blattmann/d4cb6bfb218a2e0ebe144bd8e838a396 to your computer and use it in GitHub Desktop.
Convert MQTT payloads in Node-RED and Home Assistant
This file contains 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": "4207226e.90885c", | |
"type": "tab", | |
"label": "SOS Band", | |
"disabled": false, | |
"info": "" | |
}, | |
{ | |
"id": "dfdca432.7e3a18", | |
"type": "mqtt in", | |
"z": "4207226e.90885c", | |
"name": "RF Bridge MQTT", | |
"topic": "tele/rf1/RESULT", | |
"qos": "0", | |
"datatype": "auto", | |
"broker": "a06529f7.9044f8", | |
"x": 120, | |
"y": 100, | |
"wires": [ | |
[ | |
"c5c39406.5059e8", | |
"5b630883.9d0808" | |
] | |
] | |
}, | |
{ | |
"id": "c5c39406.5059e8", | |
"type": "debug", | |
"z": "4207226e.90885c", | |
"name": "", | |
"active": false, | |
"tosidebar": true, | |
"console": false, | |
"tostatus": false, | |
"complete": "false", | |
"x": 290, | |
"y": 60, | |
"wires": [] | |
}, | |
{ | |
"id": "5b630883.9d0808", | |
"type": "json", | |
"z": "4207226e.90885c", | |
"name": "Convert to Object", | |
"property": "payload", | |
"action": "obj", | |
"pretty": false, | |
"x": 310, | |
"y": 100, | |
"wires": [ | |
[ | |
"1bff790b.a35617", | |
"82209185.f75ff" | |
] | |
] | |
}, | |
{ | |
"id": "1bff790b.a35617", | |
"type": "debug", | |
"z": "4207226e.90885c", | |
"name": "JSON to Object", | |
"active": false, | |
"tosidebar": true, | |
"console": false, | |
"tostatus": false, | |
"complete": "payload", | |
"targetType": "msg", | |
"x": 520, | |
"y": 60, | |
"wires": [] | |
}, | |
{ | |
"id": "82209185.f75ff", | |
"type": "switch", | |
"z": "4207226e.90885c", | |
"name": "Select Sensor and State", | |
"property": "payload.RfReceived.Data", | |
"propertyType": "msg", | |
"rules": [ | |
{ | |
"t": "eq", | |
"v": "111110", | |
"vt": "str" | |
}, | |
{ | |
"t": "eq", | |
"v": "11111C", | |
"vt": "str" | |
}, | |
{ | |
"t": "eq", | |
"v": "11111D", | |
"vt": "str" | |
}, | |
{ | |
"t": "eq", | |
"v": "11111E", | |
"vt": "str" | |
} | |
], | |
"checkall": "false", | |
"repair": false, | |
"outputs": 4, | |
"x": 550, | |
"y": 140, | |
"wires": [ | |
[ | |
"119398cf.c5ea07" | |
], | |
[ | |
"119398cf.c5ea07" | |
], | |
[ | |
"119398cf.c5ea07" | |
], | |
[ | |
"119398cf.c5ea07" | |
] | |
], | |
"inputLabels": [ | |
"RF Bridge 1" | |
], | |
"outputLabels": [ | |
"Code 1", | |
"Code 2", | |
"Code 3", | |
"Code 4" | |
] | |
}, | |
{ | |
"id": "f4d88cda.1978a", | |
"type": "mqtt out", | |
"z": "4207226e.90885c", | |
"name": "MQTT: Send to Home Assistant", | |
"topic": "", | |
"qos": "", | |
"retain": "", | |
"broker": "a06529f7.9044f8", | |
"x": 1210, | |
"y": 140, | |
"wires": [] | |
}, | |
{ | |
"id": "119398cf.c5ea07", | |
"type": "change", | |
"z": "4207226e.90885c", | |
"name": "Collect all and change payload", | |
"rules": [ | |
{ | |
"t": "delete", | |
"p": "payload", | |
"pt": "msg" | |
}, | |
{ | |
"t": "set", | |
"p": "topic", | |
"pt": "msg", | |
"to": "sos/alarm", | |
"tot": "str" | |
}, | |
{ | |
"t": "set", | |
"p": "qos", | |
"pt": "msg", | |
"to": "1", | |
"tot": "str" | |
}, | |
{ | |
"t": "set", | |
"p": "retain", | |
"pt": "msg", | |
"to": "true", | |
"tot": "str" | |
}, | |
{ | |
"t": "set", | |
"p": "payload", | |
"pt": "msg", | |
"to": "ON", | |
"tot": "str" | |
} | |
], | |
"action": "", | |
"property": "", | |
"from": "", | |
"to": "", | |
"reg": false, | |
"x": 890, | |
"y": 140, | |
"wires": [ | |
[ | |
"f4d88cda.1978a", | |
"cb83226b.4fd07" | |
] | |
] | |
}, | |
{ | |
"id": "cb83226b.4fd07", | |
"type": "debug", | |
"z": "4207226e.90885c", | |
"name": "Debug - Sensor", | |
"active": true, | |
"tosidebar": true, | |
"console": false, | |
"tostatus": false, | |
"complete": "payload", | |
"targetType": "msg", | |
"x": 1100, | |
"y": 60, | |
"wires": [] | |
}, | |
{ | |
"id": "d071ebea.e783d8", | |
"type": "inject", | |
"z": "4207226e.90885c", | |
"name": "Click to reset state", | |
"topic": "", | |
"payload": "", | |
"payloadType": "date", | |
"repeat": "", | |
"crontab": "", | |
"once": false, | |
"onceDelay": 0.1, | |
"x": 570, | |
"y": 240, | |
"wires": [ | |
[ | |
"64ab352f.578ddc" | |
] | |
] | |
}, | |
{ | |
"id": "64ab352f.578ddc", | |
"type": "change", | |
"z": "4207226e.90885c", | |
"name": "Reset SOS state", | |
"rules": [ | |
{ | |
"t": "delete", | |
"p": "payload", | |
"pt": "msg" | |
}, | |
{ | |
"t": "set", | |
"p": "topic", | |
"pt": "msg", | |
"to": "sos/alarm", | |
"tot": "str" | |
}, | |
{ | |
"t": "set", | |
"p": "qos", | |
"pt": "msg", | |
"to": "1", | |
"tot": "str" | |
}, | |
{ | |
"t": "set", | |
"p": "retain", | |
"pt": "msg", | |
"to": "true", | |
"tot": "str" | |
}, | |
{ | |
"t": "set", | |
"p": "payload", | |
"pt": "msg", | |
"to": "OFF", | |
"tot": "str" | |
} | |
], | |
"action": "", | |
"property": "", | |
"from": "", | |
"to": "", | |
"reg": false, | |
"x": 940, | |
"y": 240, | |
"wires": [ | |
[ | |
"f4d88cda.1978a", | |
"6aa2bf21.510a5" | |
] | |
] | |
}, | |
{ | |
"id": "6aa2bf21.510a5", | |
"type": "debug", | |
"z": "4207226e.90885c", | |
"name": "Debug - Sensor", | |
"active": true, | |
"tosidebar": true, | |
"console": false, | |
"tostatus": false, | |
"complete": "payload", | |
"targetType": "msg", | |
"x": 1120, | |
"y": 300, | |
"wires": [] | |
}, | |
{ | |
"id": "3fa7debe.5287f2", | |
"type": "comment", | |
"z": "4207226e.90885c", | |
"name": "SOS Band", | |
"info": "", | |
"x": 100, | |
"y": 40, | |
"wires": [] | |
}, | |
{ | |
"id": "a06529f7.9044f8", | |
"type": "mqtt-broker", | |
"z": "", | |
"name": "Home Assistant MQTT", | |
"broker": "192.168.xxx.xxx", | |
"port": "1883", | |
"clientid": "", | |
"usetls": false, | |
"compatmode": true, | |
"keepalive": "60", | |
"cleansession": true, | |
"birthTopic": "", | |
"birthQos": "0", | |
"birthPayload": "", | |
"closeTopic": "", | |
"closeQos": "0", | |
"closePayload": "", | |
"willTopic": "", | |
"willQos": "0", | |
"willPayload": "" | |
} | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment