Calienta agua gratis

Calienta agua gratis utilizando tus excedentes fotovoltaicos, o usando la mejor hora con tarifa PVPC

Analizamos el flujo de Node-Red y Home Assistant que nos permite encender el termo eléctrico sólo cuando tenemos excedentes fotovoltaicos suficientes, o bien, aprovechando los momentos del día en los que la tarifa PVPC está más barata.

A continuación te dejo el código del flujo para Node-Red. Que lo disfrutes

[
    {
        "id": "14a0d864f4fa8d8c",
        "type": "tab",
        "label": "Inversor y Termo",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "36a40f0e470ef694",
        "type": "function",
        "z": "14a0d864f4fa8d8c",
        "name": "Excedente",
        "func": "\nmsg.payload = (msg.payload.M_P + Math.abs(msg.payload.M_P))/2;\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 190,
        "y": 700,
        "wires": [
            [
                "c3446655ef8611cd"
            ]
        ]
    },
    {
        "id": "a89bc2c040263fbb",
        "type": "api-call-service",
        "z": "14a0d864f4fa8d8c",
        "name": "Termo ENCENDER",
        "server": "62897e3ae3b61f05",
        "version": 5,
        "debugenabled": true,
        "domain": "switch",
        "service": "turn_on",
        "areaId": [],
        "deviceId": [
            "6d8fd3da48f74347aac0a840bb3f3c17"
        ],
        "entityId": [
            "switch.sonoff_100177d00a"
        ],
        "data": "on",
        "dataType": "jsonata",
        "mergeContext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "queue": "none",
        "x": 1470,
        "y": 920,
        "wires": [
            [
                "9f6e5b554b95f766"
            ]
        ]
    },
    {
        "id": "98bf13afd4dcb598",
        "type": "api-call-service",
        "z": "14a0d864f4fa8d8c",
        "name": "Termo APAGAR",
        "server": "62897e3ae3b61f05",
        "version": 5,
        "debugenabled": true,
        "domain": "switch",
        "service": "turn_off",
        "areaId": [],
        "deviceId": [
            "6d8fd3da48f74347aac0a840bb3f3c17"
        ],
        "entityId": [
            "switch.sonoff_100177d00a"
        ],
        "data": "off",
        "dataType": "jsonata",
        "mergeContext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "queue": "none",
        "x": 1460,
        "y": 760,
        "wires": [
            [
                "047d65f3bf6ddadd"
            ]
        ]
    },
    {
        "id": "c11703b98969e4dd",
        "type": "api-current-state",
        "z": "14a0d864f4fa8d8c",
        "name": "¿Termo encendido?",
        "server": "62897e3ae3b61f05",
        "version": 3,
        "outputs": 2,
        "halt_if": "on",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "entity_id": "switch.sonoff_100177d00a",
        "state_type": "str",
        "blockInputOverrides": false,
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "entityState"
            },
            {
                "property": "data",
                "propertyType": "msg",
                "value": "",
                "valueType": "entity"
            }
        ],
        "for": "0",
        "forType": "num",
        "forUnits": "minutes",
        "override_topic": false,
        "state_location": "payload",
        "override_payload": "msg",
        "entity_location": "data",
        "override_data": "msg",
        "x": 720,
        "y": 760,
        "wires": [
            [
                "14c81c6427929ebd"
            ],
            []
        ]
    },
    {
        "id": "083b1023448c6c6f",
        "type": "api-current-state",
        "z": "14a0d864f4fa8d8c",
        "name": "¿Termo apagado?",
        "server": "62897e3ae3b61f05",
        "version": 3,
        "outputs": 2,
        "halt_if": "off",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "entity_id": "switch.sonoff_100177d00a",
        "state_type": "str",
        "blockInputOverrides": false,
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "entityState"
            },
            {
                "property": "data",
                "propertyType": "msg",
                "value": "",
                "valueType": "entity"
            }
        ],
        "for": "0",
        "forType": "num",
        "forUnits": "minutes",
        "override_topic": false,
        "state_location": "payload",
        "override_payload": "msg",
        "entity_location": "data",
        "override_data": "msg",
        "x": 710,
        "y": 820,
        "wires": [
            [
                "47324c12b334b1e2"
            ],
            []
        ]
    },
    {
        "id": "c3446655ef8611cd",
        "type": "switch",
        "z": "14a0d864f4fa8d8c",
        "name": "¿Tenemos excedentes?",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "lt",
                "v": "1",
                "vt": "str"
            },
            {
                "t": "btwn",
                "v": "1",
                "vt": "num",
                "v2": "1700",
                "v2t": "num"
            },
            {
                "t": "gt",
                "v": "1700",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 3,
        "x": 410,
        "y": 800,
        "wires": [
            [
                "c11703b98969e4dd"
            ],
            [],
            [
                "083b1023448c6c6f"
            ]
        ]
    },
    {
        "id": "47324c12b334b1e2",
        "type": "api-current-state",
        "z": "14a0d864f4fa8d8c",
        "name": "¿Termo automático?",
        "server": "62897e3ae3b61f05",
        "version": 3,
        "outputs": 2,
        "halt_if": "on",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "entity_id": "input_boolean.termo_automatico",
        "state_type": "str",
        "blockInputOverrides": false,
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "entityState"
            },
            {
                "property": "data",
                "propertyType": "msg",
                "value": "",
                "valueType": "entity"
            }
        ],
        "for": "0",
        "forType": "num",
        "forUnits": "minutes",
        "override_topic": false,
        "state_location": "payload",
        "override_payload": "msg",
        "entity_location": "data",
        "override_data": "msg",
        "x": 960,
        "y": 820,
        "wires": [
            [
                "0006d4f3c0130ac5"
            ],
            []
        ]
    },
    {
        "id": "9f6e5b554b95f766",
        "type": "function",
        "z": "14a0d864f4fa8d8c",
        "name": "TermoON",
        "func": "var anterior = flow.get('TermoHora');\nvar d = new Date();\nvar Ahora = d.getTime();\nvar diferencia = Ahora - anterior;\nif (isNaN(anterior)) {\n    diferencia = 0;\n}\nflow.set('TermoHora',Ahora);\nmsg.payload = {\n    TermoON: 1,\n    Tiempo: diferencia\n}\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 1680,
        "y": 920,
        "wires": [
            []
        ]
    },
    {
        "id": "047d65f3bf6ddadd",
        "type": "function",
        "z": "14a0d864f4fa8d8c",
        "name": "TermoOFF",
        "func": "var anterior=flow.get('TermoHora');\nvar d = new Date();\nvar Ahora = d.getTime();\nvar diferencia = Ahora - anterior;\nif (isNaN(anterior)) {\n    diferencia=0;\n}\nflow.set('TermoHora', Ahora);\nmsg.payload = {\n    TermoON: 0,\n    Tiempo: diferencia\n}\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 1670,
        "y": 760,
        "wires": [
            []
        ]
    },
    {
        "id": "14c81c6427929ebd",
        "type": "api-current-state",
        "z": "14a0d864f4fa8d8c",
        "name": "¿Termo automático?",
        "server": "62897e3ae3b61f05",
        "version": 3,
        "outputs": 2,
        "halt_if": "on",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "entity_id": "input_boolean.termo_automatico",
        "state_type": "str",
        "blockInputOverrides": false,
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "entityState"
            },
            {
                "property": "data",
                "propertyType": "msg",
                "value": "",
                "valueType": "entity"
            }
        ],
        "for": "0",
        "forType": "num",
        "forUnits": "minutes",
        "override_topic": false,
        "state_location": "payload",
        "override_payload": "msg",
        "entity_location": "data",
        "override_data": "msg",
        "x": 980,
        "y": 760,
        "wires": [
            [
                "90b58e434e447f5f",
                "67745bb3a089d0e6"
            ],
            []
        ]
    },
    {
        "id": "0006d4f3c0130ac5",
        "type": "api-current-state",
        "z": "14a0d864f4fa8d8c",
        "name": "¿Termperatura excesiva?",
        "server": "62897e3ae3b61f05",
        "version": 3,
        "outputs": 2,
        "halt_if": "on",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "entity_id": "input_boolean.termo_exceso_temperatura",
        "state_type": "str",
        "blockInputOverrides": false,
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "entityState"
            },
            {
                "property": "data",
                "propertyType": "msg",
                "value": "",
                "valueType": "entity"
            }
        ],
        "for": "0",
        "forType": "num",
        "forUnits": "minutes",
        "override_topic": false,
        "state_location": "payload",
        "override_payload": "msg",
        "entity_location": "data",
        "override_data": "msg",
        "x": 1230,
        "y": 920,
        "wires": [
            [],
            [
                "a89bc2c040263fbb"
            ]
        ]
    },
    {
        "id": "88f0fd426318af35",
        "type": "api-current-state",
        "z": "14a0d864f4fa8d8c",
        "name": "Enciende si energía barata",
        "server": "62897e3ae3b61f05",
        "version": 3,
        "outputs": 2,
        "halt_if": "on",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "entity_id": "input_boolean.enciende_si_energia_barata",
        "state_type": "str",
        "blockInputOverrides": false,
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "entityState"
            },
            {
                "property": "data",
                "propertyType": "msg",
                "value": "",
                "valueType": "entity"
            }
        ],
        "for": "0",
        "forType": "num",
        "forUnits": "minutes",
        "override_topic": false,
        "state_location": "payload",
        "override_payload": "msg",
        "entity_location": "data",
        "override_data": "msg",
        "x": 380,
        "y": 1160,
        "wires": [
            [
                "f79c940e3a8fef4a",
                "0e64c3ad333eafc3"
            ],
            []
        ]
    },
    {
        "id": "f79c940e3a8fef4a",
        "type": "api-current-state",
        "z": "14a0d864f4fa8d8c",
        "name": "PVPC",
        "server": "62897e3ae3b61f05",
        "version": 3,
        "outputs": 1,
        "halt_if": "",
        "halt_if_type": "num",
        "halt_if_compare": "lt",
        "entity_id": "sensor.pvpc",
        "state_type": "num",
        "blockInputOverrides": false,
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "entityState"
            },
            {
                "property": "topic",
                "propertyType": "msg",
                "value": "v_pvpc",
                "valueType": "str"
            },
            {
                "property": "v_pvpc",
                "propertyType": "flow",
                "value": "",
                "valueType": "entityState"
            }
        ],
        "for": "0",
        "forType": "num",
        "forUnits": "minutes",
        "override_topic": false,
        "state_location": "payload",
        "override_payload": "msg",
        "entity_location": "data",
        "override_data": "msg",
        "x": 590,
        "y": 1100,
        "wires": [
            [
                "a8502b13bc41dfb8"
            ]
        ]
    },
    {
        "id": "0e64c3ad333eafc3",
        "type": "api-current-state",
        "z": "14a0d864f4fa8d8c",
        "name": "Coste admitible",
        "server": "62897e3ae3b61f05",
        "version": 3,
        "outputs": 1,
        "halt_if": "",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "entity_id": "input_number.coste_maximo_energia_barata",
        "state_type": "num",
        "blockInputOverrides": false,
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "entityState"
            },
            {
                "property": "topic",
                "propertyType": "msg",
                "value": "v_energiabarata",
                "valueType": "str"
            },
            {
                "property": "v_energiabarata",
                "propertyType": "flow",
                "value": "",
                "valueType": "entityState"
            }
        ],
        "for": "0",
        "forType": "num",
        "forUnits": "minutes",
        "override_topic": false,
        "state_location": "payload",
        "override_payload": "msg",
        "entity_location": "data",
        "override_data": "msg",
        "x": 600,
        "y": 1200,
        "wires": [
            [
                "a8502b13bc41dfb8"
            ]
        ]
    },
    {
        "id": "a8502b13bc41dfb8",
        "type": "function",
        "z": "14a0d864f4fa8d8c",
        "name": "Compara",
        "func": "var a = flow.get(\"v_pvpc\");\nvar b = flow.get(\"v_energiabarata\");\n//msg.payload = $number(b)-$number(a);\nif (a<b) {\n    flow.set(\"v_pvpc_barato\",true);\n    msg.payload = true; \n} else {\n    msg.payload = false;\n    flow.set(\"v_pvpc_barato\", false);\n}\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 760,
        "y": 1160,
        "wires": [
            [
                "91ef0e9b800983ed"
            ]
        ]
    },
    {
        "id": "91ef0e9b800983ed",
        "type": "switch",
        "z": "14a0d864f4fa8d8c",
        "name": "¿Está barato el PVPC?",
        "property": "v_pvpc_barato",
        "propertyType": "flow",
        "rules": [
            {
                "t": "true"
            },
            {
                "t": "false"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 990,
        "y": 1160,
        "wires": [
            [
                "083b1023448c6c6f"
            ],
            []
        ]
    },
    {
        "id": "dc13deca481c25de",
        "type": "inject",
        "z": "14a0d864f4fa8d8c",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "*/1 0-23 * * *",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 130,
        "y": 1160,
        "wires": [
            [
                "88f0fd426318af35"
            ]
        ]
    },
    {
        "id": "90b58e434e447f5f",
        "type": "switch",
        "z": "14a0d864f4fa8d8c",
        "name": "¿Está barato el PVPC?",
        "property": "v_pvpc_barato",
        "propertyType": "flow",
        "rules": [
            {
                "t": "true"
            },
            {
                "t": "false"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 1230,
        "y": 760,
        "wires": [
            [],
            [
                "98bf13afd4dcb598"
            ]
        ]
    },
    {
        "id": "53520dc1f782f551",
        "type": "comment",
        "z": "14a0d864f4fa8d8c",
        "name": "Gestiona los Excedentes para Encender o Apagar el Termo",
        "info": "",
        "x": 970,
        "y": 700,
        "wires": []
    },
    {
        "id": "59aa3c6f72216cf9",
        "type": "comment",
        "z": "14a0d864f4fa8d8c",
        "name": "Si la tarifa PVPC está más barata que el umbral marcado, encendemos el termo",
        "info": "",
        "x": 520,
        "y": 1040,
        "wires": []
    },
    {
        "id": "67745bb3a089d0e6",
        "type": "debug",
        "z": "14a0d864f4fa8d8c",
        "name": "debug 1",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 1280,
        "y": 840,
        "wires": []
    },
    {
        "id": "62897e3ae3b61f05",
        "type": "server",
        "name": "Home Assistant Rpi",
        "version": 5,
        "addon": false,
        "rejectUnauthorizedCerts": true,
        "ha_boolean": "y|yes|true|on|home|open",
        "connectionDelay": true,
        "cacheJson": true,
        "heartbeat": false,
        "heartbeatInterval": "30",
        "areaSelector": "friendlyName",
        "deviceSelector": "friendlyName",
        "entitySelector": "friendlyName",
        "statusSeparator": "at: ",
        "statusYear": "hidden",
        "statusMonth": "short",
        "statusDay": "numeric",
        "statusHourCycle": "h23",
        "statusTimeFormat": "h:m",
        "enableGlobalContextStore": true
    }
]
Scroll al inicio