Unable to patch sellPriceFormulaSchedule

Hi,

Since my energy provider (Zonneplan) uses a different sell-price formula between sunset and sunrise (called ‘zonnebonus’) I’d like to change the array of sellprice formula’s on a daily basis. I’ve built a simpel flow that gets the sunset and sunrise time and then composes a new array for sellPriceFormulaSchedule.

However when patching this array I get a validation_error. Seems like this attribute isn’t writable. Or am I doing something wrong here?

The flow:

Flow JSON:

[
{
“id”: “d7b06853644b688b”,
“type”: “group”,
“z”: “a8478bf151516554”,
“name”: “Change sellPriceFormulaSchedule at 22:00 with sunrise/sunset times”,
“style”: {
“label”: true
},
“nodes”: [
“426f5b74668d1a6b”,
“be370ca5931e2729”,
“37c9a6df5ed98310”,
“e0b6c70677569798”,
“1d4ac16e0acc5e6a”,
“d3af8e4e9f58b438”,
“9054067bab3235a8”,
“fc2ceb969c84db45”,
“b4d4c4526a7c476a”,
“b426b64ab61fe0f7”
],
“x”: 14,
“y”: 59,
“w”: 892,
“h”: 282
},
{
“id”: “426f5b74668d1a6b”,
“type”: “inject”,
“z”: “a8478bf151516554”,
“g”: “d7b06853644b688b”,
“name”: “Daily at 22:00”,
“props”: [
{
“p”: “payload”
},
{
“p”: “topic”,
“vt”: “str”
}
],
“repeat”: “”,
“crontab”: “00 22 * * *”,
“once”: false,
“onceDelay”: 0.1,
“topic”: “”,
“payload”: “”,
“payloadType”: “date”,
“x”: 140,
“y”: 160,
“wires”: [
[
“37c9a6df5ed98310”
]
]
},
{
“id”: “be370ca5931e2729”,
“type”: “debug”,
“z”: “a8478bf151516554”,
“g”: “d7b06853644b688b”,
“name”: “Debug update DESS”,
“active”: true,
“tosidebar”: true,
“console”: false,
“tostatus”: false,
“complete”: “true”,
“targetType”: “full”,
“statusVal”: “”,
“statusType”: “auto”,
“x”: 720,
“y”: 300,
“wires”:
},
{
“id”: “37c9a6df5ed98310”,
“type”: “suncron”,
“z”: “a8478bf151516554”,
“g”: “d7b06853644b688b”,
“name”: “Get Sunrise/Sunset @Hoevelaken”,
“lat”: “52.18079842837667”,
“lon”: “5.470480759104369”,
“replay”: false,
“ejectScheduleOnUpdate”: false,
“sunrisePayload”: “1”,
“sunrisePayloadType”: “num”,
“sunriseTopic”: “sunrise”,
“sunriseOffsetType”: 1,
“sunriseOffsetHours”: 0,
“sunriseOffsetMinutes”: 0,
“sunriseOffset”: 0,
“sunriseEndPayload”: “”,
“sunriseEndPayloadType”: “str”,
“sunriseEndTopic”: “”,
“sunriseEndOffsetType”: 1,
“sunriseEndOffsetHours”: 0,
“sunriseEndOffsetMinutes”: 0,
“sunriseEndOffset”: 0,
“goldenHourEndPayload”: “”,
“goldenHourEndPayloadType”: “str”,
“goldenHourEndTopic”: “”,
“goldenHourEndOffsetType”: 1,
“goldenHourEndOffsetHours”: 0,
“goldenHourEndOffsetMinutes”: 0,
“goldenHourEndOffset”: 0,
“solarNoonPayload”: “”,
“solarNoonPayloadType”: “str”,
“solarNoonTopic”: “”,
“solarNoonOffsetType”: 1,
“solarNoonOffsetHours”: 0,
“solarNoonOffsetMinutes”: 0,
“solarNoonOffset”: 0,
“goldenHourPayload”: “”,
“goldenHourPayloadType”: “str”,
“goldenHourTopic”: “”,
“goldenHourOffsetType”: 1,
“goldenHourOffsetHours”: 0,
“goldenHourOffsetMinutes”: 0,
“goldenHourOffset”: 0,
“sunsetStartPayload”: “”,
“sunsetStartPayloadType”: “str”,
“sunsetStartTopic”: “”,
“sunsetStartOffsetType”: 1,
“sunsetStartOffsetHours”: 0,
“sunsetStartOffsetMinutes”: 0,
“sunsetStartOffset”: 0,
“sunsetPayload”: “1”,
“sunsetPayloadType”: “num”,
“sunsetTopic”: “sunset”,
“sunsetOffsetType”: 1,
“sunsetOffsetHours”: 0,
“sunsetOffsetMinutes”: 0,
“sunsetOffset”: 0,
“duskPayload”: “”,
“duskPayloadType”: “str”,
“duskTopic”: “”,
“duskOffsetType”: 1,
“duskOffsetHours”: 0,
“duskOffsetMinutes”: 0,
“duskOffset”: 0,
“nauticalDuskPayload”: “”,
“nauticalDuskPayloadType”: “str”,
“nauticalDuskTopic”: “”,
“nauticalDuskOffsetType”: 1,
“nauticalDuskOffsetHours”: 0,
“nauticalDuskOffsetMinutes”: 0,
“nauticalDuskOffset”: 0,
“nightPayload”: “”,
“nightPayloadType”: “str”,
“nightTopic”: “”,
“nightOffsetType”: 1,
“nightOffsetHours”: 0,
“nightOffsetMinutes”: 0,
“nightOffset”: 0,
“nadirPayload”: “”,
“nadirPayloadType”: “str”,
“nadirTopic”: “”,
“nadirOffsetType”: 1,
“nadirOffsetHours”: 0,
“nadirOffsetMinutes”: 0,
“nadirOffset”: 0,
“nightEndPayload”: “”,
“nightEndPayloadType”: “str”,
“nightEndTopic”: “”,
“nightEndOffsetType”: 1,
“nightEndOffsetHours”: 0,
“nightEndOffsetMinutes”: 0,
“nightEndOffset”: 0,
“nauticalDawnPayload”: “”,
“nauticalDawnPayloadType”: “str”,
“nauticalDawnTopic”: “”,
“nauticalDawnOffsetType”: 1,
“nauticalDawnOffsetHours”: 0,
“nauticalDawnOffsetMinutes”: 0,
“nauticalDawnOffset”: 0,
“dawnPayload”: “”,
“dawnPayloadType”: “str”,
“dawnTopic”: “”,
“dawnOffsetType”: 1,
“dawnOffsetHours”: 0,
“dawnOffsetMinutes”: 0,
“dawnOffset”: 0,
“x”: 400,
“y”: 160,
“wires”: [
[
“e0b6c70677569798”,
“b426b64ab61fe0f7”
]
]
},
{
“id”: “e0b6c70677569798”,
“type”: “function”,
“z”: “a8478bf151516554”,
“g”: “d7b06853644b688b”,
“name”: “Create new sellPriceFormulaSchedule”,
“func”: “const suncronData = msg;\n\nif (suncronData && suncronData.schedule && suncronData.schedule.sunrise && suncronData.schedule.sunset) {\n const sunriseTime = new Date(suncronData.schedule.sunrise.sunEventTime);\n const sunsetTime = new Date(suncronData.schedule.sunset.sunEventTime);\n\n const newschedule = [ // Creating the inner schedule array directly\n {\n to: sunriseTime.toLocaleTimeString(‘nl-NL’, { hour12: false, hour: ‘2-digit’, minute: ‘2-digit’ }),\n from: “00:00”,\n formula: “(p+0.01653+0.0916)*1.21”\n },\n {\n to: sunsetTime.toLocaleTimeString(‘en-US’, { hour12: false, hour: ‘2-digit’, minute: ‘2-digit’ }),\n from: sunriseTime.toLocaleTimeString(‘nl-NL’, { hour12: false, hour: ‘2-digit’, minute: ‘2-digit’ }),\n formula: “(p+0.01653+0.0916)1.211.1+0.02”\n },\n {\n to: “00:00”, // or “00:00” for the next day\n from: sunsetTime.toLocaleTimeString(‘nl-NL’, { hour12: false, hour: ‘2-digit’, minute: ‘2-digit’ }),\n formula: “(p+0.01653+0.0916)*1.21”\n }\n ];\n\n msg = {‘payload’: {}}; // Important: Clear the entire msg object\n\n msg.payload = {‘sellPriceFormulaSchedule’: JSON.stringify([ // Creating the array with the object inside\n {\n days: [0, 1, 2, 3, 4, 5, 6],\n schedule: newschedule\n }\n ])};\n\n\n} else {\n node.warn(“Invalid or missing suncron data. Check if ‘schedule’, ‘sunrise’, and ‘sunset’ properties exist.”);\n msg.payload = ; // or a default schedule if you have one. Returning an empty array to match expected format.\n}\n\nreturn msg;”,
“outputs”: 1,
“timeout”: 0,
“noerr”: 0,
“initialize”: “”,
“finalize”: “”,
“libs”: ,
“x”: 410,
“y”: 240,
“wires”: [
[
“1d4ac16e0acc5e6a”,
“9054067bab3235a8”
]
]
},
{
“id”: “1d4ac16e0acc5e6a”,
“type”: “vrm-api”,
“z”: “a8478bf151516554”,
“g”: “d7b06853644b688b”,
“vrm”: “4eb658f1d26a4d86”,
“name”: “Update Dynamic ESS configuration”,
“api_type”: “installations”,
“idUser”: “”,
“idSite”: “000000”,
“installations”: “patch-dynamic-ess-settings”,
“attribute”: “”,
“stats_interval”: “”,
“show_instance”: false,
“stats_start”: “”,
“stats_end”: “”,
“use_utc”: false,
“gps_start”: “”,
“gps_end”: “”,
“widgets”: “”,
“instance”: “”,
“store_in_global_context”: true,
“verbose”: true,
“transform_price_schedule”: false,
“outputs”: 1,
“x”: 400,
“y”: 300,
“wires”: [
[
“be370ca5931e2729”
]
]
},
{
“id”: “d3af8e4e9f58b438”,
“type”: “inject”,
“z”: “a8478bf151516554”,
“g”: “d7b06853644b688b”,
“name”: “Manual start”,
“props”: [
{
“p”: “payload”
},
{
“p”: “topic”,
“vt”: “str”
}
],
“repeat”: “”,
“crontab”: “”,
“once”: false,
“onceDelay”: 0.1,
“topic”: “”,
“payload”: “”,
“payloadType”: “date”,
“x”: 130,
“y”: 100,
“wires”: [
[
“37c9a6df5ed98310”,
“fc2ceb969c84db45”
]
]
},
{
“id”: “9054067bab3235a8”,
“type”: “debug”,
“z”: “a8478bf151516554”,
“g”: “d7b06853644b688b”,
“name”: “Debug new schedule”,
“active”: true,
“tosidebar”: true,
“console”: false,
“tostatus”: false,
“complete”: “payload”,
“targetType”: “msg”,
“statusVal”: “”,
“statusType”: “auto”,
“x”: 720,
“y”: 240,
“wires”:
},
{
“id”: “fc2ceb969c84db45”,
“type”: “vrm-api”,
“z”: “a8478bf151516554”,
“g”: “d7b06853644b688b”,
“vrm”: “4eb658f1d26a4d86”,
“name”: “Retrieve DESS Settings”,
“api_type”: “installations”,
“idUser”: “”,
“usersQuery”: “me”,
“idSite”: “000000”,
“installations”: “dynamic-ess-settings”,
“attribute”: “”,
“stats_interval”: “”,
“show_instance”: false,
“stats_start”: “”,
“stats_end”: “”,
“use_utc”: false,
“gps_start”: “”,
“gps_end”: “”,
“widgets”: “”,
“instance”: “”,
“store_in_global_context”: true,
“verbose”: true,
“transform_price_schedule”: false,
“outputs”: 1,
“x”: 370,
“y”: 100,
“wires”: [
[
“b4d4c4526a7c476a”
]
]
},
{
“id”: “b4d4c4526a7c476a”,
“type”: “debug”,
“z”: “a8478bf151516554”,
“g”: “d7b06853644b688b”,
“name”: “Debug read DESS Settings”,
“active”: true,
“tosidebar”: true,
“console”: false,
“tostatus”: false,
“complete”: “payload”,
“targetType”: “msg”,
“statusVal”: “”,
“statusType”: “auto”,
“x”: 740,
“y”: 100,
“wires”:
},
{
“id”: “b426b64ab61fe0f7”,
“type”: “debug”,
“z”: “a8478bf151516554”,
“g”: “d7b06853644b688b”,
“name”: “Debug suncron”,
“active”: true,
“tosidebar”: true,
“console”: false,
“tostatus”: false,
“complete”: “payload”,
“targetType”: “msg”,
“statusVal”: “”,
“statusType”: “auto”,
“x”: 700,
“y”: 160,
“wires”:
},
{
“id”: “4eb658f1d26a4d86”,
“type”: “config-vrm-api”,
“name”: “VRM”,
“forceIpv4”: true
},
{
“id”: “24190ac8f03c676d”,
“type”: “global-config”,
“env”: ,
“modules”: {
“node-red-contrib-suncron”: “1.6.9”,
“victron-vrm-api”: “0.3.11”
}
}
]

And the formatted sellPriceFormulaSchedule:

[{"days":[0,1,2,3,4,5,6],"schedule":[{"to":"05:21","from":"00:00","formula":"(p+0.01653+0.0916)*1.21"},{"to":"18:06","from":"05:21","formula":"(p+0.01653+0.0916)*1.21*1.1+0.02"},{"to":"00:00","from":"18:06","formula":"(p+0.01653+0.0916)*1.21"}]}]

Hoping that I can make this work for a long as selling is opportunistic in the Netherlands…