节点红色的MongDB温度传感器值丢失

时间:2019-03-20 23:30:57

标签: mongodb-query node-red

我有一个DS18b20传感器连接到我的pi。我正在使用CRUD网站添加存储在MongoDB中的姓名,姓氏和电话号码。如果温度高于或低于特定水平,我想使用来自原始数据库的数据发送电子邮件警报。我可以正常工作,但我也想在电子邮件中包括实际温度以及数据库中的详细信息。我得到了数据库的详细信息,但是温度让我不寒而栗!我正在运行多个流程,这是我的CRUD网站和数据库的流程,然后是我如何将所有内容整合在一起的方法。

调试输出:Temperature Alert! testing tillblue Temperature is [object Object] Thu Mar 21 2019 01:26:26 GMT+0200 (SAST)

我想将我的DS18b20值插入“ [object Object]”部分。

(测试tillblue是来自MongoDB Crud站点的值)

如何填充?

[
   {
      "id":"ab12b659.8e71a8",
      "type":"http in",
      "z":"4bce6f41.15aa4",
      "name":"",
      "url":"/update",
      "method":"put",
      "swaggerDoc":"",
      "x":90,
      "y":108,
      "wires":[
         [
            "dd8b5ef4.4e8bc"
         ]
      ]
   },
   {
      "id":"a19375f8.67f738",
      "type":"http response",
      "z":"4bce6f41.15aa4",
      "name":"",
      "statusCode":"",
      "headers":{

      },
      "x":1150,
      "y":108,
      "wires":[

      ]
   },
   {
      "id":"f8d1c74c.528128",
      "type":"function",
      "z":"4bce6f41.15aa4",
      "name":"update request",
      "func":"msg.result=msg.req.body;\ndelete msg.req.body._id;\nmsg.payload=[\n   msg.payload,\n   msg.req.body\n    ];\nreturn msg;\n\n",
      "outputs":"1",
      "noerr":0,
      "x":560,
      "y":108,
      "wires":[
         [
            "d03524fd.6a5768"
         ]
      ]
   },
   {
      "id":"dd8b5ef4.4e8bc",
      "type":"function",
      "z":"4bce6f41.15aa4",
      "name":"extract _id",
      "func":"msg._id=msg.payload._id;\nreturn msg;",
      "outputs":1,
      "noerr":0,
      "x":250,
      "y":108,
      "wires":[
         [
            "e4275604.1b7bb8"
         ]
      ]
   },
   {
      "id":"e4275604.1b7bb8",
      "type":"objectid",
      "z":"4bce6f41.15aa4",
      "name":"",
      "x":400,
      "y":108,
      "wires":[
         [
            "f8d1c74c.528128"
         ]
      ]
   },
   {
      "id":"e4fb57c0.f853e8",
      "type":"template",
      "z":"4bce6f41.15aa4",
      "name":"Web Template",
      "field":"payload",
      "fieldType":"msg",
      "format":"handlebars",
      "syntax":"mustache",
      "template":"<!DOCTYPE html>\n<html>\n<head>\n    <title>Admin Page</title>\n    <meta charset=\"utf-8\">\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n    <link rel=\"stylesheet\" href=\"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css\">\n    <link rel=\"stylesheet\" href=\"https://cdnjs.cloudflare.com/ajax/libs/bootstrap-timepicker/0.5.2/css/bootstrap-timepicker.min.css\" />\n    <script src=\"https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js\"></script>\n    <script src=\"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js\"></script>\n    <link type=\"text/css\" rel=\"stylesheet\" href=\"https://cdnjs.cloudflare.com/ajax/libs/jsgrid/1.5.3/jsgrid.min.css\" />\n    <link type=\"text/css\" rel=\"stylesheet\" href=\"https://cdnjs.cloudflare.com/ajax/libs/jsgrid/1.5.3/jsgrid-theme.min.css\" />\n    <script type=\"text/javascript\" src=\"https://cdnjs.cloudflare.com/ajax/libs/jsgrid/1.5.3/jsgrid.min.js\"></script>\n\n    <script type=\"text/javascript\">\n        $(function () {\n            var crud = {{#payload}}{{{.}}}{{/payload}};\n                $(\"#jsgrid\").jsGrid({\n                    width: \"100%\",\n                    inserting: true,\n                    editing: true,\n                    sorting: true,\n                    paging: true,\n\n                    data: crud,\n\n                    fields: [\n                        { title:\"Name\", name: \"Name\", type: \"text\", width: 50 },\n                        { title:\"Surname\", name: \"Surname\", type: \"text\", width: 50 },\n                        { title:\"Email Address\", name: \"Email\", type: \"text\", width: 50 },\n                        { title:\"Mobile phone\", name: \"number\", type:\"text\", width: 50},\n                        { type: \"control\" }\n                    ],\n               \n                    controller: {\n                        insertItem: function(item) {\n                            return $.ajax({\n                                type: \"POST\",\n                                url: \"/insert\",\n                                data: item\n                            });\n                        },\n                        updateItem: function(item) {\n                           return $.ajax({\n                                type: \"PUT\",\n                                url: \"/update\",\n                                data: item\n                            });\n                        },\n                        deleteItem: function(item) {\n                            return $.ajax({\n                                type: \"DELETE\",\n                                url: \"/delete\",\n                                data: item\n                            });\n                        }\n                    }   \n                });\n            });\n    \n  </script>\n</head>\n<body class=\"container\">\n    <section class=\"row\">\n        \n        <div class=\"col-md-6\"></div>\n        <div class=\"col-md-6\" id=\"jsgrid\">\n        </div>\n    </section>\n</body>\n</html>",
      "x":700,
      "y":48,
      "wires":[
         [
            "70e1e9b1.5d92b8"
         ]
      ]
   },
   {
      "id":"7b551690.45f348",
      "type":"http in",
      "z":"4bce6f41.15aa4",
      "name":"",
      "url":"/crud",
      "method":"get",
      "upload":false,
      "swaggerDoc":"",
      "x":80,
      "y":48,
      "wires":[
         [
            "b75256b9.4db9f8"
         ]
      ]
   },
   {
      "id":"70e1e9b1.5d92b8",
      "type":"http response",
      "z":"4bce6f41.15aa4",
      "name":"",
      "x":850,
      "y":48,
      "wires":[

      ]
   },
   {
      "id":"5de742ac.77afbc",
      "type":"json",
      "z":"4bce6f41.15aa4",
      "name":"",
      "x":530,
      "y":48,
      "wires":[
         [
            "e4fb57c0.f853e8"
         ]
      ]
   },
   {
      "id":"12320935.f3c367",
      "type":"function",
      "z":"4bce6f41.15aa4",
      "name":"callback response",
      "func":"msg.payload=msg.result;\nreturn msg;",
      "outputs":1,
      "noerr":0,
      "x":990,
      "y":108,
      "wires":[
         [
            "a19375f8.67f738"
         ]
      ]
   },
   {
      "id":"e2529c5e.4214f",
      "type":"http response",
      "z":"4bce6f41.15aa4",
      "name":"",
      "x":690,
      "y":168,
      "wires":[

      ]
   },
   {
      "id":"c98f000b.3e01d",
      "type":"http in",
      "z":"4bce6f41.15aa4",
      "name":"",
      "url":"/insert",
      "method":"post",
      "swaggerDoc":"",
      "x":90,
      "y":168,
      "wires":[
         [
            "e867b605.0be758"
         ]
      ]
   },
   {
      "id":"f5595ec3.b0b57",
      "type":"http in",
      "z":"4bce6f41.15aa4",
      "name":"",
      "url":"/delete",
      "method":"delete",
      "swaggerDoc":"",
      "x":100,
      "y":228,
      "wires":[
         [
            "6ce4a581.c8276c"
         ]
      ]
   },
   {
      "id":"6ce4a581.c8276c",
      "type":"function",
      "z":"4bce6f41.15aa4",
      "name":"extract _id",
      "func":"msg._id=msg.payload._id;\nreturn msg;",
      "outputs":1,
      "noerr":0,
      "x":270,
      "y":228,
      "wires":[
         [
            "a7fe436d.21db3"
         ]
      ]
   },
   {
      "id":"a7fe436d.21db3",
      "type":"objectid",
      "z":"4bce6f41.15aa4",
      "name":"",
      "selectedProperty":"",
      "x":440,
      "y":228,
      "wires":[
         [
            "ae850902.ed3288"
         ]
      ]
   },
   {
      "id":"6f0a1064.951f9",
      "type":"http response",
      "z":"4bce6f41.15aa4",
      "name":"",
      "x":850,
      "y":228,
      "wires":[

      ]
   },
   {
      "id":"c0151e06.7b84",
      "type":"function",
      "z":"4bce6f41.15aa4",
      "name":"callback response",
      "func":"msg.payload=msg.req.body;\nreturn msg;",
      "outputs":1,
      "noerr":0,
      "x":510,
      "y":168,
      "wires":[
         [
            "e2529c5e.4214f"
         ]
      ]
   },
   {
      "id":"d03524fd.6a5768",
      "type":"mongodb2 in",
      "z":"4bce6f41.15aa4",
      "service":"_ext_",
      "configNode":"f4f7f112.93cbb",
      "name":"",
      "collection":"myCollection",
      "operation":"update",
      "x":770,
      "y":108,
      "wires":[
         [
            "12320935.f3c367"
         ]
      ]
   },
   {
      "id":"b75256b9.4db9f8",
      "type":"mongodb2 in",
      "z":"4bce6f41.15aa4",
      "service":"_ext_",
      "configNode":"f4f7f112.93cbb",
      "name":"",
      "collection":"MyCollection",
      "operation":"find.toArray",
      "x":310,
      "y":48,
      "wires":[
         [
            "5de742ac.77afbc"
         ]
      ]
   },
   {
      "id":"e867b605.0be758",
      "type":"mongodb2 in",
      "z":"4bce6f41.15aa4",
      "service":"_ext_",
      "configNode":"f4f7f112.93cbb",
      "name":"",
      "collection":"MyCollection",
      "operation":"insert",
      "x":290,
      "y":168,
      "wires":[
         [
            "c0151e06.7b84"
         ]
      ]
   },
   {
      "id":"ae850902.ed3288",
      "type":"mongodb2 in",
      "z":"4bce6f41.15aa4",
      "service":"_ext_",
      "configNode":"f4f7f112.93cbb",
      "name":"",
      "collection":"MyCollection",
      "operation":"deleteOne",
      "x":660,
      "y":228,
      "wires":[
         [
            "6f0a1064.951f9"
         ]
      ]
   },
   {
      "id":"138d34a2.9ee94b",
      "type":"mongodb2 in",
      "z":"4bce6f41.15aa4",
      "service":"_ext_",
      "configNode":"f4f7f112.93cbb",
      "name":"Find number",
      "collection":"MyCollection",
      "operation":"aggregate.forEach",
      "x":580,
      "y":306,
      "wires":[
         [
            "68c55c04.fa9a74"
         ]
      ]
   },
   {
      "id":"68c55c04.fa9a74",
      "type":"function",
      "z":"4bce6f41.15aa4",
      "name":"Name",
      "func":"var temp = msg.payload\nvar name = msg.payload.Name;\nvar surname = msg.payload.Surname\nvar email = msg.payload.Email;\n    msg.to = email\n    msg.topic = \"Temperature Alert\";\n    msg.payload = \"Temperature Alert! \" + name + \" \" + surname + \" Temperature is \" + temp + \" \" + new Date().toString();\nreturn msg;\n",
      "outputs":1,
      "noerr":0,
      "x":772,
      "y":288,
      "wires":[
         [
            "134b76be.5ea1b9"
         ]
      ]
   },
   {
      "id":"917b06b.ab954f8",
      "type":"e-mail",
      "z":"4bce6f41.15aa4",
      "server":"smtp.zoho.com",
      "port":"465",
      "secure":true,
      "name":"",
      "dname":"EmailNotification",
      "x":960,
      "y":288,
      "wires":[

      ]
   },
   {
      "id":"ea49400d.394f5",
      "type":"delay",
      "z":"4bce6f41.15aa4",
      "name":"",
      "pauseType":"rate",
      "timeout":"5",
      "timeoutUnits":"minutes",
      "rate":"1",
      "nbRateUnits":"5",
      "rateUnits":"minute",
      "randomFirst":"1",
      "randomLast":"5",
      "randomUnits":"seconds",
      "drop":true,
      "x":348,
      "y":306,
      "wires":[
         [
            "138d34a2.9ee94b"
         ]
      ]
   },
   {
      "id":"6476872c.cbd3c8",
      "type":"switch",
      "z":"4bce6f41.15aa4",
      "name":"Values",
      "property":"payload",
      "propertyType":"msg",
      "rules":[
         {
            "t":"btwn",
            "v":"-50.000",
            "vt":"num",
            "v2":"2.499",
            "v2t":"num"
         },
         {
            "t":"btwn",
            "v":"7.500",
            "vt":"num",
            "v2":"50",
            "v2t":"num"
         }
      ],
      "checkall":"true",
      "repair":false,
      "outputs":2,
      "x":150,
      "y":304,
      "wires":[
         [
            "ea49400d.394f5"
         ],
         [
            "ea49400d.394f5"
         ]
      ]
   },
   {
      "id":"134b76be.5ea1b9",
      "type":"debug",
      "z":"4bce6f41.15aa4",
      "name":"",
      "active":true,
      "tosidebar":true,
      "console":false,
      "tostatus":false,
      "complete":"false",
      "x":866.5,
      "y":384,
      "wires":[

      ]
   },
   {
      "id":"b8d8657c.bb7a88",
      "type":"inject",
      "z":"4bce6f41.15aa4",
      "name":"",
      "topic":"",
      "payload":"12",
      "payloadType":"num",
      "repeat":"",
      "crontab":"",
      "once":false,
      "onceDelay":0.1,
      "x":92.5,
      "y":369,
      "wires":[
         [
            "6476872c.cbd3c8"
         ]
      ]
   },
   {
      "id":"f4f7f112.93cbb",
      "type":"mongodb2",
      "z":"10319114.3916bf",
      "uri":"mongodb://localhost:27017/crud",
      "name":"crud",
      "options":"",
      "parallelism":"-1"
   }
]

0 个答案:

没有答案