"Sketch Version" (I_SKETCH_VERSION) Handler



  • I extended the /root/leases.file to also include a 3rd field for version. Now you can update nodes and see the version change as you update (or view unupdated ones).

    It is functionally very similar to that of I_SKETCH_NAME handler.

    [{"id":"8e3e8f02.7fd0c","type":"mqtt-broker","z":"63842e72.893f78","broker":"localhost","port":"8883","clientid":"","usetls":false,"verifyservercert":true,"compatmode":true,"keepalive":"15","cleansession":true,"willTopic":"","willQos":"0","willRetain":null,"willPayload":"","birthTopic":"","birthQos":"0","birthRetain":null,"birthPayload":""},{"id":"21742d0e.25817a","type":"mqtt in","z":"63842e72.893f78","name":"Rename sensor in file","topic":"MySensors/+/255/3/0/12","broker":"8e3e8f02.7fd0c","x":106,"y":630,"wires":[["8a1e6bb3.db726"]]},{"id":"8a1e6bb3.db726","type":"function","z":"63842e72.893f78","name":"message to edit","func":"var splitTopic= msg.topic.split(\"\\/\");\nmsg.payload = msg.payload.replace(\"\\n\", \"\");\nmsg.edit = {col1:splitTopic[1] , col3:msg.payload}; \n// msg.edit carries over the next 2 nodes to \"find edit and replace\" function node\nreturn msg;","outputs":1,"noerr":0,"x":352,"y":629,"wires":[["cb5f1a37.6ab65"]]},{"id":"cb5f1a37.6ab65","type":"file in","z":"63842e72.893f78","name":"","filename":"/root/leases.file","format":"utf8","x":528,"y":630,"wires":[["77038207.b61144"]]},{"id":"77038207.b61144","type":"csv","z":"63842e72.893f78","name":"","sep":",","hdrin":"","hdrout":"","multi":"mult","ret":"\\n","temp":"col1,col2,col3","x":113,"y":701,"wires":[["f2858e20.0e9b18"]]},{"id":"f2858e20.0e9b18","type":"function","z":"63842e72.893f78","name":"find edit and replace","func":"for(var i = 0; i < msg.payload.length; i++){\n    if( msg.edit.col1 == msg.payload[i].col1 ){\n        msg.payload[i].col3 = msg.edit.col3;\n    }\n}\nreturn msg;","outputs":1,"noerr":0,"x":282,"y":701,"wires":[["2ef32bcf.fefb74"]]},{"id":"321725f3.9ad162","type":"file","z":"63842e72.893f78","name":"","filename":"/root/leases.file","appendNewline":true,"createDir":false,"overwriteFile":"true","x":644,"y":702,"wires":[]},{"id":"6404769b.fdaff8","type":"debug","z":"63842e72.893f78","name":"","active":true,"console":"false","complete":"false","x":634,"y":741,"wires":[]},{"id":"2ef32bcf.fefb74","type":"csv","z":"63842e72.893f78","name":"","sep":",","hdrin":"","hdrout":"","multi":"one","ret":"\\n","temp":"col1,col2,col3","x":449,"y":701,"wires":[["321725f3.9ad162","6404769b.fdaff8"]]},{"id":"aaea7f9c.a0adf","type":"comment","z":"63842e72.893f78","name":"I_SKETCH_VERSION handler ([0-255];255;3;0;12;[name])","info":"Whenever a sensor announces itself to the network as [any];255;3;0;11;[name from presentation],\nit modifies field 2 for that appropriate sensor. \n\nThe resulting modification is then saved.","x":304,"y":743,"wires":[]}]
    

Log in to reply
 

Suggested Topics

  • 9
  • 2
  • 5
  • 9
  • 1
  • 2

64
Online

11.4k
Users

11.1k
Topics

112.7k
Posts