• You have a virtual sensor at home providing data on humidity (H) and temperature (T) at regular intervals (SENSE)
  • Your local intelligence is the following (THINK)
    • if H>HTh and T>TTh switch on the virtual air conditioning (ACT)
    • Notice that the thresholds HTh and TTh are initially set to arbitrary values 
  • In the meanwhile you have a server running sentiment analysis to verify whether people  is actually confortable by the given thresholds
    • if sentiment positive then nothing
    • if AVERAGE sentiment negative then send a command over the Internet to your sensor at home to decrease HTh and TTh
    • For the sake of simplicity run sentiment analysis on the word "temperature"

NODE-RED FLOW

[{"id":"47daa254.fdd9dc","type":"dweetio in","z":"efcf45e2.677f98","thing":"papa_give_me_a_hammer","name":"Com RX by dweet","x":730.25,"y":186,"wires":[["1746c24.f5a653e"]]},{"id":"1746c24.f5a653e","type":"debug","z":"efcf45e2.677f98","name":"Actuate Time in your Room","active":false,"console":"false","complete":"payload","x":1026.250015258789,"y":52,"wires":[]},{"id":"55dd56bb.717278","type":"comment","z":"efcf45e2.677f98","name":"https://dweet.io/","info":"Ridiculously simple messaging (and alerts) for the Internet of Things.","x":618,"y":67,"wires":[]},{"id":"2aa86258.08aebe","type":"inject","z":"efcf45e2.677f98","name":"Sense Time in my Room","topic":"","payload":"Ciao funge?","payloadType":"str","repeat":"2","crontab":"","once":false,"x":222.5,"y":62.5,"wires":[["f2e262c4.559cc"]]},{"id":"f2e262c4.559cc","type":"dweetio out","z":"efcf45e2.677f98","thing":"papa_give_me_a_hammer","name":"Com TX by dweet","x":495.25000762939453,"y":185.25000190734863,"wires":[]}]

NODE-RED FLOW

[{"id":"d841eafa.45c728","type":"inject","z":"51acd361.27dd1c","name":"Sense Temp","topic":"temp","payload":"5","payloadType":"num","repeat":"","crontab":"","once":false,"x":193.25,"y":212.50000286102295,"wires":[["49d1d538.a03a1c"]]},{"id":"a5898d5e.54668","type":"inject","z":"51acd361.27dd1c","name":"Sense Hum","topic":"hum","payload":"3","payloadType":"num","repeat":"","crontab":"","once":false,"x":196,"y":364,"wires":[["49d1d538.a03a1c"]]},{"id":"49d1d538.a03a1c","type":"function","z":"51acd361.27dd1c","name":"Think","func":"// initialise the counter to 0 if it doesn't exist already\n// http://nodered.org/docs/writing-functions.html\n\nvar hum = context.get('hum')||false;\nvar temp = context.get('temp')||false;\n\nmsg.payload=\"false\";\n\nif (msg.topic==\"hum\"){\n    context.set('hum',true);\n    hum = true;\n}\n    \nif (msg.topic==\"temp\"){\n    context.set('temp',true);\n    temp = true;\n}\n\nmsg.payload = hum && temp;\nif (hum && temp){\n   context.set('hum',false);\n   context.set('temp',false);\n}\n    \nreturn msg;","outputs":1,"noerr":0,"x":329.00000381469727,"y":293.2500047683716,"wires":[["4ab8dff8.39a75"]]},{"id":"4ab8dff8.39a75","type":"debug","z":"51acd361.27dd1c","name":"Actuate","active":false,"console":"false","complete":"payload","x":501.00000762939453,"y":296.50000381469727,"wires":[]}]

NODE-RED FLOW

