diff --git a/node-red_flow.json b/node-red_flow.json index debea1d..03332d1 100644 --- a/node-red_flow.json +++ b/node-red_flow.json @@ -25,8 +25,8 @@ "name": "batt_temp", "onlyChanges": true, "roundValues": "0", - "x": 380, - "y": 380, + "x": 80, + "y": 200, "wires": [ [ "7e04d0fa828e9868" @@ -46,8 +46,8 @@ "targetType": "msg", "statusVal": "", "statusType": "auto", - "x": 1040, - "y": 220, + "x": 740, + "y": 40, "wires": [] }, { @@ -68,8 +68,8 @@ "name": "pv_power", "onlyChanges": true, "roundValues": "0", - "x": 380, - "y": 440, + "x": 80, + "y": 260, "wires": [ [ "7e04d0fa828e9868" @@ -80,10 +80,10 @@ "id": "de555a35fee6404c", "type": "ui-switch", "z": "cf255672ab90a22f", - "name": "heater_switch", + "name": "heater_on", "label": "Calefacción", "group": "aa9cdf043b4ff6f3", - "order": 0, + "order": 1, "width": 0, "height": 0, "passthru": false, @@ -92,8 +92,8 @@ "topicType": "msg", "style": "", "className": "", - "layout": "row-left-swapped", - "clickableArea": "switch", + "layout": "row-spread", + "clickableArea": "none", "onvalue": "true", "onvalueType": "bool", "onicon": "", @@ -102,8 +102,8 @@ "offvalueType": "bool", "officon": "", "offcolor": "", - "x": 1220, - "y": 360, + "x": 940, + "y": 160, "wires": [ [] ] @@ -112,7 +112,7 @@ "id": "fb3c661bf8c01d98", "type": "shelly-gen2", "z": "cf255672ab90a22f", - "hostname": "10.0.1.11", + "hostname": "172.24.24.2", "description": "shelly", "mode": "callback", "verbose": false, @@ -126,8 +126,8 @@ "devicetypemustmatchexactly": false, "captureblutooth": false, "outputs": 1, - "x": 810, - "y": 660, + "x": 490, + "y": 520, "wires": [ [ "bd1f36a1d9afba8d" @@ -151,8 +151,8 @@ "drop": true, "allowrate": false, "outputs": 1, - "x": 610, - "y": 340, + "x": 310, + "y": 160, "wires": [ [ "4f2f81e6c9c20a90" @@ -177,8 +177,8 @@ "name": "batt_power", "onlyChanges": true, "roundValues": "0", - "x": 380, - "y": 320, + "x": 80, + "y": 140, "wires": [ [ "7e04d0fa828e9868" @@ -197,11 +197,12 @@ "initialize": "", "finalize": "", "libs": [], - "x": 700, - "y": 500, + "x": 280, + "y": 360, "wires": [ [ - "4f2f81e6c9c20a90" + "4f2f81e6c9c20a90", + "0f85c811db6b90cb" ] ] }, @@ -210,15 +211,15 @@ "type": "function", "z": "cf255672ab90a22f", "name": "heater_switch_manager", - "func": "context.set(msg.topic, msg.payload)\n\nlet batt_temp = context.get(\"batt_temp\")\nlet batt_power = context.get(\"batt_power\")\nlet batt_soc = context.get(\"batt_soc\")\nlet box_temp = context.get(\"box_temp\")\nlet room_temp = context.get(\"room_temp\")\nlet pv_power = context.get(\"pv_power\")\nlet relay = context.get(\"relay\")\n\nlet log = \"\"\nfor (const key of context.keys()) {\n log += key + \"=\" + context.get(key) + \" \"\n}\nnode.warn(log)\n\n// Si estamos iniciando y faltan datos apagar el radiador.\nif (batt_temp == undefined || batt_power == undefined || box_temp == undefined\n || room_temp == undefined || pv_power == undefined) {\n node.warn(\"INITIALIZING\")\n msg.payload = false\n return msg;\n}\n\n// Si la temperatura ambiente o de la batería es alta apagar el radiador.\nif (batt_temp > 20 || room_temp > 20) {\n msg.payload = false\n return msg;\n}\n\n// Si la temperatura del sarcofago es baja desmarcar que se ha llegado al límite.\nif (box_temp < 15) {\n context.set(\"box_temp_upper_limit_reached\", false)\n}\n// Si la temperatura del sarcofago es alta marcar que se ha llegado al límite.\nelse if (box_temp > 25) {\n context.set(\"box_temp_upper_limit_reached\", true)\n}\n\n// Si se ha llegado al límite superior de temperatura del sarcófago apagar el\n// radiador, hay que esperar a cruzar el límite inferior.\nif (context.get(\"box_temp_upper_limit_reached\")) {\n msg.payload = false\n return msg;\n}\n\n// Encender el radiador si la potencia de carga es alta teniendo en cuenta el SOC.\nif ((pv_power > 700 && batt_soc > 50) || (pv_power > 300 && batt_soc > 70) ||\n (pv_power > 200 && batt_soc > 90)) {\n msg.payload = true\n return msg;\n}\n\n// Encender el radiador si la potencia de carga está limitada por la temperatura\n// de la batería.\nif ((pv_power > 1200 && batt_temp < 8) || (pv_power > 2500 && batt_temp < 16)) {\n msg.payload = true\n return msg;\n}\n\n// La batería debe estar por encima de 5º, a menos que el SOC sea menor que 50%.\nif (batt_temp < 5 && batt_soc > 50) {\n msg.payload = true\n return msg;\n}\n\n// En el resto de casos apagamos el radiador.\nmsg.payload = false\nreturn msg;\n", + "func": "context.set(msg.topic, msg.payload)\n\nlet batt_temp = context.get(\"batt_temp\")\nlet batt_power = context.get(\"batt_power\")\nlet batt_soc = context.get(\"batt_soc\")\nlet box_temp = context.get(\"box_temp\")\nlet room_temp = context.get(\"room_temp\")\nlet pv_power = context.get(\"pv_power\")\nlet relay = context.get(\"relay\")\nlet force_heater = context.get(\"force_heater\")\n\nlet log = \"\"\nfor (const key of context.keys()) {\n log += key + \"=\" + context.get(key) + \" \"\n}\n//node.warn(log)\n\n// Si estamos iniciando y faltan datos apagar el radiador.\nif (batt_temp == undefined || batt_power == undefined || box_temp == undefined\n || room_temp == undefined || pv_power == undefined) {\n node.warn(\"INITIALIZING\")\n msg.payload = false\n return msg;\n}\n\n// Si la temperatura ambiente o de la batería es alta apagar el radiador.\nif (batt_temp > 20 || room_temp > 20) {\n msg.payload = false\n return msg;\n}\n\n// Si la temperatura del sarcofago es baja desmarcar que se ha llegado al límite.\nif (box_temp < 15) {\n context.set(\"box_temp_upper_limit_reached\", false)\n}\n// Si la temperatura del sarcofago es alta marcar que se ha llegado al límite.\nelse if (box_temp > 25) {\n context.set(\"box_temp_upper_limit_reached\", true)\n}\n\n// Si se ha llegado al límite superior de temperatura del sarcófago apagar el\n// radiador, hay que esperar a cruzar el límite inferior.\nif (context.get(\"box_temp_upper_limit_reached\")) {\n msg.payload = false\n return msg;\n}\n\n// Comprobar si se ha pedido explicitamente encender la calefacción.\nif (context.get(\"force_heater\")) {\n msg.payload = true\n return msg;\n}\n\n// Encender el radiador si la potencia de carga es alta teniendo en cuenta el SOC.\nif ((pv_power > 700 && batt_soc > 50) || (pv_power > 300 && batt_soc > 70) ||\n (pv_power > 200 && batt_soc > 90)) {\n msg.payload = true\n return msg;\n}\n\n// Encender el radiador si la potencia de carga está limitada por la temperatura\n// de la batería.\nif ((pv_power > 1200 && batt_temp < 8) || (pv_power > 2500 && batt_temp < 16)) {\n msg.payload = true\n return msg;\n}\n\n// Encender el radiador si la batería está fría y hay suficiente SOC.\nif ((batt_temp < 5 && batt_soc > 50) || (batt_temp < 6 && batt_soc > 60) ||\n (batt_temp < 8 && batt_soc > 70) || (batt_temp < 12 && batt_soc > 80) ||\n (batt_temp < 16 && batt_soc > 90)) {\n msg.payload = true\n return msg;\n}\n\n// En el resto de casos apagamos el radiador.\nmsg.payload = false\nreturn msg;\n", "outputs": 1, "timeout": 0, "noerr": 0, "initialize": "", "finalize": "", "libs": [], - "x": 850, - "y": 340, + "x": 550, + "y": 160, "wires": [ [ "cd1a8c477cfe992a", @@ -238,8 +239,8 @@ "initialize": "", "finalize": "", "libs": [], - "x": 1170, - "y": 460, + "x": 970, + "y": 380, "wires": [ [ "fb3c661bf8c01d98" @@ -250,7 +251,7 @@ "id": "cd1a8c477cfe992a", "type": "rbe", "z": "cf255672ab90a22f", - "name": "", + "name": "filter equal", "func": "rbe", "gap": "", "start": "", @@ -258,8 +259,8 @@ "septopics": false, "property": "payload", "topi": "topic", - "x": 1050, - "y": 340, + "x": 770, + "y": 160, "wires": [ [ "de555a35fee6404c", @@ -280,8 +281,8 @@ "complete": "false", "statusVal": "", "statusType": "auto", - "x": 1220, - "y": 300, + "x": 940, + "y": 100, "wires": [] }, { @@ -302,14 +303,129 @@ "name": "batt_soc", "onlyChanges": true, "roundValues": "0", - "x": 380, - "y": 260, + "x": 80, + "y": 80, "wires": [ [ "7e04d0fa828e9868" ] ] }, + { + "id": "0f85c811db6b90cb", + "type": "switch", + "z": "cf255672ab90a22f", + "name": "", + "property": "topic", + "propertyType": "msg", + "rules": [ + { + "t": "eq", + "v": "box_temp", + "vt": "str" + }, + { + "t": "eq", + "v": "room_temp", + "vt": "str" + } + ], + "checkall": "true", + "repair": false, + "outputs": 2, + "x": 530, + "y": 360, + "wires": [ + [ + "9593b9b734c4e4f9" + ], + [ + "62d7f8dd71fa7b38" + ] + ] + }, + { + "id": "9593b9b734c4e4f9", + "type": "ui-text", + "z": "cf255672ab90a22f", + "group": "aa9cdf043b4ff6f3", + "order": 3, + "width": 0, + "height": 0, + "name": "box_temp", + "label": "Sarcófago", + "format": "{{msg.payload}}", + "layout": "row-spread", + "style": false, + "font": "", + "fontSize": 16, + "color": "#717171", + "wrapText": false, + "className": "", + "value": "payload", + "valueType": "msg", + "x": 680, + "y": 340, + "wires": [] + }, + { + "id": "62d7f8dd71fa7b38", + "type": "ui-text", + "z": "cf255672ab90a22f", + "group": "aa9cdf043b4ff6f3", + "order": 4, + "width": 0, + "height": 0, + "name": "room_text", + "label": "Habitación", + "format": "{{msg.payload}}", + "layout": "row-spread", + "style": false, + "font": "", + "fontSize": 16, + "color": "#717171", + "wrapText": false, + "className": "", + "value": "payload", + "valueType": "msg", + "x": 680, + "y": 380, + "wires": [] + }, + { + "id": "91d7f7d3a52c6875", + "type": "ui-switch", + "z": "cf255672ab90a22f", + "name": "force_heater", + "label": "Forzar calefacción", + "group": "aa9cdf043b4ff6f3", + "order": 2, + "width": 0, + "height": 0, + "passthru": false, + "decouple": false, + "topic": "force_heater", + "topicType": "str", + "style": "", + "className": "", + "layout": "row-spread", + "clickableArea": "switch", + "onvalue": "true", + "onvalueType": "bool", + "onicon": "", + "oncolor": "", + "offvalue": "false", + "offvalueType": "bool", + "officon": "", + "offcolor": "", + "x": 310, + "y": 100, + "wires": [ + [ + "4f2f81e6c9c20a90" + ] + ] + }, { "id": "aa9cdf043b4ff6f3", "type": "ui-group", @@ -318,7 +434,7 @@ "width": "6", "height": "1", "order": 1, - "showTitle": true, + "showTitle": false, "className": "", "visible": "true", "disabled": "false", @@ -333,32 +449,32 @@ { "id": "545b3851d8568f59", "type": "ui-page", - "name": "Page 1", + "name": "Calefacción", "ui": "cf2bb7479e560f99", - "path": "/page1", + "path": "/heater", "icon": "home", "layout": "grid", "theme": "43a2d84f031e3dc7", "breakpoints": [ { "name": "Default", - "px": 0, - "cols": 3 + "px": "0", + "cols": "3" }, { "name": "Tablet", - "px": 576, - "cols": 6 + "px": "576", + "cols": "6" }, { "name": "Small Desktop", - "px": 768, - "cols": 9 + "px": "768", + "cols": "9" }, { "name": "Desktop", - "px": 1024, - "cols": 12 + "px": "1024", + "cols": "12" } ], "order": 1,