[ { "id": "90196b31.9c54a8", "type": "e-mail in", "z": "736018cb.0939b8", "name": "EmbeddedIoT", "protocol": "IMAP", "server": "imap.gmail.com", "useSSL": true, "port": "993", "box": "INBOX", "disposition": "Read", "repeat": "30", "x": 138, "y": 139, "wires": [ [ "bc1f74b8.0de8b8", "1906041d.58362c" ] ] }, { "id": "bc1f74b8.0de8b8", "type": "debug", "z": "736018cb.0939b8", "name": "", "active": true, "console": "false", "complete": "payload", "x": 353, "y": 73, "wires": [] }, { "id": "1906041d.58362c", "type": "sentiment", "z": "736018cb.0939b8", "name": "email-sentiment", "x": 361, "y": 194, "wires": [ [ "e897dcf2.54cb", "838d2040.8a7ed" ] ] }, { "id": "e897dcf2.54cb", "type": "debug", "z": "736018cb.0939b8", "name": "", "active": true, "console": "false", "complete": "sentiment.score", "x": 618, "y": 223, "wires": [] }, { "id": "8e30807f.3c3fb", "type": "ibmiot out", "z": "736018cb.0939b8", "authentication": "apiKey", "apiKey": "", "outputType": "cmd", "deviceId": "LED-controller", "deviceType": "", "eventCommandType": "sentiment", "format": "string", "data": "", "qos": 0, "name": "IBM IoT", "service": "registered", "x": 730, "y": 64, "wires": [] }, { "id": "838d2040.8a7ed", "type": "function", "z": "736018cb.0939b8", "name": "score", "func": "var count = context.get('count')||0;\nvar sum_score = context.get('sum_score')||0;\ncount += 1;\nsum_score += msg.sentiment.score;\nvar average_score = (sum_score/count);\ncontext.set('count',count);\ncontext.set('sum_score',sum_score);\nvar newMsg = { payload: average_score.toFixed(0) };\nreturn newMsg;\n\n", "outputs": 1, "noerr": 0, "x": 557, "y": 97, "wires": [ [ "8e30807f.3c3fb", "f9fc320e.2de7b" ] ] }, { "id": "f9fc320e.2de7b", "type": "debug", "z": "736018cb.0939b8", "name": "", "active": true, "console": "false", "complete": "false", "x": 742, "y": 146, "wires": [] }, { "id": "f3b5d181.edd8b", "type": "ibmiot in", "z": "736018cb.0939b8", "authentication": "apiKey", "apiKey": "", "inputType": "evt", "deviceId": "", "applicationId": "", "deviceType": "+", "eventType": "+", "commandType": "", "format": "json", "name": "IBM IoT", "service": "registered", "allDevices": "", "allApplications": "", "allDeviceTypes": false, "allEvents": true, "allCommands": "", "allFormats": true, "qos": 0, "x": 223, "y": 381, "wires": [ [ "3d3237b.304f3c8", "17214209.e1dc9e" ] ] }, { "id": "3d3237b.304f3c8", "type": "debug", "z": "736018cb.0939b8", "name": "", "active": true, "console": "false", "complete": "true", "x": 498, "y": 294, "wires": [] }, { "id": "17214209.e1dc9e", "type": "ibmiot out", "z": "736018cb.0939b8", "authentication": "quickstart", "apiKey": "8467db6b.d9c138", "outputType": "evt", "deviceId": "LED-controller", "deviceType": "0.15.2", "eventCommandType": "status", "format": "json", "data": "work-mode", "qos": 0, "name": "IBM IoT", "service": "quickstart", "x": 500, "y": 400, "wires": [] }, { "id": "8467db6b.d9c138", "type": "ibmiot", "z": "736018cb.0939b8", "name": "LED_controller", "keepalive": "60", "cleansession": true, "appId": "", "shared": false } ]