[{"id":"81b3adf4.11104","type":"inject","z":"d77e5dcf.c2e75","name":"temperature","topic":"","payload":"3","payloadType":"num","repeat":"","crontab":"","once":true,"x":121,"y":98,"wires":[["30c7b85c.6c1a48","52639a9b.f454a4"]]},{"id":"30c7b85c.6c1a48","type":"debug","z":"d77e5dcf.c2e75","name":"","active":false,"console":"false","complete":"payload","x":664,"y":112.16667175292969,"wires":[]},{"id":"52639a9b.f454a4","type":"switch","z":"d77e5dcf.c2e75","name":"","property":"payload","propertyType":"msg","rules":[{"t":"gt","v":"5","vt":"str"},{"t":"lt","v":"5","vt":"str"},{"t":"eq","v":"5","vt":"str"}],"checkall":"true","outputs":3,"x":165.1666717529297,"y":318.83331298828125,"wires":[["b71a791.d15ac88"],["c47cd42d.29eb08"],["95d61b4c.9d8078"]]},{"id":"b71a791.d15ac88","type":"function","z":"d77e5dcf.c2e75","name":"HIGH","func":"msg.payload=\"HIGH\"\nreturn msg;","outputs":1,"noerr":0,"x":432.66668701171875,"y":220.3333282470703,"wires":[["79b15dd3.59eb54"]]},{"id":"c47cd42d.29eb08","type":"function","z":"d77e5dcf.c2e75","name":"LOW","func":"msg.payload=\"LOW\"\nreturn msg;","outputs":1,"noerr":0,"x":441.8333435058594,"y":330.66668701171875,"wires":[["79b15dd3.59eb54"]]},{"id":"95d61b4c.9d8078","type":"function","z":"d77e5dcf.c2e75","name":"EQUAL","func":"msg.payload=\"EQUAL\"\nreturn msg;","outputs":1,"noerr":0,"x":450,"y":456,"wires":[["79b15dd3.59eb54"]]},{"id":"79b15dd3.59eb54","type":"debug","z":"d77e5dcf.c2e75","name":"","active":false,"console":"false","complete":"false","x":731,"y":312,"wires":[]}]

NODE-RED FLOW



[{"id":"50c61357.4b11bc","type":"ui_tab","z":"f36cb853.0c9348","name":"Arduino","icon":"dashboard","order":"1"},{"id":"4a44e8f0.b5bb18","type":"mqtt-broker","z":"f36cb853.0c9348","broker":"test.mosquitto.org","port":"1883","clientid":"","usetls":false,"verifyservercert":true,"compatmode":true,"keepalive":"15","cleansession":true,"willTopic":"","willQos":"0","willRetain":null,"willPayload":"","birthTopic":"","birthQos":"0","birthRetain":null,"birthPayload":""},{"id":"263112bf.d9ceee","type":"serial-port","z":"f36cb853.0c9348","serialport":"/dev/ttyACM0","serialbaud":"9600","databits":"8","parity":"none","stopbits":"1","newline":"\\n","bin":"false","out":"char","addchar":false},{"id":"323793ce.cdc86c","type":"serial in","z":"f36cb853.0c9348","name":"Arduino","serial":"263112bf.d9ceee","x":262,"y":296,"wires":[["1411049f.ebeefb","e07fc8d3.1f8038","44c2b041.bb3d5"]]},{"id":"1411049f.ebeefb","type":"debug","z":"f36cb853.0c9348","name":"","active":false,"console":"false","complete":"false","x":579,"y":428,"wires":[]},{"id":"e07fc8d3.1f8038","type":"dweetio out","z":"f36cb853.0c9348","thing":"123rrr456","name":"","x":582,"y":185,"wires":[]},{"id":"130c604c.ecf3a","type":"debug","z":"f36cb853.0c9348","name":"","active":false,"console":"false","complete":"false","x":566,"y":674,"wires":[]},{"id":"b326542d.4cd9a8","type":"dweetio in","z":"f36cb853.0c9348","thing":"123rrr456","name":"","x":246,"y":565,"wires":[["130c604c.ecf3a","74586874.55e498"]]},{"id":"44c2b041.bb3d5","type":"mqtt out","z":"f36cb853.0c9348","name":"mqtt","topic":"proviamoci","qos":"","retain":"","broker":"4a44e8f0.b5bb18","x":627,"y":341,"wires":[]},{"id":"40278716.bfd878","type":"mqtt in","z":"f36cb853.0c9348","name":"mqtt","topic":"proviamoci","broker":"4a44e8f0.b5bb18","x":625,"y":536,"wires":[["e0cc4553.1f33b8"]]},{"id":"e0cc4553.1f33b8","type":"debug","z":"f36cb853.0c9348","name":"","active":false,"console":"false","complete":"false","x":912,"y":607,"wires":[]},{"id":"74586874.55e498","type":"ui_gauge","z":"f36cb853.0c9348","tab":"50c61357.4b11bc","name":"Stream","group":"ACTUATOR","order":1,"format":"{{value}}","min":0,"max":"5","x":568,"y":761,"wires":[]},{"id":"93881fe2.d0da6","type":"ui_switch","z":"f36cb853.0c9348","tab":"50c61357.4b11bc","name":"Alarm Switch","topic":"","group":"SENSOR","order":1,"onvalue":"true","offvalue":"false","x":282,"y":868,"wires":[["67061152.5687c"]]},{"id":"3ea796f.19d846a","type":"serial out","z":"f36cb853.0c9348","name":"","serial":"263112bf.d9ceee","x":806,"y":867,"wires":[]},{"id":"67061152.5687c","type":"function","z":"f36cb853.0c9348","name":"switch to command","func":"if (msg.payload==\"true\") {\n    msg.payload='3';\n}\nelse {\n    msg.payload='4';\n}\nreturn msg;","outputs":1,"noerr":0,"x":555,"y":869,"wires":[["3ea796f.19d846a"]]}]

