Parsing JeeNode Room Board

Flow to Parse JeeNode Room board messages. (http://jeelabs.net/projects/hardware/wiki/Room_Board)

The flow assumes that the RoomBoard is equipped with Temperature, Humidity and PIR sensors, and calculates the dew point.

Sensor readings are routed individually to mqtt topics in addition to a JSON object.

[{"id":"ba386057.845d3","type":"mqtt-broker","broker":"localhost","port":"1883"},{"id":"73eefd1c.95934c","type":"mqtt in","name":"Shed node Raw","topic":"home/shed/node/raw","broker":"ba386057.845d3","x":76,"y":290,"z":"aa7bf422.ba91a","wires":[["9802394.f7d8e48"]]},{"id":"9802394.f7d8e48","type":"function","name":"Parse RoomNode","func":"// console.log(msg.topic, msg.payload, msg.qos, msg.retain);\n// context = {};\n//retrieve byte data from array\n\n//based on JEElib Housemon roomnode driver\nvar raw= JSON.parse(msg.payload);\nbuf = new Buffer(raw);\n\nvar t = buf.readUInt16LE(2) & 0x3FF;\n//temp from -512..+511 (e.g. -51.2..+51.1) supported by roomNode sketch\nmsg.environment = new Object();\n\nmsg.environment.Temperature = (( (t < 0x200 ) ? t : t - 0x400))/10;\nmsg.environment.Light = buf[0];\nmsg.environment.Moved = buf[1] & 1;\nmsg.environment.Humidity = buf[1] >> 1;\nmsg.environment.Lowbattery  = (buf[3] >> 2) & 1;\n\n\nreturn msg;","outputs":"1","x":241.99995803833008,"y":290.00002813339233,"z":"aa7bf422.ba91a","wires":[["a05fcec9.f169a8"]]},{"id":"adf93841.2d14","type":"debug","name":"Shed Json","complete":"false","x":540.333309173584,"y":138.00002479553223,"z":"aa7bf422.ba91a","wires":[]},{"id":"d59a6b33.1fb0a","type":"mqtt out","name":"Shed Json","topic":"home/shed/json","broker":"ba386057.845d3","x":536.9999732971191,"y":174.00001049041748,"z":"aa7bf422.ba91a","wires":[]},{"id":"4a77e83a.8a84a","type":"mqtt out","name":"Shed Temperature","topic":"home/shed/temp","broker":"ba386057.845d3","x":730.3333892822266,"y":252.3333215713501,"z":"aa7bf422.ba91a","wires":[]},{"id":"aebf178d.f841a8","type":"mqtt out","name":"Shed Light","topic":"home/shed/light","broker":"ba386057.845d3","x":705.333381652832,"y":285.666690826416,"z":"aa7bf422.ba91a","wires":[]},{"id":"aa6aa829.e088e8","type":"mqtt out","name":"Shed Movement","topic":"home/shed/movement","broker":"ba386057.845d3","x":721.9999618530273,"y":313.99999809265137,"z":"aa7bf422.ba91a","wires":[]},{"id":"6c117e2b.2c8cb8","type":"mqtt out","name":"Shed Humidity","topic":"home/shed/humidity","broker":"ba386057.845d3","x":716.9999465942383,"y":349.0000066757202,"z":"aa7bf422.ba91a","wires":[]},{"id":"4193b961.b6df18","type":"mqtt out","name":"Shed LowBattery","topic":"home/shed/lowbattery","broker":"ba386057.845d3","x":722.9999580383301,"y":421.66668462753296,"z":"aa7bf422.ba91a","wires":[]},{"id":"5cb3450.a2b5cbc","type":"comment","name":"-------------------  Shed -------------------","info":"","x":156.99991607666016,"y":75.66669750213623,"z":"aa7bf422.ba91a","wires":[]},{"id":"a05fcec9.f169a8","type":"function","name":"Add Dew Point","func":"// The received message is stored in 'msg'\n// It will have at least a 'payload' property:\n//   console.log(msg.payload);\n// The 'context' object is available to store state\n// between invocations of the function\n//   context = {};\n\n// expects environment.temp && environment.humidity \nif(msg.environment != null)\n\t{\n\t\tvar temp2 = msg.environment.Temperature;\n\t\tvar r = msg.environment.Humidity;\n\t  \n\t\tif(temp2 !=null && !isNaN(temp2)  && r !=null && !isNaN(r))\n\t   \t{\n\t\t    \n\t\t    var temp = -1.0*temp2;\n\t\t    es = 6.112*Math.exp(-1.0*17.67*temp/(243.5 - temp));\n\t\t    ed = r/100.0*es;\n\t\t    eln = Math.log(ed/6.112);\n\t\t    td = -243.5*eln/(eln - 17.67 );\n\t\t    msg.environment.Dewpoint = td.toFixed(2);\n\t\t}\n\t}\nreturn msg;","outputs":1,"x":398.99992752075195,"y":289.66668462753296,"z":"aa7bf422.ba91a","wires":[["88040234.5a5d9"]]},{"id":"88040234.5a5d9","type":"function","name":"Route Messages","func":"// The received message is stored in 'msg'\n// It will have at least a 'payload' property:\n//   console.log(msg.payload);\n// The 'context' object is available to store state\n// between invocations of the function\n//   context = {};\n//create json text\n\nif(msg.environment == null)\n{\n\t//no data - stop here\n\treturn null;\n}\n\n \tjsonText = JSON.stringify(msg.environment);\n \nvar msg1 = {payload:JSON.stringify(msg.environment)};\n\nvar msg2 = {payload:msg.environment.Temperature};\nvar msg3 = {payload:msg.environment.Light};\nvar msg4 = {payload:msg.environment.Moved};\nvar msg5 = {payload:msg.environment.Humidity};\nvar msg6 = {payload:msg.environment.Dewpoint};\nvar msg7 = {payload:msg.environment.Lowbattery};\n\n\nreturn [msg1,msg2,msg3,msg4,msg5,msg6,msg7];","outputs":"7","x":552.6666145324707,"y":290.3333716392517,"z":"aa7bf422.ba91a","wires":[["adf93841.2d14","d59a6b33.1fb0a"],["4a77e83a.8a84a"],["aebf178d.f841a8"],["aa6aa829.e088e8"],["6c117e2b.2c8cb8"],["134c9b64.0534ad"],["4193b961.b6df18"]]},{"id":"134c9b64.0534ad","type":"mqtt out","name":"Shed Dew Point","topic":"home/shed/dewpoint","broker":"ba386057.845d3","x":723.6666259765625,"y":382.33337116241455,"z":"aa7bf422.ba91a","wires":[]}]
bramleyd

Flow Info

created 4 years, 3 months ago

Node Types

Core
  • comment (x1)
  • debug (x1)
  • function (x3)
  • mqtt in (x1)
  • mqtt out (x7)
  • mqtt-broker (x1)

Tags

  • RoomBoard
  • JeeNode
  • RFM12B
  • 433MHZ
  • Temperature
  • Humidity
  • PIR
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option