Tarjeta con PVPC y Excedentes para Home Assistant

Con la que está cayendo seguro que te interesa conocer en tiempo real el coste de la energía eléctrica hora a hora. Si encima tienes placas fotovoltaicas, también estarás interesado en saber cuánto te pagan por tus excedentes en cada momento del día.

En este vídeo te explico paso a paso cómo integrar en tu Home Assistant la información hora a hora del PVPC en una tarjeta (crédito para Daniel Martín).

Además añado un procedimiento adicional para descargar automáticamente y publicar una tarjeta igual con el pago por Excedentes.

Es muy útil y espero que te resulte interesante.

A continuación el código JSON para Node-Red

  
[
    {
        "id": "e2842814befe3a1a",
        "type": "tab",
        "label": "Excedentes",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "1abaf17397543814",
        "type": "http request",
        "z": "e2842814befe3a1a",
        "name": "Lectura ESIOS",
        "method": "GET",
        "ret": "obj",
        "paytoqs": "ignore",
        "url": "https://api.esios.ree.es/indicators/1739",
        "tls": "",
        "persist": false,
        "proxy": "",
        "insecureHTTPParser": false,
        "authType": "",
        "senderr": false,
        "headers": [
            {
                "keyType": "other",
                "keyValue": "Accept",
                "valueType": "other",
                "valueValue": "application/json;application/vnd.esios-api-v1+json"
            },
            {
                "keyType": "other",
                "keyValue": "Content-Type",
                "valueType": "other",
                "valueValue": "application/json"
            },
            {
                "keyType": "other",
                "keyValue": "Authorization",
                "valueType": "other",
                "valueValue": "Token token=xxxxx poner aquí el token que te ha enviado REE xxxxxxxxxxxxxxxx"
            }
        ],
        "x": 480,
        "y": 240,
        "wires": [
            [
                "f00377f0c54e8a0d",
                "905eea069b1d4c3d"
            ]
        ]
    },
    {
        "id": "fd2067abfe01c4b0",
        "type": "inject",
        "z": "e2842814befe3a1a",
        "name": "Una vez por minuto",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "60",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 200,
        "y": 120,
        "wires": [
            [
                "98e94d06f15ec81f"
            ]
        ]
    },
    {
        "id": "ecbaf6b48ae5c1b3",
        "type": "change",
        "z": "e2842814befe3a1a",
        "name": "Extrae precios 24h",
        "rules": [
            {
                "t": "set",
                "p": "price_00h",
                "pt": "msg",
                "to": "payload.indicator.values[0].value/1000",
                "tot": "jsonata"
            },
            {
                "t": "set",
                "p": "price_01h",
                "pt": "msg",
                "to": "payload.indicator.values[1].value/1000",
                "tot": "jsonata"
            },
            {
                "t": "set",
                "p": "price_02h",
                "pt": "msg",
                "to": "payload.indicator.values[2].value/1000",
                "tot": "jsonata"
            },
            {
                "t": "set",
                "p": "price_03h",
                "pt": "msg",
                "to": "payload.indicator.values[3].value/1000",
                "tot": "jsonata"
            },
            {
                "t": "set",
                "p": "price_04h",
                "pt": "msg",
                "to": "payload.indicator.values[4].value/1000",
                "tot": "jsonata"
            },
            {
                "t": "set",
                "p": "price_05h",
                "pt": "msg",
                "to": "payload.indicator.values[5].value/1000",
                "tot": "jsonata"
            },
            {
                "t": "set",
                "p": "price_06h",
                "pt": "msg",
                "to": "payload.indicator.values[6].value/1000",
                "tot": "jsonata"
            },
            {
                "t": "set",
                "p": "price_07h",
                "pt": "msg",
                "to": "payload.indicator.values[7].value/1000",
                "tot": "jsonata"
            },
            {
                "t": "set",
                "p": "price_08h",
                "pt": "msg",
                "to": "payload.indicator.values[8].value/1000",
                "tot": "jsonata"
            },
            {
                "t": "set",
                "p": "price_09h",
                "pt": "msg",
                "to": "payload.indicator.values[9].value/1000",
                "tot": "jsonata"
            },
            {
                "t": "set",
                "p": "price_10h",
                "pt": "msg",
                "to": "payload.indicator.values[10].value/1000",
                "tot": "jsonata"
            },
            {
                "t": "set",
                "p": "price_11h",
                "pt": "msg",
                "to": "payload.indicator.values[11].value/1000",
                "tot": "jsonata"
            },
            {
                "t": "set",
                "p": "price_12h",
                "pt": "msg",
                "to": "payload.indicator.values[12].value/1000",
                "tot": "jsonata"
            },
            {
                "t": "set",
                "p": "price_13h",
                "pt": "msg",
                "to": "payload.indicator.values[13].value/1000",
                "tot": "jsonata"
            },
            {
                "t": "set",
                "p": "price_14h",
                "pt": "msg",
                "to": "payload.indicator.values[14].value/1000",
                "tot": "jsonata"
            },
            {
                "t": "set",
                "p": "price_15h",
                "pt": "msg",
                "to": "payload.indicator.values[15].value/1000",
                "tot": "jsonata"
            },
            {
                "t": "set",
                "p": "price_16h",
                "pt": "msg",
                "to": "payload.indicator.values[16].value/1000",
                "tot": "jsonata"
            },
            {
                "t": "set",
                "p": "price_17h",
                "pt": "msg",
                "to": "payload.indicator.values[17].value/1000",
                "tot": "jsonata"
            },
            {
                "t": "set",
                "p": "price_18h",
                "pt": "msg",
                "to": "payload.indicator.values[18].value/1000",
                "tot": "jsonata"
            },
            {
                "t": "set",
                "p": "price_19h",
                "pt": "msg",
                "to": "payload.indicator.values[19].value/1000",
                "tot": "jsonata"
            },
            {
                "t": "set",
                "p": "price_20h",
                "pt": "msg",
                "to": "payload.indicator.values[20].value/1000",
                "tot": "jsonata"
            },
            {
                "t": "set",
                "p": "price_21h",
                "pt": "msg",
                "to": "payload.indicator.values[21].value/1000",
                "tot": "jsonata"
            },
            {
                "t": "set",
                "p": "price_22h",
                "pt": "msg",
                "to": "payload.indicator.values[22].value/1000",
                "tot": "jsonata"
            },
            {
                "t": "set",
                "p": "price_23h",
                "pt": "msg",
                "to": "payload.indicator.values[23].value/1000",
                "tot": "jsonata"
            },
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "actual",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 830,
        "y": 360,
        "wires": [
            [
                "2890f876af5b83de"
            ]
        ]
    },
    {
        "id": "2890f876af5b83de",
        "type": "ha-sensor",
        "z": "e2842814befe3a1a",
        "name": "PVPC Excedentes",
        "entityConfig": "3f2cdc1ff129c29f",
        "version": 0,
        "state": "payload",
        "stateType": "msg",
        "attributes": [
            {
                "property": "price_01h",
                "value": "msg.price_01h",
                "valueType": "jsonata"
            },
            {
                "property": "price_00h",
                "value": "msg.price_00h",
                "valueType": "jsonata"
            },
            {
                "property": "price_02h",
                "value": "msg.price_02h",
                "valueType": "jsonata"
            },
            {
                "property": "price_03h",
                "value": "msg.price_03h",
                "valueType": "jsonata"
            },
            {
                "property": "price_04h",
                "value": "msg.price_04h",
                "valueType": "jsonata"
            },
            {
                "property": "price_05h",
                "value": "msg.price_05h",
                "valueType": "jsonata"
            },
            {
                "property": "price_06h",
                "value": "msg.price_06h",
                "valueType": "jsonata"
            },
            {
                "property": "price_07h",
                "value": "msg.price_07h",
                "valueType": "jsonata"
            },
            {
                "property": "price_08h",
                "value": "msg.price_08h",
                "valueType": "jsonata"
            },
            {
                "property": "price_09h",
                "value": "msg.price_09h",
                "valueType": "jsonata"
            },
            {
                "property": "price_10h",
                "value": "msg.price_10h",
                "valueType": "jsonata"
            },
            {
                "property": "price_11h",
                "value": "msg.price_11h",
                "valueType": "jsonata"
            },
            {
                "property": "price_12h",
                "value": "msg.price_12h",
                "valueType": "jsonata"
            },
            {
                "property": "price_13h",
                "value": "msg.price_13h",
                "valueType": "jsonata"
            },
            {
                "property": "price_14h",
                "value": "msg.price_14h",
                "valueType": "jsonata"
            },
            {
                "property": "price_15h",
                "value": "msg.price_15h",
                "valueType": "jsonata"
            },
            {
                "property": "price_16h",
                "value": "msg.price_16h",
                "valueType": "jsonata"
            },
            {
                "property": "price_17h",
                "value": "msg.price_17h",
                "valueType": "jsonata"
            },
            {
                "property": "price_18h",
                "value": "msg.price_18h",
                "valueType": "jsonata"
            },
            {
                "property": "price_19h",
                "value": "msg.price_19h",
                "valueType": "jsonata"
            },
            {
                "property": "price_20h",
                "value": "msg.price_20h",
                "valueType": "jsonata"
            },
            {
                "property": "price_21h",
                "value": "msg.price_21h",
                "valueType": "jsonata"
            },
            {
                "property": "price_22h",
                "value": "msg.price_22h",
                "valueType": "jsonata"
            },
            {
                "property": "price_23h",
                "value": "msg.price_23h",
                "valueType": "jsonata"
            }
        ],
        "inputOverride": "allow",
        "outputProperties": [],
        "x": 970,
        "y": 420,
        "wires": [
            []
        ]
    },
    {
        "id": "f00377f0c54e8a0d",
        "type": "function",
        "z": "e2842814befe3a1a",
        "name": "Carga precio de la hora actual",
        "func": "msg.actual = msg.payload.indicator.values[flow.get('hora')].value / 1000;\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 650,
        "y": 300,
        "wires": [
            [
                "ecbaf6b48ae5c1b3"
            ]
        ]
    },
    {
        "id": "98e94d06f15ec81f",
        "type": "function",
        "z": "e2842814befe3a1a",
        "name": "Trigger cuando hay cambio de hora",
        "func": "var d = new Date(msg.payload);\nvar hora = d.getHours();\n\nif (d.getMinutes() % 60 == 0) {\n\tflow.set('hora', hora);\n\treturn msg;\n} else\n\treturn null;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 340,
        "y": 180,
        "wires": [
            [
                "1abaf17397543814"
            ]
        ]
    },
    {
        "id": "905eea069b1d4c3d",
        "type": "debug",
        "z": "e2842814befe3a1a",
        "name": "debug 3",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 880,
        "y": 180,
        "wires": []
    },
    {
        "id": "76ae47b8b2f89fb2",
        "type": "comment",
        "z": "e2842814befe3a1a",
        "name": "Pago por los Excedentes",
        "info": "",
        "x": 190,
        "y": 80,
        "wires": []
    },
    {
        "id": "3f2cdc1ff129c29f",
        "type": "ha-entity-config",
        "server": "62897e3ae3b61f05",
        "deviceConfig": "",
        "name": "PVPC Excedentes",
        "version": "6",
        "entityType": "sensor",
        "haConfig": [
            {
                "property": "name",
                "value": "PVPC Excedentes"
            },
            {
                "property": "icon",
                "value": ""
            },
            {
                "property": "entity_category",
                "value": "config"
            },
            {
                "property": "device_class",
                "value": ""
            },
            {
                "property": "unit_of_measurement",
                "value": "EUR/kWh"
            },
            {
                "property": "state_class",
                "value": "measurement"
            }
        ],
        "resend": false,
        "debugEnabled": false
    },
    {
        "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