Fun with AMI Node-Red 2


(PbxNoob) #1

@lgaetz I’m just wondering if you’ve done any more playing with your node-red and your hinterland script? I’m trying to get this to reliably send updates for the three extensions and it’s hit and miss. Something about the strings means they’re not being routed to the right nodes. Made me think it might be a whole lot less faff to just modify the hinterland script to catch the different cases/events within that script and send mqtt messages from there? I don’t really know PHP - is that how you’d do it or would you more likely tell PHP to execute a bash script on a particular case? I don’t know whether PHP can work with mosquitto.

[{"id":"3aedb22.998dc4e","type":"switch","z":"36ca7898.7bdf48","name":"","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"4001","vt":"str"},{"t":"cont","v":"4003","vt":"str"},{"t":"cont","v":"4004","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":510,"y":200,"wires":[["a9c44c6a.9af79","94081938.f32de8"],["a481224d.1b7db","94081938.f32de8"],["914994a5.ab24c8","94081938.f32de8"]]},{"id":"a9c44c6a.9af79","type":"switch","z":"36ca7898.7bdf48","name":"","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"status: 0","vt":"str"},{"t":"cont","v":"status: 8","vt":"str"},{"t":"cont","v":"status: 1","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":650,"y":100,"wires":[["addaf9f1.d01cc8"],["70236d08.e292e4"],["5d383102.265e"]]},{"id":"addaf9f1.d01cc8","type":"change","z":"36ca7898.7bdf48","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"IDLE","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":820,"y":40,"wires":[["8ff384c.bfe6778"]]},{"id":"70236d08.e292e4","type":"change","z":"36ca7898.7bdf48","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"RINGING","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":820,"y":80,"wires":[["8ff384c.bfe6778"]]},{"id":"5d383102.265e","type":"change","z":"36ca7898.7bdf48","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"IN_USE","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":820,"y":120,"wires":[["8ff384c.bfe6778"]]},{"id":"8ff384c.bfe6778","type":"mqtt out","z":"36ca7898.7bdf48","name":"","topic":"exten/4001","qos":"","retain":"","broker":"459c73d.68a4d8c","x":1020,"y":80,"wires":[]},{"id":"9871d79b.d57688","type":"change","z":"36ca7898.7bdf48","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"IDLE","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":820,"y":160,"wires":[["25f7721a.7960ce"]]},{"id":"78a437d0.dc7c88","type":"change","z":"36ca7898.7bdf48","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"RINGING","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":820,"y":200,"wires":[["25f7721a.7960ce"]]},{"id":"519cfd63.413db4","type":"change","z":"36ca7898.7bdf48","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"IN_USE","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":820,"y":240,"wires":[["25f7721a.7960ce"]]},{"id":"25f7721a.7960ce","type":"mqtt out","z":"36ca7898.7bdf48","name":"","topic":"exten/4003","qos":"","retain":"","broker":"459c73d.68a4d8c","x":1020,"y":200,"wires":[]},{"id":"bc754b90.818858","type":"change","z":"36ca7898.7bdf48","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"IDLE","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":820,"y":280,"wires":[["152c5552.67110b"]]},{"id":"19885700.fabc69","type":"change","z":"36ca7898.7bdf48","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"RINGING","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":820,"y":320,"wires":[["152c5552.67110b"]]},{"id":"a41a4204.29fe9","type":"change","z":"36ca7898.7bdf48","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"IN_USE","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":820,"y":360,"wires":[["152c5552.67110b"]]},{"id":"152c5552.67110b","type":"mqtt out","z":"36ca7898.7bdf48","name":"","topic":"exten/4004","qos":"","retain":"","broker":"459c73d.68a4d8c","x":1020,"y":320,"wires":[]},{"id":"fc3d0ba.7bad3f8","type":"daemon","z":"36ca7898.7bdf48","name":"","command":"/usr/bin/php","args":"/root/lgaetz-hinterland.php","autorun":true,"cr":false,"redo":true,"op":"string","closer":"SIGKILL","x":170,"y":100,"wires":[["4b63f892.ef4dd8","dd197c66.3a727"],[],[]]},{"id":"7903f5b.e94f50c","type":"string","z":"36ca7898.7bdf48","name":"","methods":[{"name":"between","params":[{"type":"str","value":"exten:  "},{"type":"str","value":" statustext"}]}],"prop":"payload","propout":"payload","object":"msg","objectout":"msg","x":450,"y":60,"wires":[["3aedb22.998dc4e"]]},{"id":"a481224d.1b7db","type":"switch","z":"36ca7898.7bdf48","name":"","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"status: 0","vt":"str"},{"t":"cont","v":"status: 8","vt":"str"},{"t":"cont","v":"status: 1","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":650,"y":200,"wires":[["9871d79b.d57688"],["78a437d0.dc7c88"],["519cfd63.413db4"]]},{"id":"914994a5.ab24c8","type":"switch","z":"36ca7898.7bdf48","name":"","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"status: 0","vt":"str"},{"t":"cont","v":"status: 8","vt":"str"},{"t":"cont","v":"status: 1","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":650,"y":320,"wires":[["bc754b90.818858"],["19885700.fabc69"],["a41a4204.29fe9"]]},{"id":"4b63f892.ef4dd8","type":"function","z":"36ca7898.7bdf48","name":"","func":"var values = msg.payload.trim().split('\\t');    // trim off the crlf first then split into parts   \nmsg.payload = values[0];  // replace payload with the reading we want\nreturn msg;","outputs":1,"noerr":0,"x":330,"y":120,"wires":[["7903f5b.e94f50c","d1be6587.ab6b18"]]},{"id":"dd197c66.3a727","type":"debug","z":"36ca7898.7bdf48","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":260,"y":280,"wires":[]},{"id":"d1be6587.ab6b18","type":"debug","z":"36ca7898.7bdf48","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":350,"y":220,"wires":[]},{"id":"94081938.f32de8","type":"debug","z":"36ca7898.7bdf48","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":630,"y":260,"wires":[]},{"id":"459c73d.68a4d8c","type":"mqtt-broker","z":"","name":"","broker":"192.168.0.110","port":"1883","clientid":"node-red","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]

(Lorne Gaetz) #2

I haven’t done anything beyond proof of concept and tinkering, so I don’t have a sense of how things behave at scale or after a long time.


(system) closed #3

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.