https://developer.ibm.com/bluemix/2015/11/02/analyze-tweets-in-30-minutes/

NODE-RED FLOW

[{"id":"18f221a3.9a936e","type":"ui_tab","z":"c293dba8.73c328","name":"Sentiment","icon":"dashboard","order":"1"},{"id":"6f99631.c65c09c","type":"twitter in","z":"c293dba8.73c328","twitter":"","tags":"art","user":"false","name":"","topic":"tweets","x":151.5,"y":307.5000042915344,"wires":[["da3c11e3.8e723"]]},{"id":"da3c11e3.8e723","type":"sentiment","z":"c293dba8.73c328","name":"","x":378,"y":341,"wires":[["8c26690d.faa578","678acb53.c92a84","a83df3b5.699e1"]]},{"id":"8c26690d.faa578","type":"debug","z":"c293dba8.73c328","name":"","active":false,"console":"false","complete":"false","x":602,"y":287,"wires":[]},{"id":"a83df3b5.699e1","type":"debug","z":"c293dba8.73c328","name":"","active":false,"console":"false","complete":"sentiment.score","x":631.7500076293945,"y":398.2500066757202,"wires":[]},{"id":"83d38220.e7cf3","type":"ui_chart","z":"c293dba8.73c328","tab":"18f221a3.9a936e","name":"","group":"","order":1,"interpolate":"linear","nodata":"No Data","removeOlder":1,"removeOlderUnit":"60","x":711.25,"y":518,"wires":[[],[]]},{"id":"678acb53.c92a84","type":"function","z":"c293dba8.73c328","name":"","func":"msg.payload=msg.sentiment.score;\nmsg.topic=\"xxx\";\nreturn msg;","outputs":1,"noerr":0,"x":533,"y":519.25,"wires":[["83d38220.e7cf3"]]}]


[{"id":"be2fe415.41d018","type":"ui_tab","z":"da4831fa.25b7d","name":"Home","icon":"dashboard","order":"1"},{"id":"3428f757.cbd708","type":"ui_text","z":"da4831fa.25b7d","tab":"be2fe415.41d018","name":"Alarm","group":"ACTUATOR","order":1,"format":"{{msg.payload}}","x":642,"y":500,"wires":[]},{"id":"ff1e5345.00e1b","type":"ui_slider","z":"da4831fa.25b7d","tab":"be2fe415.41d018","name":"TEMPERATURE:  ","topic":"","group":"SENSOR","order":"3","min":0,"max":10,"x":314,"y":654,"wires":[["33f7204e.cc08e"]]},{"id":"33f7204e.cc08e","type":"ui_gauge","z":"da4831fa.25b7d","tab":"be2fe415.41d018","name":"Stream","group":"ACTUATOR","order":1,"format":"{{value}}","min":0,"max":10,"x":685,"y":655,"wires":[]},{"id":"7ddba36f.82245c","type":"ui_chart","z":"da4831fa.25b7d","tab":"be2fe415.41d018","name":"Graph","group":"GRAPH","order":1,"interpolate":"linear","nodata":"No Data","removeOlder":1,"removeOlderUnit":"60","x":743,"y":789,"wires":[[],[]]},{"id":"3c33691.fc3cc96","type":"inject","z":"da4831fa.25b7d","name":"","topic":"","payload":"","payloadType":"date","repeat":"1","crontab":"","once":true,"x":315,"y":788,"wires":[["cea061.ff315fa"]]},{"id":"cea061.ff315fa","type":"function","z":"da4831fa.25b7d","name":"RND","func":"msg.payload = 100*Math.random();\nreturn msg;","outputs":1,"noerr":0,"x":510,"y":789,"wires":[["7ddba36f.82245c"]]},{"id":"96e257cc.691da8","type":"ui_switch","z":"da4831fa.25b7d","tab":"be2fe415.41d018","name":"Alarm Switch","topic":"","group":"SENSOR","order":1,"onvalue":"true","offvalue":"false","x":305,"y":498,"wires":[["3428f757.cbd708"]]},{"id":"c2f5f906.3d0a08","type":"comment","z":"da4831fa.25b7d","name":"http://127.0.0.1:1880/ui/","info":"http://127.0.0.1:1880/ui/","x":337,"y":402,"wires":[]}]