节点红色智能恒温器

时间:2019-04-10 19:41:22

标签: javascript node-red

我需要有关Node Red(在Raspberry Pi上)的增量的帮助。我正在尝试制作一个带有LCD触摸屏和用于远程访问的应用程序的智能恒温器(例如,在一个寒冷的冬天回家,想开始为您的公寓供暖)。 我们将不胜感激有关如何通过android(不是本地网络)通过Internet(而不是本地网络)连接到Raspberry Pi的一些建议以及教程或示例中的链接。

P.S。我正在为一个朋友做这个,我向他保证会取得好成绩。 抱歉,代码混乱... =>在编辑中将其清除


由于我对NodeRed和JS的经验不足,我已经尽一切努力使代码正常工作。

全局变量可能就可以解决问题...我还没有弄清楚...

我遇到的另一个障碍是能否访问本地网络之外的代码并与之交互。


[
{
    "id": "9f63513b.e227a",
    "type": "ui_slider",
    "z": "f216bae9.be3b68",
    "name": "",
    "label": "",
    "group": "b344cd03.40f29",
    "order": 2,
    "width": "0",
    "height": "0",
    "passthru": true,
    "topic": "slide",
    "min": "10",
    "max": "45",
    "step": 1,
    "x": 650,
    "y": 140,
    "wires": [
        [
            "4e35591.c5466a8",
            "ef681f9b.17845"
        ]
    ]
},
{
    "id": "4e35591.c5466a8",
    "type": "delay",
    "z": "f216bae9.be3b68",
    "name": "Buffer",
    "pauseType": "queue",
    "timeout": "5",
    "timeoutUnits": "seconds",
    "rate": "1",
    "nbRateUnits": "1",
    "rateUnits": "second",
    "randomFirst": "1",
    "randomLast": "5",
    "randomUnits": "seconds",
    "drop": true,
    "x": 810,
    "y": 60,
    "wires": [
        [
            "eec05221.3091e"
        ]
    ]
},
{
    "id": "82848cf2.b33d1",
    "type": "function",
    "z": "f216bae9.be3b68",
    "name": "delete payload",
    "func": "msg.buton = msg.payload;\ndelete msg.payload;\nmsg.incalzire=msg.buton;\nreturn msg;",
    "outputs": 1,
    "noerr": 0,
    "x": 480,
    "y": 240,
    "wires": [
        [
            "9f63513b.e227a"
        ]
    ]
},
{
    "id": "ef681f9b.17845",
    "type": "ui_gauge",
    "z": "f216bae9.be3b68",
    "name": "",
    "group": "b344cd03.40f29",
    "order": 1,
    "width": 0,
    "height": 0,
    "gtype": "gage",
    "title": "",
    "label": "",
    "format": "{{value}}",
    "min": "0",
    "max": "60",
    "colors": [
        "#00b500",
        "#e6e600",
        "#ca3838"
    ],
    "seg1": "",
    "seg2": "",
    "x": 810,
    "y": 220,
    "wires": []
},
{
    "id": "eec05221.3091e",
    "type": "function",
    "z": "f216bae9.be3b68",
    "name": "delete payload",
    "func": "msg.tempslide=msg.payload;\ndelete msg.payload;\n\nreturn msg;",
    "outputs": 1,
    "noerr": 0,
    "x": 1000,
    "y": 60,
    "wires": [
        [
            "f5853672.5fe148"
        ]
    ]
},
{
    "id": "6b57c137.8c136",
    "type": "function",
    "z": "f216bae9.be3b68",
    "name": "Switch",
    "func": "if(msg.payload===0){\n    msg.payload=1;\n}\nelse if (msg.payload==1){\n    msg.payload=0;\n}\nreturn msg;",
    "outputs": 1,
    "noerr": 0,
    "x": 310,
    "y": 460,
    "wires": [
        [
            "82848cf2.b33d1"
        ]
    ]
},
{
    "id": "f5853672.5fe148",
    "type": "function",
    "z": "f216bae9.be3b68",
    "name": "working mess",
    "func": "if (msg.incalzire===0||msg.payload===0){\n\nif (msg.temp<=msg.tempslide){\n    msg.payload=0;\n}\n\nelse if (msg.temp>msg.tempslide){\n    msg.payload=1;\n}\n\nelse{\n    msg.payload=1;}\n    \n}\n\n\nelse{\n    msg.payload=1;\n    \n}\n\n\n\n\nreturn msg;",
    "outputs": 1,
    "noerr": 0,
    "x": 1058,
    "y": 140,
    "wires": [
        [
            "3f6977e5.b44158",
            "ee3a7840.808ad8",
            "7726596c.b74228"
        ]
    ]
},
{
    "id": "d34a3234.79712",
    "type": "ui_switch",
    "z": "f216bae9.be3b68",
    "name": "",
    "label": "Override Window",
    "group": "b344cd03.40f29",
    "order": 4,
    "width": 0,
    "height": 0,
    "passthru": true,
    "decouple": "false",
    "topic": "",
    "style": "",
    "onvalue": "1",
    "onvalueType": "num",
    "onicon": "",
    "oncolor": "",
    "offvalue": "0",
    "offvalueType": "num",
    "officon": "",
    "offcolor": "",
    "x": 250,
    "y": 420,
    "wires": [
        [
            "6b57c137.8c136"
        ]
    ]
},
{
    "id": "3f6977e5.b44158",
    "type": "debug",
    "z": "f216bae9.be3b68",
    "name": "",
    "active": false,
    "tosidebar": true,
    "console": false,
    "tostatus": false,
    "complete": "true",
    "x": 1293,
    "y": 140,
    "wires": []
},
{
    "id": "ee3a7840.808ad8",
    "type": "function",
    "z": "f216bae9.be3b68",
    "name": "Message",
    "func": "if(msg.payload===0){\n    msg.payload='PORNITA'; //ON\n}\nelse if (msg.payload==1){\n    msg.payload='OPRITA'; //OFF\n}\nreturn msg;",
    "outputs": 1,
    "noerr": 0,
    "x": 1183,
    "y": 340,
    "wires": [
        [
            "eaeac5fb.c27728"
        ]
    ]
},
{
    "id": "7726596c.b74228",
    "type": "rpi-gpio out",
    "z": "f216bae9.be3b68",
    "name": "Rel1",
    "pin": "22",
    "set": "",
    "level": "0",
    "freq": "",
    "out": "out",
    "x": 1233,
    "y": 220,
    "wires": []
},
{
    "id": "c0784b3b.c1fcb8",
    "type": "function",
    "z": "f216bae9.be3b68",
    "name": "Switch",
    "func": "if(msg.payload===0){\n    msg.payload=1;\n}\nelse if (msg.payload==1){\n    msg.payload=0;\n}\nreturn msg;",
    "outputs": 1,
    "noerr": 0,
    "x": 250,
    "y": 380,
    "wires": [
        [
            "d34a3234.79712"
        ]
    ]
},
{
    "id": "eaeac5fb.c27728",
    "type": "ui_text",
    "z": "f216bae9.be3b68",
    "group": "b344cd03.40f29",
    "order": 3,
    "width": 0,
    "height": 0,
    "name": "",
    "label": "Incalzirea este",
    "format": "{{msg.payload}}",
    "layout": "row-right",
    "x": 1220,
    "y": 380,
    "wires": []
},
{
    "id": "248c4825.00c018",
    "type": "rpi-gpio in",
    "z": "f216bae9.be3b68",
    "name": "",
    "pin": "40",
    "intype": "tri",
    "debounce": "25",
    "read": false,
    "x": 90,
    "y": 300,
    "wires": [
        [
            "c0784b3b.c1fcb8"
        ]
    ]
},
{
    "id": "afb8009a.49841",
    "type": "function",
    "z": "f216bae9.be3b68",
    "name": "delete payload",
    "func": "//nu umbla la asta\nmsg.temp=msg.payload;\ndelete msg.payload;\nreturn msg;",
    "outputs": 1,
    "noerr": 0,
    "x": 320,
    "y": 140,
    "wires": [
        [
            "c0784b3b.c1fcb8"
        ]
    ]
},
{
    "id": "c696dbbc.58ee98",
    "type": "rpi-dht22",
    "z": "f216bae9.be3b68",
    "name": "",
    "topic": "Interior",
    "dht": "22",
    "pintype": "1",
    "pin": "29",
    "x": 140,
    "y": 180,
    "wires": [
        [
            "afb8009a.49841",
            "33ec6fb6.fda7f"
        ]
    ]
},
{
    "id": "33ec6fb6.fda7f",
    "type": "ui_gauge",
    "z": "f216bae9.be3b68",
    "name": "",
    "group": "d2bfb34b.1c943",
    "order": 1,
    "width": 0,
    "height": 0,
    "gtype": "gage",
    "title": "",
    "label": "° C",
    "format": "{{value}}",
    "min": 0,
    "max": "60",
    "colors": [
        "#00b500",
        "#e6e600",
        "#ca3838"
    ],
    "seg1": "",
    "seg2": "",
    "x": 150,
    "y": 220,
    "wires": []
},
{
    "id": "d3a6bff.b99a44",
    "type": "inject",
    "z": "f216bae9.be3b68",
    "name": "",
    "topic": "",
    "payload": "",
    "payloadType": "date",
    "repeat": "50",
    "crontab": "",
    "once": false,
    "onceDelay": 0.1,
    "x": 110,
    "y": 120,
    "wires": [
        [
            "c696dbbc.58ee98"
        ]
    ]
},
{
    "id": "b344cd03.40f29",
    "type": "ui_group",
    "z": "",
    "name": "Reglarea Incalzirii",
    "tab": "af80de11.bfd15",
    "order": 2,
    "disp": true,
    "width": "6",
    "collapse": true
},
{
    "id": "d2bfb34b.1c943",
    "type": "ui_group",
    "z": "",
    "name": "Temperatura Curenta",
    "tab": "af80de11.bfd15",
    "order": 1,
    "disp": true,
    "width": "6",
    "collapse": true
},
{
    "id": "af80de11.bfd15",
    "type": "ui_tab",
    "z": "",
    "name": "Sergiu",
    "icon": "fa-thermometer-full",
    "order": 4
}

]


旧的恒温器基本上是一个自动继电器开关。我必须使其聪明,最好的选择是覆盆子pi。

增量部分可以代替滑块(我有备份),并且必须由仪表板UI中的按钮触发。

我提到的

以外的所有内容 正确

谢谢您的帮助!(或至少是您的时间)

0 个答案:

没有答案