Skip to content

Instantly share code, notes, and snippets.

@epaulsen
Created March 7, 2023 12:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save epaulsen/ab687c0b084365857f2596977d8f3c67 to your computer and use it in GitHub Desktop.
Save epaulsen/ab687c0b084365857f2596977d8f3c67 to your computer and use it in GitHub Desktop.
Workaround for node-red overwriting linkSource object on linked calls
[
{
"id": "3c403b0fd8ac9f67",
"type": "api-current-state",
"z": "c47a770c26e3be71",
"name": "Get price from Nordpool",
"server": "72b5aa9aa9eb914e",
"version": 3,
"outputs": 1,
"halt_if": "",
"halt_if_type": "str",
"halt_if_compare": "is",
"entity_id": "sensor.nordpool_kwh_krsand_nok_3_095_025",
"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": 310,
"y": 220,
"wires": [
[
"7ac89a363830089e"
]
]
},
{
"id": "7ac89a363830089e",
"type": "ps-receive-price",
"z": "c47a770c26e3be71",
"name": "Price Receiver",
"x": 520,
"y": 220,
"wires": [
[
"26a94237de13f1bf"
]
]
},
{
"id": "26a94237de13f1bf",
"type": "ps-general-add-tariff",
"z": "c47a770c26e3be71",
"name": "Add Agder Energi tariff",
"periods": [
{
"start": "22",
"value": "0,4251"
},
{
"start": "06",
"value": "0,5251"
}
],
"validFrom": "",
"validTo": "",
"days": {
"Mon": true,
"Tue": true,
"Wed": true,
"Thu": true,
"Fri": true,
"Sat": true,
"Sun": true
},
"x": 720,
"y": 220,
"wires": [
[
"a7493a23baefa8bc"
]
]
},
{
"id": "06adaf9b313ede9c",
"type": "link in",
"z": "c47a770c26e3be71",
"name": "Powersaver",
"links": [],
"x": 125,
"y": 220,
"wires": [
[
"3c403b0fd8ac9f67",
"a7e62e72690cdf53"
]
]
},
{
"id": "357f34b69234efb3",
"type": "link out",
"z": "c47a770c26e3be71",
"name": "link out 3",
"mode": "return",
"links": [],
"x": 1305,
"y": 300,
"wires": []
},
{
"id": "7a3b85d3db7bb417",
"type": "inject",
"z": "c47a770c26e3be71",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 240,
"y": 420,
"wires": [
[
"0cfadf7d4646f6b9"
]
]
},
{
"id": "0cfadf7d4646f6b9",
"type": "link call",
"z": "c47a770c26e3be71",
"name": "Call powersaver",
"links": [
"06adaf9b313ede9c"
],
"linkType": "static",
"timeout": "30",
"x": 500,
"y": 420,
"wires": [
[
"7127ef95e7820258"
]
]
},
{
"id": "9a792d2b8381b334",
"type": "join",
"z": "c47a770c26e3be71",
"name": "",
"mode": "custom",
"build": "object",
"property": "payload",
"propertyType": "msg",
"key": "topic",
"joiner": "\\n",
"joinerType": "str",
"accumulate": false,
"timeout": "",
"count": "2",
"reduceRight": false,
"reduceExp": "",
"reduceInit": "",
"reduceInitType": "",
"reduceFixup": "",
"x": 1050,
"y": 300,
"wires": [
[
"9a18394b4398b2ec"
]
]
},
{
"id": "a7e62e72690cdf53",
"type": "function",
"z": "c47a770c26e3be71",
"name": "Topic",
"func": "msg.topic = \"link\";\nmsg.payload = msg._linkSource;\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 250,
"y": 300,
"wires": [
[
"9a792d2b8381b334"
]
]
},
{
"id": "a7493a23baefa8bc",
"type": "function",
"z": "c47a770c26e3be71",
"name": "Topic",
"func": "msg.topic = \"powersaver\";\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 890,
"y": 220,
"wires": [
[
"9a792d2b8381b334"
]
]
},
{
"id": "9a18394b4398b2ec",
"type": "function",
"z": "c47a770c26e3be71",
"name": "Create result",
"func": "msg = {\n \"_linkSource\":msg.payload.link,\n \"payload\": msg.payload.powersaver\n}\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1190,
"y": 300,
"wires": [
[
"357f34b69234efb3"
]
]
},
{
"id": "7127ef95e7820258",
"type": "debug",
"z": "c47a770c26e3be71",
"name": "debug 10",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 720,
"y": 420,
"wires": []
},
{
"id": "72b5aa9aa9eb914e",
"type": "server",
"name": "Home Assistant",
"version": 5,
"addon": false,
"rejectUnauthorizedCerts": true,
"ha_boolean": "y|yes|true|on|home|open",
"connectionDelay": true,
"cacheJson": true,
"heartbeat": true,
"heartbeatInterval": "30",
"areaSelector": "friendlyName",
"deviceSelector": "friendlyName",
"entitySelector": "friendlyName",
"statusSeparator": ": ",
"statusYear": "hidden",
"statusMonth": "short",
"statusDay": "numeric",
"statusHourCycle": "h23",
"statusTimeFormat": "h:m",
"enableGlobalContextStore": true
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment