Created
September 30, 2022 13:44
-
-
Save eperdeme/7b8f7a7640c49c317c9b60a0efec161f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [ | |
| { | |
| "id": "4df1db11.780364", | |
| "type": "tab", | |
| "label": "Energy Money Maker", | |
| "disabled": false, | |
| "info": "" | |
| }, | |
| { | |
| "id": "f5bdf687714d6141", | |
| "type": "poll-state", | |
| "z": "4df1db11.780364", | |
| "name": "", | |
| "server": "187a6c3d.d3c2d4", | |
| "version": 2, | |
| "exposeToHomeAssistant": false, | |
| "haConfig": [ | |
| { | |
| "property": "name", | |
| "value": "" | |
| }, | |
| { | |
| "property": "icon", | |
| "value": "" | |
| } | |
| ], | |
| "updateinterval": "60", | |
| "updateIntervalType": "num", | |
| "updateIntervalUnits": "seconds", | |
| "outputinitially": false, | |
| "outputonchanged": false, | |
| "entity_id": "sensor.lux_battery", | |
| "state_type": "str", | |
| "halt_if": "", | |
| "halt_if_type": "str", | |
| "halt_if_compare": "is", | |
| "outputs": 1, | |
| "x": 160, | |
| "y": 980, | |
| "wires": [ | |
| [ | |
| "15048535f316c11b" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "f11cf36bdef4f272", | |
| "type": "poll-state", | |
| "z": "4df1db11.780364", | |
| "name": "", | |
| "server": "187a6c3d.d3c2d4", | |
| "version": 2, | |
| "exposeToHomeAssistant": false, | |
| "haConfig": [ | |
| { | |
| "property": "name", | |
| "value": "" | |
| }, | |
| { | |
| "property": "icon", | |
| "value": "" | |
| } | |
| ], | |
| "updateinterval": "60", | |
| "updateIntervalType": "num", | |
| "updateIntervalUnits": "seconds", | |
| "outputinitially": false, | |
| "outputonchanged": false, | |
| "entity_id": "sensor.lux_solar_output_live", | |
| "state_type": "str", | |
| "halt_if": "", | |
| "halt_if_type": "str", | |
| "halt_if_compare": "is", | |
| "outputs": 1, | |
| "x": 190, | |
| "y": 920, | |
| "wires": [ | |
| [ | |
| "5ac77cb89ed6e34b" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "b464693b0c8b1648", | |
| "type": "json", | |
| "z": "4df1db11.780364", | |
| "name": "", | |
| "property": "payload", | |
| "action": "obj", | |
| "pretty": false, | |
| "x": 330, | |
| "y": 460, | |
| "wires": [ | |
| [ | |
| "8312b081ad2085a1" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "6bfc14a675048687", | |
| "type": "split", | |
| "z": "4df1db11.780364", | |
| "name": "", | |
| "splt": "\\n", | |
| "spltType": "str", | |
| "arraySplt": 1, | |
| "arraySpltType": "len", | |
| "stream": false, | |
| "addname": "", | |
| "x": 630, | |
| "y": 460, | |
| "wires": [ | |
| [ | |
| "39703ead5f24fe70", | |
| "ce86bbd024e6a3bb" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "8312b081ad2085a1", | |
| "type": "change", | |
| "z": "4df1db11.780364", | |
| "name": "Results", | |
| "rules": [ | |
| { | |
| "t": "set", | |
| "p": "payload", | |
| "pt": "msg", | |
| "to": "payload.results", | |
| "tot": "msg" | |
| } | |
| ], | |
| "action": "", | |
| "property": "", | |
| "from": "", | |
| "to": "", | |
| "reg": false, | |
| "x": 480, | |
| "y": 460, | |
| "wires": [ | |
| [ | |
| "6bfc14a675048687" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "20e01cbccc29636f", | |
| "type": "http request", | |
| "z": "4df1db11.780364", | |
| "name": "Octopus Agile Rates", | |
| "method": "GET", | |
| "ret": "obj", | |
| "paytoqs": "ignore", | |
| "url": "https://api.octopus.energy/v1/products/AGILE-OUTGOING-19-05-13/electricity-tariffs/E-1R-AGILE-OUTGOING-19-05-13-M/standard-unit-rates/?period_from={{{payload.start_time}}}&period_to={{{payload.end_time}}}", | |
| "tls": "", | |
| "persist": true, | |
| "proxy": "", | |
| "insecureHTTPParser": false, | |
| "authType": "", | |
| "senderr": false, | |
| "headers": [], | |
| "x": 160, | |
| "y": 460, | |
| "wires": [ | |
| [ | |
| "b464693b0c8b1648" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "39703ead5f24fe70", | |
| "type": "debug", | |
| "z": "4df1db11.780364", | |
| "name": "debug 5", | |
| "active": false, | |
| "tosidebar": true, | |
| "console": false, | |
| "tostatus": false, | |
| "complete": "false", | |
| "statusVal": "", | |
| "statusType": "auto", | |
| "x": 800, | |
| "y": 460, | |
| "wires": [] | |
| }, | |
| { | |
| "id": "bbbfa0b4baec5206", | |
| "type": "inject", | |
| "z": "4df1db11.780364", | |
| "name": "Number of 30min slots", | |
| "props": [ | |
| { | |
| "p": "payload" | |
| }, | |
| { | |
| "p": "slots", | |
| "v": "4", | |
| "vt": "str" | |
| } | |
| ], | |
| "repeat": "10800", | |
| "crontab": "", | |
| "once": true, | |
| "onceDelay": 0.1, | |
| "topic": "", | |
| "payload": "", | |
| "payloadType": "date", | |
| "x": 170, | |
| "y": 280, | |
| "wires": [ | |
| [ | |
| "4afc10faddd06111", | |
| "9290d10bebfc59fe" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "821918e6473e24ab", | |
| "type": "debug", | |
| "z": "4df1db11.780364", | |
| "name": "debug 6", | |
| "active": false, | |
| "tosidebar": true, | |
| "console": false, | |
| "tostatus": false, | |
| "complete": "true", | |
| "targetType": "full", | |
| "statusVal": "", | |
| "statusType": "auto", | |
| "x": 800, | |
| "y": 280, | |
| "wires": [] | |
| }, | |
| { | |
| "id": "4afc10faddd06111", | |
| "type": "change", | |
| "z": "4df1db11.780364", | |
| "name": "start", | |
| "rules": [ | |
| { | |
| "t": "set", | |
| "p": "payload", | |
| "pt": "msg", | |
| "to": "$moment().startOf('day').utc().format(\"YYYY-MM-DD HH:mm:ss\")", | |
| "tot": "jsonata" | |
| }, | |
| { | |
| "t": "set", | |
| "p": "topic", | |
| "pt": "msg", | |
| "to": "start_time", | |
| "tot": "str" | |
| } | |
| ], | |
| "action": "", | |
| "property": "", | |
| "from": "", | |
| "to": "", | |
| "reg": false, | |
| "x": 470, | |
| "y": 240, | |
| "wires": [ | |
| [ | |
| "6da85929d12ba3e9" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "9290d10bebfc59fe", | |
| "type": "change", | |
| "z": "4df1db11.780364", | |
| "name": "end", | |
| "rules": [ | |
| { | |
| "t": "set", | |
| "p": "payload", | |
| "pt": "msg", | |
| "to": "$moment().endOf('day').utc().format(\"YYYY-MM-DD HH:mm:ss\")", | |
| "tot": "jsonata" | |
| }, | |
| { | |
| "t": "set", | |
| "p": "topic", | |
| "pt": "msg", | |
| "to": "end_time", | |
| "tot": "str" | |
| } | |
| ], | |
| "action": "", | |
| "property": "", | |
| "from": "", | |
| "to": "", | |
| "reg": false, | |
| "x": 470, | |
| "y": 320, | |
| "wires": [ | |
| [ | |
| "6da85929d12ba3e9" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "6da85929d12ba3e9", | |
| "type": "join", | |
| "z": "4df1db11.780364", | |
| "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": 630, | |
| "y": 280, | |
| "wires": [ | |
| [ | |
| "821918e6473e24ab", | |
| "20e01cbccc29636f" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "ce86bbd024e6a3bb", | |
| "type": "batch", | |
| "z": "4df1db11.780364", | |
| "name": "Batch 1 period", | |
| "mode": "count", | |
| "count": "1", | |
| "overlap": "0", | |
| "interval": 10, | |
| "allowEmptySequence": false, | |
| "topics": [], | |
| "x": 140, | |
| "y": 540, | |
| "wires": [ | |
| [ | |
| "1a82e1fec541e4a3" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "1a82e1fec541e4a3", | |
| "type": "join", | |
| "z": "4df1db11.780364", | |
| "name": "", | |
| "mode": "auto", | |
| "build": "string", | |
| "property": "payload", | |
| "propertyType": "msg", | |
| "key": "topic", | |
| "joiner": "\\n", | |
| "joinerType": "str", | |
| "accumulate": false, | |
| "timeout": "", | |
| "count": "", | |
| "reduceRight": false, | |
| "reduceExp": "", | |
| "reduceInit": "", | |
| "reduceInitType": "", | |
| "reduceFixup": "", | |
| "x": 310, | |
| "y": 540, | |
| "wires": [ | |
| [ | |
| "6aa5ad71b0b9e210" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "6aa5ad71b0b9e210", | |
| "type": "function", | |
| "z": "4df1db11.780364", | |
| "name": "Cost for batch", | |
| "func": "function addValue(arr) {\n let add = 0;\n for (let ele of arr) {\n add = add + ele.value_inc_vat;\n }\n return add;\n}\n\nmsg.value_batch = addValue(msg.payload);\n\nreturn msg;", | |
| "outputs": 1, | |
| "noerr": 0, | |
| "x": 480, | |
| "y": 540, | |
| "wires": [ | |
| [ | |
| "cac1c4c3c669eec4" | |
| ] | |
| ], | |
| "info": "Calculate the energy cost for the period" | |
| }, | |
| { | |
| "id": "cac1c4c3c669eec4", | |
| "type": "change", | |
| "z": "4df1db11.780364", | |
| "name": "Transform", | |
| "rules": [ | |
| { | |
| "t": "set", | |
| "p": "topic", | |
| "pt": "msg", | |
| "to": "payload[0].valid_from", | |
| "tot": "msg" | |
| }, | |
| { | |
| "t": "set", | |
| "p": "pay.start", | |
| "pt": "msg", | |
| "to": "payload[0].valid_from", | |
| "tot": "msg" | |
| }, | |
| { | |
| "t": "set", | |
| "p": "pay.time_end", | |
| "pt": "msg", | |
| "to": "payload[0].valid_to", | |
| "tot": "msg" | |
| }, | |
| { | |
| "t": "move", | |
| "p": "value_batch", | |
| "pt": "msg", | |
| "to": "pay.value", | |
| "tot": "msg" | |
| }, | |
| { | |
| "t": "set", | |
| "p": "payload", | |
| "pt": "msg", | |
| "to": "pay.value", | |
| "tot": "msg" | |
| } | |
| ], | |
| "action": "", | |
| "property": "", | |
| "from": "", | |
| "to": "", | |
| "reg": false, | |
| "x": 120, | |
| "y": 600, | |
| "wires": [ | |
| [ | |
| "bb915f5745aa2253" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "2f3888aa6c790442", | |
| "type": "join", | |
| "z": "4df1db11.780364", | |
| "name": "Create Array", | |
| "mode": "custom", | |
| "build": "array", | |
| "property": "pay", | |
| "propertyType": "msg", | |
| "key": "topic", | |
| "joiner": "\\n", | |
| "joinerType": "str", | |
| "accumulate": false, | |
| "timeout": "2", | |
| "count": "", | |
| "reduceRight": false, | |
| "reduceExp": "", | |
| "reduceInit": "", | |
| "reduceInitType": "", | |
| "reduceFixup": "", | |
| "x": 490, | |
| "y": 600, | |
| "wires": [ | |
| [ | |
| "7672379d2b7152a9" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "7672379d2b7152a9", | |
| "type": "function", | |
| "z": "4df1db11.780364", | |
| "name": "Best_Slots", | |
| "func": "if (msg.slots > msg.pay.length) {\n msg.slots = msg.pay.length;\n}\n\nconst cycle = msg.slots;\n\n//msg.outcome = msg.pay.sort((a,b) => a.value - b.value);\nmsg.outcome = msg.pay.sort((a, b) => b.value - a.value);\n\n\nfor (let c = 0; c < cycle ; c++) {\n // var payload = { \"topic\": \"Highest-\" + c, \"price\": msg.outcome[c] }\n //var payload = { \"command\": \"add\", \"name\": \"Test\", \"topic\": \"Inject time\", \"expression\": \"2022-05-14 12:23 GMT+1\", \"payload\": \"GO\", \"type\": \"default\", \"limit\": 0 }\n\n\n msg.payload = [\n {\n \"command\": \"add\",\n \"name\": \"Highest-start\" + c,\n \"topic\": \"Highest-\" + c,\n \"expression\": msg.outcome[c].start,\n \"expressionType\": \"dates\",\n \"payloadType\": \"str\",\n \"payload\": \"GO\"\n },\n {\n \"command\": \"add\",\n \"name\": \"Highest-stop\" + c,\n \"topic\": \"Highest -\" + c,\n \"expression\": msg.outcome[c].time_end,\n \"expressionType\": \"dates\",\n \"payloadType\": \"str\",\n \"payload\": \"STOP\"\n },\n ]\n // return msg;\n\n node.send(msg);\n}\n\n\n// {\"command\":\"add\",\"name\":\"Test\",\"topic\":\"Inject time\",\"expression\":\"2022-05-14 12:23 GMT+1\",\"payload\":\"GO\",\"type\":\"default\",\"limit\":0}", | |
| "outputs": 1, | |
| "noerr": 0, | |
| "initialize": "", | |
| "finalize": "", | |
| "libs": [], | |
| "x": 650, | |
| "y": 600, | |
| "wires": [ | |
| [ | |
| "f8432354ba12b84c", | |
| "0a378adac03a8038" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "f8432354ba12b84c", | |
| "type": "debug", | |
| "z": "4df1db11.780364", | |
| "name": "debug 16", | |
| "active": false, | |
| "tosidebar": true, | |
| "console": false, | |
| "tostatus": false, | |
| "complete": "true", | |
| "targetType": "full", | |
| "statusVal": "", | |
| "statusType": "auto", | |
| "x": 800, | |
| "y": 540, | |
| "wires": [] | |
| }, | |
| { | |
| "id": "0a378adac03a8038", | |
| "type": "cronplus", | |
| "z": "4df1db11.780364", | |
| "name": "Top Electric prices", | |
| "outputField": "payload", | |
| "timeZone": "", | |
| "persistDynamic": false, | |
| "commandResponseMsgOutput": "output1", | |
| "outputs": 1, | |
| "options": [], | |
| "x": 150, | |
| "y": 680, | |
| "wires": [ | |
| [ | |
| "964019a3d3137e7e" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "0be1cbf14506fb73", | |
| "type": "debug", | |
| "z": "4df1db11.780364", | |
| "name": "debug 18", | |
| "active": true, | |
| "tosidebar": true, | |
| "console": false, | |
| "tostatus": false, | |
| "complete": "true", | |
| "targetType": "full", | |
| "statusVal": "", | |
| "statusType": "auto", | |
| "x": 900, | |
| "y": 940, | |
| "wires": [] | |
| }, | |
| { | |
| "id": "15048535f316c11b", | |
| "type": "function", | |
| "z": "4df1db11.780364", | |
| "name": "batData", | |
| "func": "flow.set(\"batteryState\",msg.payload);\nreturn msg;", | |
| "outputs": 1, | |
| "noerr": 0, | |
| "initialize": "", | |
| "finalize": "", | |
| "libs": [], | |
| "x": 420, | |
| "y": 980, | |
| "wires": [ | |
| [ | |
| "36c381e6d01b5572" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "5ac77cb89ed6e34b", | |
| "type": "function", | |
| "z": "4df1db11.780364", | |
| "name": "pvData", | |
| "func": "flow.set(\"pvState\",msg.payload);\nreturn msg;\n", | |
| "outputs": 1, | |
| "noerr": 0, | |
| "initialize": "", | |
| "finalize": "", | |
| "libs": [], | |
| "x": 420, | |
| "y": 920, | |
| "wires": [ | |
| [ | |
| "36c381e6d01b5572" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "36c381e6d01b5572", | |
| "type": "function", | |
| "z": "4df1db11.780364", | |
| "name": "DischargeController", | |
| "func": "var pvPower=flow.get(\"pvState\");\nvar battery=flow.get(\"batteryState\");\nvar feed=flow.get(\"feedin\");\nvar timeNow=flow.get(\"time\");\nvar OACurrentRate = flow.get(\"OACurrentRate\");\nvar MoneyMaker=flow.get(\"MoneyMaker\");\n\nvar inverter_max_output_ac = 5000\nvar inverter_max_output_dc = 7000\nvar invetrer_max_output_pv = 6500\n\n// Logic is;\n// Solars not saturating the inverter.\n// Battery is not below discharge thesholds.\n// We'll make profit.\n\nif (pvPower > inverter_max_output_ac ) {\n msg.text = \"PV export saturating at \" + pvPower + \" watts\";\n msg.extra = { \"MoneyMaker\": MoneyMaker,\"OACurrentRate\": OACurrentRate, \"battery\": battery }\n msg.payload = \"Stop\";\n return msg;\n//} else if (OACurrentRate > '40' && battery > 20 ) {\n} else if (OACurrentRate > '40' && battery > 20 && MoneyMaker == \"Go\") {\n msg.text = \"Top exporter time, more than 40p, battery more than 20%\"\n msg.extra = { \"MoneyMaker\": MoneyMaker, \"OACurrentRate\": OACurrentRate, \"battery\": battery}\n msg.payload = \"Go\";\n return msg;\n} else {\n msg.text = \"Unnown catchall\"\n msg.extra = { \"MoneyMaker\": MoneyMaker,\"OACurrentRate\": OACurrentRate, \"battery\": battery}\n msg.payload = \"Stop\";\n return msg\n}", | |
| "outputs": 1, | |
| "noerr": 0, | |
| "initialize": "", | |
| "finalize": "", | |
| "libs": [], | |
| "x": 640, | |
| "y": 940, | |
| "wires": [ | |
| [ | |
| "0be1cbf14506fb73", | |
| "f9ca7289354cecf1" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "aa603537f5629357", | |
| "type": "function", | |
| "z": "4df1db11.780364", | |
| "name": "time", | |
| "func": "flow.set(\"time\", Number(msg.payload));\nreturn msg;\n", | |
| "outputs": 1, | |
| "noerr": 0, | |
| "initialize": "", | |
| "finalize": "", | |
| "libs": [], | |
| "x": 430, | |
| "y": 860, | |
| "wires": [ | |
| [ | |
| "36c381e6d01b5572" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "1fbbbf9231b42a61", | |
| "type": "inject", | |
| "z": "4df1db11.780364", | |
| "name": "", | |
| "props": [ | |
| { | |
| "p": "payload" | |
| }, | |
| { | |
| "p": "topic", | |
| "vt": "str" | |
| } | |
| ], | |
| "repeat": "60", | |
| "crontab": "", | |
| "once": true, | |
| "onceDelay": 0.1, | |
| "topic": "", | |
| "payload": "", | |
| "payloadType": "date", | |
| "x": 130, | |
| "y": 860, | |
| "wires": [ | |
| [ | |
| "03abf485c2cf77c1" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "03abf485c2cf77c1", | |
| "type": "moment", | |
| "z": "4df1db11.780364", | |
| "name": "Time", | |
| "topic": "", | |
| "input": "", | |
| "inputType": "msg", | |
| "inTz": "Europe/London", | |
| "adjAmount": 0, | |
| "adjType": "days", | |
| "adjDir": "add", | |
| "format": "HH", | |
| "locale": "C", | |
| "output": "", | |
| "outputType": "msg", | |
| "outTz": "Europe/London", | |
| "x": 290, | |
| "y": 860, | |
| "wires": [ | |
| [ | |
| "aa603537f5629357" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "1f477430499071d3", | |
| "type": "server-state-changed", | |
| "z": "4df1db11.780364", | |
| "name": "OACurrentRate", | |
| "server": "187a6c3d.d3c2d4", | |
| "version": 4, | |
| "exposeToHomeAssistant": false, | |
| "haConfig": [ | |
| { | |
| "property": "name", | |
| "value": "" | |
| }, | |
| { | |
| "property": "icon", | |
| "value": "" | |
| } | |
| ], | |
| "entityidfilter": "sensor.octopus_outgoing_current_price", | |
| "entityidfiltertype": "exact", | |
| "outputinitially": true, | |
| "state_type": "str", | |
| "haltifstate": "", | |
| "halt_if_type": "str", | |
| "halt_if_compare": "is", | |
| "outputs": 1, | |
| "output_only_on_state_change": false, | |
| "for": "0", | |
| "forType": "num", | |
| "forUnits": "minutes", | |
| "ignorePrevStateNull": false, | |
| "ignorePrevStateUnknown": false, | |
| "ignorePrevStateUnavailable": false, | |
| "ignoreCurrentStateUnknown": false, | |
| "ignoreCurrentStateUnavailable": false, | |
| "outputProperties": [ | |
| { | |
| "property": "payload", | |
| "propertyType": "msg", | |
| "value": "", | |
| "valueType": "entityState" | |
| }, | |
| { | |
| "property": "data", | |
| "propertyType": "msg", | |
| "value": "", | |
| "valueType": "eventData" | |
| }, | |
| { | |
| "property": "topic", | |
| "propertyType": "msg", | |
| "value": "", | |
| "valueType": "triggerId" | |
| } | |
| ], | |
| "x": 120, | |
| "y": 1040, | |
| "wires": [ | |
| [ | |
| "193898d955ece9eb" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "193898d955ece9eb", | |
| "type": "function", | |
| "z": "4df1db11.780364", | |
| "name": "OACurrentRate", | |
| "func": "flow.set(\"OACurrentRate\", Number(msg.payload));\nreturn msg;\n", | |
| "outputs": 1, | |
| "noerr": 0, | |
| "initialize": "", | |
| "finalize": "", | |
| "libs": [], | |
| "x": 400, | |
| "y": 1040, | |
| "wires": [ | |
| [ | |
| "36c381e6d01b5572" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "4953dc92e7fb8238", | |
| "type": "function", | |
| "z": "4df1db11.780364", | |
| "name": "immersionFunction", | |
| "func": "var pvPower=flow.get(\"pvState\");\nvar battery=flow.get(\"batteryState\");\nvar feed=flow.get(\"feedin\");\nvar timeNow=flow.get(\"time\");\nvar OACurrentRate = flow.get(\"OACurrentRate\");\nvar immersionHeaterBoost = flow.get(\"immersionHeaterBoost\");\n\nif (OACurrentRate <= '0' && battery <= '10') {\n msg.payload = \"Go\";\n return msg;\n}\nelse if (OACurrentRate > '0' && battery > '10') {\n if (immersionHeaterBoost == \"active\"){\n msg.payload = \"Go\";\n return msg;\n }\n else {\n// else if (immersionHeaterBoost != \"active\"){ \n if (timeNow >= '6' && timeNow <= '13') {\n if (pvPower >= '2000') {\n if (battery >= '30') {\n if (feed >= '-2000') {\n msg.payload = \"Go\";\n return msg;\n }\n else {\n msg.payload = \"Stop\";\n return msg;\n }\n }\n else if (battery <= '20') {\n msg.payload = \"Stop\";\n return msg;\n }\n }\n else if (pvPower >= '3000') {\n if (battery >= '65') {\n if (feed >= '-2000') {\n msg.payload = \"Go\";\n return msg;\n }\n else {\n msg.payload = \"Stop\";\n return msg;\n }\n }\n if (battery <= '50') {\n msg.payload = \"Stop\";\n return msg;\n }\n }\n else {\n msg.payload = \"Stop\";\n return msg;\n }\n }\n else if (timeNow >= '14' && timeNow <= '19') {\n if (pvPower >= '2000') {\n if(battery >= '80') {\n if(feed >= '-2000') {\n msg.payload=\"Go\";\n return msg;\n }\n else {\n msg.payload=\"Stop\";\n return msg;\n }\n }\n else if(battery <= '64') {\n msg.payload=\"Stop\";\n return msg;\n }\n }\n else if (pvPower >= '3000') {\n if(battery >= '65') {\n if(feed >= '-2000') {\n msg.payload=\"Go\";\n return msg;\n }\n else {\n msg.payload=\"Stop\";\n return msg;\n }\n }\n else if(battery <= '50') {\n msg.payload=\"Stop\";\n return msg;\n }\n }\n else {\n msg.payload=\"Stop\";\n return msg;\n }\n }\n else {\n msg.payload = \"Stop\";\n return msg;\n }\n }\n}\nelse {\n msg.payload=\"Stop\";\n return msg;\n}\nreturn msg;", | |
| "outputs": 1, | |
| "noerr": 0, | |
| "initialize": "", | |
| "finalize": "", | |
| "libs": [], | |
| "x": 510, | |
| "y": 700, | |
| "wires": [ | |
| [] | |
| ] | |
| }, | |
| { | |
| "id": "eaf2cd014bf6c2be", | |
| "type": "switch", | |
| "z": "4df1db11.780364", | |
| "name": "", | |
| "property": "payload", | |
| "propertyType": "msg", | |
| "rules": [ | |
| { | |
| "t": "eq", | |
| "v": "Go", | |
| "vt": "str" | |
| }, | |
| { | |
| "t": "eq", | |
| "v": "Stop", | |
| "vt": "str" | |
| } | |
| ], | |
| "checkall": "true", | |
| "repair": false, | |
| "outputs": 2, | |
| "x": 930, | |
| "y": 860, | |
| "wires": [ | |
| [ | |
| "15b1b0878280861c", | |
| "bfb03f24a65070be" | |
| ], | |
| [ | |
| "15b1b0878280861c", | |
| "bfb03f24a65070be" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "7abdbf8b2c5f1a3f", | |
| "type": "api-call-service", | |
| "z": "4df1db11.780364", | |
| "name": "Discharge_Battery_On", | |
| "server": "187a6c3d.d3c2d4", | |
| "version": 5, | |
| "debugenabled": false, | |
| "domain": "homeassistant", | |
| "service": "turn_on", | |
| "areaId": [], | |
| "deviceId": [], | |
| "entityId": [ | |
| "switch.lux_force_discharge_enable" | |
| ], | |
| "data": "", | |
| "dataType": "json", | |
| "mergeContext": "", | |
| "mustacheAltTags": false, | |
| "outputProperties": [], | |
| "queue": "none", | |
| "x": 1280, | |
| "y": 840, | |
| "wires": [ | |
| [] | |
| ] | |
| }, | |
| { | |
| "id": "b51428ef563ec0e6", | |
| "type": "api-call-service", | |
| "z": "4df1db11.780364", | |
| "name": "Discharge_Battery_Off", | |
| "server": "187a6c3d.d3c2d4", | |
| "version": 5, | |
| "debugenabled": false, | |
| "domain": "homeassistant", | |
| "service": "turn_off", | |
| "areaId": [], | |
| "deviceId": [], | |
| "entityId": [ | |
| "switch.lux_force_discharge_enable" | |
| ], | |
| "data": "", | |
| "dataType": "json", | |
| "mergeContext": "", | |
| "mustacheAltTags": false, | |
| "outputProperties": [], | |
| "queue": "none", | |
| "x": 1280, | |
| "y": 920, | |
| "wires": [ | |
| [] | |
| ] | |
| }, | |
| { | |
| "id": "15b1b0878280861c", | |
| "type": "trigger", | |
| "z": "4df1db11.780364", | |
| "name": "offOnce", | |
| "op1": "true", | |
| "op2": "false", | |
| "op1type": "bool", | |
| "op2type": "bool", | |
| "duration": "0", | |
| "extend": false, | |
| "overrideDelay": false, | |
| "units": "ms", | |
| "reset": "Go", | |
| "bytopic": "all", | |
| "topic": "topic", | |
| "outputs": 1, | |
| "x": 1080, | |
| "y": 920, | |
| "wires": [ | |
| [ | |
| "b51428ef563ec0e6" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "bfb03f24a65070be", | |
| "type": "trigger", | |
| "z": "4df1db11.780364", | |
| "name": "onOnce", | |
| "op1": "true", | |
| "op2": "false", | |
| "op1type": "bool", | |
| "op2type": "bool", | |
| "duration": "0", | |
| "extend": false, | |
| "overrideDelay": false, | |
| "units": "ms", | |
| "reset": "Stop", | |
| "bytopic": "all", | |
| "topic": "topic", | |
| "outputs": 1, | |
| "x": 1080, | |
| "y": 840, | |
| "wires": [ | |
| [ | |
| "7abdbf8b2c5f1a3f" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "2d2d9c1e271565fb", | |
| "type": "inject", | |
| "z": "4df1db11.780364", | |
| "name": "Go", | |
| "props": [ | |
| { | |
| "p": "payload" | |
| } | |
| ], | |
| "repeat": "", | |
| "crontab": "", | |
| "once": false, | |
| "onceDelay": 0.1, | |
| "topic": "", | |
| "payload": "Go", | |
| "payloadType": "str", | |
| "x": 790, | |
| "y": 780, | |
| "wires": [ | |
| [ | |
| "eaf2cd014bf6c2be" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "0239f3744db46285", | |
| "type": "inject", | |
| "z": "4df1db11.780364", | |
| "name": "Stop", | |
| "props": [ | |
| { | |
| "p": "payload" | |
| } | |
| ], | |
| "repeat": "", | |
| "crontab": "", | |
| "once": false, | |
| "onceDelay": 0.1, | |
| "topic": "", | |
| "payload": "Stop", | |
| "payloadType": "str", | |
| "x": 790, | |
| "y": 820, | |
| "wires": [ | |
| [ | |
| "eaf2cd014bf6c2be" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "f9ca7289354cecf1", | |
| "type": "delay", | |
| "z": "4df1db11.780364", | |
| "name": "Delay for HA to come online", | |
| "pauseType": "delay", | |
| "timeout": "5", | |
| "timeoutUnits": "seconds", | |
| "rate": "1", | |
| "nbRateUnits": "1", | |
| "rateUnits": "second", | |
| "randomFirst": "1", | |
| "randomLast": "5", | |
| "randomUnits": "seconds", | |
| "drop": false, | |
| "allowrate": false, | |
| "outputs": 1, | |
| "x": 860, | |
| "y": 900, | |
| "wires": [ | |
| [ | |
| "eaf2cd014bf6c2be" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "964019a3d3137e7e", | |
| "type": "function", | |
| "z": "4df1db11.780364", | |
| "name": "MoneyMaker", | |
| "func": "flow.set(\"MoneyMaker\", msg.payload);\nreturn msg;\n", | |
| "outputs": 1, | |
| "noerr": 0, | |
| "initialize": "", | |
| "finalize": "", | |
| "libs": [], | |
| "x": 410, | |
| "y": 800, | |
| "wires": [ | |
| [ | |
| "c031083a5ae17969", | |
| "36c381e6d01b5572" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "c031083a5ae17969", | |
| "type": "debug", | |
| "z": "4df1db11.780364", | |
| "name": "debug 20", | |
| "active": true, | |
| "tosidebar": true, | |
| "console": false, | |
| "tostatus": false, | |
| "complete": "false", | |
| "statusVal": "", | |
| "statusType": "auto", | |
| "x": 600, | |
| "y": 800, | |
| "wires": [] | |
| }, | |
| { | |
| "id": "bb915f5745aa2253", | |
| "type": "moment", | |
| "z": "4df1db11.780364", | |
| "name": "", | |
| "topic": "", | |
| "input": "pay.time_end", | |
| "inputType": "msg", | |
| "inTz": "Europe/London", | |
| "adjAmount": "1", | |
| "adjType": "minutes", | |
| "adjDir": "subtract", | |
| "format": "", | |
| "locale": "C", | |
| "output": "pay.time_end", | |
| "outputType": "msg", | |
| "outTz": "Europe/London", | |
| "x": 300, | |
| "y": 600, | |
| "wires": [ | |
| [ | |
| "2f3888aa6c790442" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "82fd3d7e971c894d", | |
| "type": "comment", | |
| "z": "4df1db11.780364", | |
| "name": "Slots", | |
| "info": "We need to know how many 30min slots we want to mark as discharge slots", | |
| "x": 110, | |
| "y": 240, | |
| "wires": [] | |
| }, | |
| { | |
| "id": "187a6c3d.d3c2d4", | |
| "type": "server", | |
| "name": "Home Assistant", | |
| "version": 4, | |
| "addon": true, | |
| "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" | |
| } | |
| ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment