Skip to content

Instantly share code, notes, and snippets.

@dirkjanfaber
Last active March 13, 2024 09:03
Show Gist options
  • Save dirkjanfaber/5720d358a5d701ba3fc7ed1cdfea2a8d to your computer and use it in GitHub Desktop.
Save dirkjanfaber/5720d358a5d701ba3fc7ed1cdfea2a8d to your computer and use it in GitHub Desktop.
Buy or sell, based on time of day (Node-RED)
[
{
"id": "31b15ddbce69ea1f",
"type": "tab",
"label": "Remco Schilder",
"disabled": false,
"info": "",
"env": []
},
{
"id": "b8caee9c72378399",
"type": "group",
"z": "31b15ddbce69ea1f",
"name": "Mode: Automatic (time based)",
"style": {
"label": true
},
"nodes": [
"ea9f4a0f374a4285",
"5c40dd87a052ce26",
"5ecbae8881c5205c",
"c812c05d2d0a9540"
],
"x": 504,
"y": 339,
"w": 452,
"h": 122
},
{
"id": "e0e6197d2e62dcdf",
"type": "group",
"z": "31b15ddbce69ea1f",
"name": "Mode: manual",
"style": {
"label": true
},
"nodes": [
"ac25685677cb8022",
"553fd8a13049d9a9",
"38e8b9119f692b2c",
"a9aa7442a9aa8402"
],
"x": 74,
"y": 339,
"w": 412,
"h": 122
},
{
"id": "6b96b04acdc987ae",
"type": "group",
"z": "31b15ddbce69ea1f",
"name": "Sell",
"style": {
"label": true
},
"nodes": [
"b775a050385cd3ef",
"cd74798006e99881",
"2c82277076046e80",
"3a6f903dce06fd8a"
],
"x": 64,
"y": 479,
"w": 882,
"h": 122
},
{
"id": "3d7bd1d8fa983fa0",
"type": "group",
"z": "31b15ddbce69ea1f",
"name": "Buy",
"style": {
"label": true
},
"nodes": [
"d57eab2683011034",
"3e911eb53f5d5ae4",
"cb8a09a481ef87de",
"c489b466df063db6"
],
"x": 64,
"y": 619,
"w": 882,
"h": 122
},
{
"id": "d5a4f8187e16f87c",
"type": "group",
"z": "31b15ddbce69ea1f",
"name": "Determine action periodically",
"style": {
"label": true
},
"nodes": [
"48083bcfac3fa286",
"90053ca90db28936",
"7e573f435c1ce925",
"1241749889a9fcd5",
"41e4d79b99734f0f"
],
"x": 74,
"y": 199,
"w": 872,
"h": 122
},
{
"id": "a15695d5d3111545",
"type": "group",
"z": "31b15ddbce69ea1f",
"name": "Controls",
"style": {
"label": true
},
"nodes": [
"33690b75ab4a0bb6",
"06715550aef65871",
"78ab3e82bb8902b8",
"bb9ca8110c7b3c54",
"88945141e6db0f61",
"a443c045933045c5",
"9ef95cfed13ef728",
"df828d4d9ded61df",
"380123a00e09c648",
"fbdb6876839c8f80",
"3c6c74af33750248",
"72dc92095e8c7f23"
],
"x": 74,
"y": 19,
"w": 882,
"h": 162
},
{
"id": "48083bcfac3fa286",
"type": "inject",
"z": "31b15ddbce69ea1f",
"g": "d5a4f8187e16f87c",
"name": "Output every minute",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "60",
"crontab": "",
"once": true,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 220,
"y": 240,
"wires": [
[
"90053ca90db28936"
]
]
},
{
"id": "ea9f4a0f374a4285",
"type": "time-range-switch",
"z": "31b15ddbce69ea1f",
"g": "b8caee9c72378399",
"name": "Switch between 08:00 and 20:00",
"lat": "",
"lon": "",
"startTime": "08:00",
"endTime": "20:00",
"startOffset": 0,
"endOffset": 0,
"x": 720,
"y": 400,
"wires": [
[
"5c40dd87a052ce26"
],
[
"5ecbae8881c5205c"
]
]
},
{
"id": "5c40dd87a052ce26",
"type": "link out",
"z": "31b15ddbce69ea1f",
"g": "b8caee9c72378399",
"name": "link out 1",
"mode": "link",
"links": [
"cd74798006e99881",
"40efd6651dc81e2b"
],
"x": 915,
"y": 380,
"wires": []
},
{
"id": "5ecbae8881c5205c",
"type": "link out",
"z": "31b15ddbce69ea1f",
"g": "b8caee9c72378399",
"name": "link out 2",
"mode": "link",
"links": [
"6363f2604c436f3f",
"c489b466df063db6"
],
"x": 915,
"y": 420,
"wires": []
},
{
"id": "b775a050385cd3ef",
"type": "victron-output-relay",
"z": "31b15ddbce69ea1f",
"g": "6b96b04acdc987ae",
"service": "com.victronenergy.system/0",
"path": "/Relay/1/State",
"serviceObj": {
"service": "com.victronenergy.system/0",
"name": "Venus device"
},
"pathObj": {
"path": "/Relay/1/State",
"type": "enum",
"name": "Venus relay 2 state",
"enum": {
"0": "Open",
"1": "Closed"
},
"writable": true
},
"initial": "",
"name": "",
"onlyChanges": false,
"x": 780,
"y": 520,
"wires": []
},
{
"id": "cd74798006e99881",
"type": "link in",
"z": "31b15ddbce69ea1f",
"g": "6b96b04acdc987ae",
"name": "link in 1",
"links": [
"5c40dd87a052ce26",
"553fd8a13049d9a9"
],
"x": 105,
"y": 520,
"wires": [
[
"2c82277076046e80",
"3a6f903dce06fd8a"
]
]
},
{
"id": "2c82277076046e80",
"type": "change",
"z": "31b15ddbce69ea1f",
"g": "6b96b04acdc987ae",
"name": "Open relay",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "0",
"tot": "num"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 250,
"y": 520,
"wires": [
[
"b775a050385cd3ef"
]
]
},
{
"id": "d57eab2683011034",
"type": "change",
"z": "31b15ddbce69ea1f",
"g": "3d7bd1d8fa983fa0",
"name": "Close relay",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "1",
"tot": "num"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 250,
"y": 660,
"wires": [
[
"b775a050385cd3ef"
]
]
},
{
"id": "3e911eb53f5d5ae4",
"type": "change",
"z": "31b15ddbce69ea1f",
"g": "3d7bd1d8fa983fa0",
"name": "Grid setpoint 10000 (buy)",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "10000",
"tot": "num"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 290,
"y": 700,
"wires": [
[
"cb8a09a481ef87de"
]
]
},
{
"id": "3a6f903dce06fd8a",
"type": "change",
"z": "31b15ddbce69ea1f",
"g": "6b96b04acdc987ae",
"name": "Grid setpoint -10000 (sell)",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "-10000",
"tot": "num"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 290,
"y": 560,
"wires": [
[
"cb8a09a481ef87de"
]
]
},
{
"id": "cb8a09a481ef87de",
"type": "victron-output-ess",
"z": "31b15ddbce69ea1f",
"g": "3d7bd1d8fa983fa0",
"service": "com.victronenergy.settings",
"path": "/Settings/CGwacs/AcPowerSetPoint",
"serviceObj": {
"service": "com.victronenergy.settings",
"name": "Venus settings"
},
"pathObj": {
"path": "/Settings/CGwacs/AcPowerSetPoint",
"type": "integer",
"name": "Grid set-point (W)",
"writable": true
},
"name": "",
"onlyChanges": false,
"x": 780,
"y": 700,
"wires": []
},
{
"id": "c489b466df063db6",
"type": "link in",
"z": "31b15ddbce69ea1f",
"g": "3d7bd1d8fa983fa0",
"name": "link in 3",
"links": [
"5ecbae8881c5205c",
"a9aa7442a9aa8402"
],
"x": 105,
"y": 660,
"wires": [
[
"3e911eb53f5d5ae4",
"d57eab2683011034"
]
]
},
{
"id": "90053ca90db28936",
"type": "switch",
"z": "31b15ddbce69ea1f",
"g": "d5a4f8187e16f87c",
"name": "Manual or automatic",
"property": "mode",
"propertyType": "flow",
"rules": [
{
"t": "eq",
"v": "manual",
"vt": "str"
},
{
"t": "eq",
"v": "automatic",
"vt": "str"
},
{
"t": "else"
}
],
"checkall": "true",
"repair": false,
"outputs": 3,
"x": 560,
"y": 260,
"wires": [
[
"1241749889a9fcd5"
],
[
"7e573f435c1ce925"
],
[
"7e573f435c1ce925"
]
]
},
{
"id": "33690b75ab4a0bb6",
"type": "inject",
"z": "31b15ddbce69ea1f",
"g": "a15695d5d3111545",
"name": "Set mode: manual",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "manual",
"payloadType": "str",
"x": 210,
"y": 60,
"wires": [
[
"78ab3e82bb8902b8"
]
]
},
{
"id": "c812c05d2d0a9540",
"type": "link in",
"z": "31b15ddbce69ea1f",
"g": "b8caee9c72378399",
"name": "link in 5",
"links": [
"7e573f435c1ce925"
],
"x": 545,
"y": 400,
"wires": [
[
"ea9f4a0f374a4285"
]
]
},
{
"id": "7e573f435c1ce925",
"type": "link out",
"z": "31b15ddbce69ea1f",
"g": "d5a4f8187e16f87c",
"name": "link out 3",
"mode": "link",
"links": [
"c812c05d2d0a9540"
],
"x": 905,
"y": 280,
"wires": []
},
{
"id": "06715550aef65871",
"type": "inject",
"z": "31b15ddbce69ea1f",
"g": "a15695d5d3111545",
"name": "Set mode: automatic",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": true,
"onceDelay": 0.1,
"topic": "",
"payload": "automatic",
"payloadType": "str",
"x": 220,
"y": 100,
"wires": [
[
"78ab3e82bb8902b8"
]
]
},
{
"id": "78ab3e82bb8902b8",
"type": "change",
"z": "31b15ddbce69ea1f",
"g": "a15695d5d3111545",
"name": "Store mode",
"rules": [
{
"t": "set",
"p": "mode",
"pt": "flow",
"to": "payload",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 430,
"y": 60,
"wires": [
[
"3c6c74af33750248"
]
]
},
{
"id": "bb9ca8110c7b3c54",
"type": "inject",
"z": "31b15ddbce69ea1f",
"g": "a15695d5d3111545",
"name": "Set action: buy",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": true,
"onceDelay": 0.1,
"topic": "",
"payload": "buy",
"payloadType": "str",
"x": 660,
"y": 60,
"wires": [
[
"a443c045933045c5"
]
]
},
{
"id": "88945141e6db0f61",
"type": "inject",
"z": "31b15ddbce69ea1f",
"g": "a15695d5d3111545",
"name": "Set action: sell",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "sell",
"payloadType": "str",
"x": 660,
"y": 100,
"wires": [
[
"a443c045933045c5"
]
]
},
{
"id": "1241749889a9fcd5",
"type": "link out",
"z": "31b15ddbce69ea1f",
"g": "d5a4f8187e16f87c",
"name": "link out 4",
"mode": "link",
"links": [
"ac25685677cb8022"
],
"x": 905,
"y": 240,
"wires": []
},
{
"id": "ac25685677cb8022",
"type": "link in",
"z": "31b15ddbce69ea1f",
"g": "e0e6197d2e62dcdf",
"name": "link in 6",
"links": [
"1241749889a9fcd5"
],
"x": 115,
"y": 400,
"wires": [
[
"38e8b9119f692b2c"
]
]
},
{
"id": "553fd8a13049d9a9",
"type": "link out",
"z": "31b15ddbce69ea1f",
"g": "e0e6197d2e62dcdf",
"name": "",
"mode": "link",
"links": [
"cd74798006e99881"
],
"x": 445,
"y": 380,
"wires": []
},
{
"id": "38e8b9119f692b2c",
"type": "switch",
"z": "31b15ddbce69ea1f",
"g": "e0e6197d2e62dcdf",
"name": "Check action: buy or sell",
"property": "action",
"propertyType": "flow",
"rules": [
{
"t": "eq",
"v": "sell",
"vt": "str"
},
{
"t": "eq",
"v": "buy",
"vt": "str"
},
{
"t": "else"
}
],
"checkall": "true",
"repair": false,
"outputs": 3,
"x": 260,
"y": 400,
"wires": [
[
"553fd8a13049d9a9"
],
[
"a9aa7442a9aa8402"
],
[
"a9aa7442a9aa8402"
]
]
},
{
"id": "a9aa7442a9aa8402",
"type": "link out",
"z": "31b15ddbce69ea1f",
"g": "e0e6197d2e62dcdf",
"name": "",
"mode": "link",
"links": [
"c489b466df063db6"
],
"x": 445,
"y": 420,
"wires": []
},
{
"id": "a443c045933045c5",
"type": "change",
"z": "31b15ddbce69ea1f",
"g": "a15695d5d3111545",
"name": "Store action",
"rules": [
{
"t": "set",
"p": "action",
"pt": "flow",
"to": "payload",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 850,
"y": 60,
"wires": [
[
"72dc92095e8c7f23"
]
]
},
{
"id": "9ef95cfed13ef728",
"type": "ui-switch",
"z": "31b15ddbce69ea1f",
"g": "a15695d5d3111545",
"name": "Automatic / Manual",
"label": "Automatic / Manual",
"group": "3269a45549b9a377",
"order": 0,
"width": 0,
"height": 0,
"passthru": false,
"topic": "topic",
"topicType": "msg",
"style": "",
"className": "",
"onvalue": "true",
"onvalueType": "bool",
"onicon": "",
"oncolor": "",
"offvalue": "false",
"offvalueType": "bool",
"officon": "",
"offcolor": "",
"x": 190,
"y": 140,
"wires": [
[
"380123a00e09c648"
]
]
},
{
"id": "df828d4d9ded61df",
"type": "ui-switch",
"z": "31b15ddbce69ea1f",
"g": "a15695d5d3111545",
"name": "Buy / Sell",
"label": "Buy / Sell",
"group": "3269a45549b9a377",
"order": 0,
"width": 0,
"height": 0,
"passthru": false,
"topic": "topic",
"topicType": "msg",
"style": "",
"className": "",
"onvalue": "true",
"onvalueType": "bool",
"onicon": "",
"oncolor": "",
"offvalue": "false",
"offvalueType": "bool",
"officon": "",
"offcolor": "",
"x": 620,
"y": 140,
"wires": [
[
"fbdb6876839c8f80"
]
]
},
{
"id": "380123a00e09c648",
"type": "change",
"z": "31b15ddbce69ea1f",
"g": "a15695d5d3111545",
"name": "",
"rules": [
{
"t": "change",
"p": "payload",
"pt": "msg",
"from": "true",
"fromt": "bool",
"to": "manual",
"tot": "str"
},
{
"t": "change",
"p": "payload",
"pt": "msg",
"from": "false",
"fromt": "bool",
"to": "automatic",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 380,
"y": 140,
"wires": [
[
"78ab3e82bb8902b8"
]
]
},
{
"id": "fbdb6876839c8f80",
"type": "change",
"z": "31b15ddbce69ea1f",
"g": "a15695d5d3111545",
"name": "",
"rules": [
{
"t": "change",
"p": "payload",
"pt": "msg",
"from": "true",
"fromt": "bool",
"to": "sell",
"tot": "str"
},
{
"t": "change",
"p": "payload",
"pt": "msg",
"from": "false",
"fromt": "bool",
"to": "buy",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 780,
"y": 140,
"wires": [
[
"a443c045933045c5"
]
]
},
{
"id": "3c6c74af33750248",
"type": "link out",
"z": "31b15ddbce69ea1f",
"g": "a15695d5d3111545",
"name": "link out 5",
"mode": "link",
"links": [
"41e4d79b99734f0f"
],
"x": 515,
"y": 140,
"wires": []
},
{
"id": "72dc92095e8c7f23",
"type": "link out",
"z": "31b15ddbce69ea1f",
"g": "a15695d5d3111545",
"name": "link out 6",
"mode": "link",
"links": [
"41e4d79b99734f0f"
],
"x": 915,
"y": 140,
"wires": []
},
{
"id": "41e4d79b99734f0f",
"type": "link in",
"z": "31b15ddbce69ea1f",
"g": "d5a4f8187e16f87c",
"name": "link in 7",
"links": [
"3c6c74af33750248",
"72dc92095e8c7f23"
],
"x": 305,
"y": 280,
"wires": [
[
"90053ca90db28936"
]
]
},
{
"id": "3269a45549b9a377",
"type": "ui-group",
"name": "Buy or Sell",
"page": "7b07ed59e4ed9176",
"width": "6",
"height": "1",
"order": -1,
"showTitle": true,
"className": "",
"visible": "true",
"disabled": "false"
},
{
"id": "7b07ed59e4ed9176",
"type": "ui-page",
"name": "Page Name",
"ui": "606cf3b748fd6e55",
"path": "/solar",
"icon": "home",
"layout": "grid",
"theme": "00cf73885e05e57a",
"order": -1,
"className": "",
"visible": "true",
"disabled": "false"
},
{
"id": "606cf3b748fd6e55",
"type": "ui-base",
"name": "UI Name",
"path": "/dashboard",
"includeClientData": true,
"acceptsClientConfig": [
"ui-notification",
"ui-control"
],
"showPathInSidebar": false
},
{
"id": "00cf73885e05e57a",
"type": "ui-theme",
"name": "Theme Name",
"colors": {
"surface": "#ffffff",
"primary": "#0094ce",
"bgPage": "#eeeeee",
"groupBg": "#ffffff",
"groupOutline": "#cccccc"
},
"sizes": {
"pagePadding": "12px",
"groupGap": "12px",
"groupBorderRadius": "4px",
"widgetGap": "12px"
}
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment