Code Monkey home page Code Monkey logo

node-red-contrib-eskomsepush's Introduction

EskomSePush API

EskomsePush API

A node for retrieving info from the EskomSePush API.

The EskomSePush-API node makes it easier for South African users to incorporate the load shedding schedules into their flows.

Summary

The node must be configured by entering the license key and the correct area id (which needs to fetched from the API).

Once deployed, the node will fetch the data from EskomSePush every hour. As every fetch from the API takes 2 calls, the 50 free queries per day on a free account should suffice. Every ten minutes the API status is checked to see how many queries you have left.

Internally, the node checks every minute if a schedule is currently active or not. It will also output a message on the first deployment.

EskomsePush Victron MinSOC

The node has been made to work well together with the @victronenergy/node-red-contrib-victron nodes. The ESS control node for setting the Minimum State of Charge is an obvious combination to enable a user to change the MinSoC value based on the currently active loadshedding stage.

You can find the example flow for this via importing the victron-minsoc-stage-based.json file.

Installation & Configuration

Install the node from within Node-RED from the menu: Manage pallete -> Install (tab) -> Search for "eskom" and click "install".

First you will need a licence key. You can get one from here, by subscribing to the Free model. Note that this is for personal use only.

EskomsePush configuration

Next you need to insert the correct area id. This can be done by either:

  • making a manual API call to search for the area and paste the id from the API response into the area field in the node; or
  • by first entering a valid API license key into the node, and then entering at least 5 characters, the node will use the API to search for the area. Note that this will consume some of the daily API quota.

If you don't want to use API quota by searching, and you already know the id of the area, fill out the area first and then the license key.

To fetch the area id manually, make an areas_search API call using your API license key token, a word of search text. In the response returned by the API, copy the id value of the matching area.

In the example below (on MacOS), curl is used to query the API and the search text value is 'ballito' (the license key token is invalid and must be replaced with a valid key). The area id value that will be used from this example is eskmo-15-ballitokwadukuzakwazulunatal:

% curl --location --request GET 'https://developer.sepush.co.za/business/2.0/areas_search?text=ballito' --header 'token: 2DFB82AC-46254F6E-A68B26A4-8DF1303E'
{
  "areas":[
      {"id":"eskmo-15-ballitokwadukuzakwazulunatal","name":"Ballito (15)","region":"Eskom Municipal, Kwadukuza, Kwazulu-Natal"},
      {"id":"eskdo-15-ballitokwadukuzakwazulunatal","name":"Ballito (15)","region":"Eskom Direct, KwaDukuza, KwaZulu-Natal"}
   ]
}

Then you need to fill out which status to follow. This can be either National (Eskom) or Cape Town.

If the test checkbox has been selected, test data for the specified area will be fetched instead of the actual schedule. This is useful when debugging.

Inputs

The input side is not needed in most cases. The node will output its status every ten minutes and won't update the information it gets from the API more often. The input node however can be used to overrule this behaviour. When inserting a timestamp, the node will output the latest information it got and re-calculate all fields.

There are also special strings that can be injected as payload to force updates:

  • allowance - for retrieving the latest API count values
  • stage - for retrieving the latest active load shedding stage
  • area - for retrieving the latest schedule information

So usually there is no reason to connect anything to the input. It is only needed if you want to have more control over the node.

Outputs

The note has two outputs. In most cases, the first (upper) output will be used.

The first output of the node outputs a boolean value and some related data. When load shedding is active, the msg.payload will be true, otherwise it will be false. It also outputs some extra values:

{
  "payload": false,
  "stage": "0",
  "statusselect": "capetown",
  "api": {
    "count": 30,
    "limit": 50
  },
  "calc": {
    "sleeptime": "58",
    "stage": "0",
    "active": false,
    "type": "event",
    "next": {
      "type": "schedule",
      "start": 1686830400000,
      "end": 1686839400000,
      "duration": 9000,
      "islong": false
    },
    "secondstostatechange": 84912
  },
  "_msgid": "9fa5d503c47f083e"
}

The start and end objects contain the time as unix timestamp in the Javascript format (milliseconds after the epoch), while the duration is in seconds. The msg.calc.next.islong value is boolean and will be true if the shedding lasts 4 hours or longer.

The second output shows msg.stage and msg.schedule, containing the latest information as retrieved from the API, with the lastUpdate field added. This output is mainly useful when debugging or writing your own functions and logic.

Status

The status will show the situation regarding the API calls and when the next shedding wil start or end. It also shows the count of API calls that have been done and how many are left. This updates every 10 minutes.

The yellow color status can be either filled (dot) or not (ring). In case of a dot, the load schedding is because of an event. When it is a ring, it is caused by a matching schedule.

Documentation

Documentation for the API can be found here

When quota has been exceeded:

{"error":"Quota Exceeded - Reminder: you can use the 'test' query param for development. Check the docs! \ud83d\ude05"}

node-red-contrib-eskomsepush's People

Contributors

dirkjanfaber avatar

Stargazers

Realeboga Khoele avatar Dan Southwood-Wells avatar Nico Pretorius avatar Riaan de Lange avatar  avatar  avatar  avatar

Watchers

 avatar Warwick Bruce Chapman avatar Dan Southwood-Wells avatar Nico Pretorius avatar  avatar

node-red-contrib-eskomsepush's Issues

"No API calls left, not checking status/schedule" during and after no loadshedding.

When Eskom declare no loadshedding the eskomsepush node seems to consume all my Api calls and later the day when they declare loadshedding again there are no Api calls left.

"No API calls left, not checking status/schedule"

To Reproduce
The problem happens every time Eskom declares no load shedding.

Expected behaviour
I expect a return that indicates that there are no load shedding and that the Api calls are not used so quickly.

Software (please complete the following information):

  • node-red-contrib-eskomsepush version: 0.0.13 and 0.0.14

Flow

[
    {
        "id": "f5daca9f340cab37",
        "type": "tab",
        "label": "Flow 2",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "9be6f05e27ae1123",
        "type": "debug",
        "z": "f5daca9f340cab37",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": true,
        "complete": "true",
        "targetType": "full",
        "statusVal": "payload",
        "statusType": "auto",
        "x": 430,
        "y": 240,
        "wires": []
    },
    {
        "id": "622c1a76cfb4d678",
        "type": "change",
        "z": "f5daca9f340cab37",
        "name": "Extract ESP API calls",
        "rules": [
            {
                "t": "move",
                "p": "api.count",
                "pt": "msg",
                "to": "payload",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 480,
        "y": 380,
        "wires": [
            [
                "4c3b712fe465a0b2",
                "2573723df9e911e3"
            ]
        ]
    },
    {
        "id": "2573723df9e911e3",
        "type": "change",
        "z": "f5daca9f340cab37",
        "name": "",
        "rules": [
            {
                "t": "move",
                "p": "payload",
                "pt": "msg",
                "to": "payload.ESP_API_Calls",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 470,
        "y": 320,
        "wires": [
            [
                "a9184512.6d0338"
            ]
        ]
    },
    {
        "id": "4c3b712fe465a0b2",
        "type": "debug",
        "z": "f5daca9f340cab37",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": true,
        "complete": "true",
        "targetType": "full",
        "statusVal": "payload",
        "statusType": "auto",
        "x": 750,
        "y": 400,
        "wires": []
    },
    {
        "id": "854cb9223eb1d95f",
        "type": "eskomsepush",
        "z": "f5daca9f340cab37",
        "name": "Brakpan-WEST (6)",
        "licensekey": "***********************",
        "area": "eskde-6-brakpanwestmaquassihillsnorthwest",
        "statusselect": "eskom",
        "test": false,
        "verbose": false,
        "x": 160,
        "y": 320,
        "wires": [
            [
                "9be6f05e27ae1123",
                "622c1a76cfb4d678"
            ],
            []
        ]
    },
    {
        "id": "a9184512.6d0338",
        "type": "file",
        "z": "f5daca9f340cab37",
        "name": "WriteFile",
        "filename": "C:\\Users\\fourw\\OneDrive\\Documents\\API.txt",
        "filenameType": "str",
        "appendNewline": true,
        "createDir": true,
        "overwriteFile": "false",
        "encoding": "none",
        "x": 740,
        "y": 320,
        "wires": [
            []
        ]
    },
    {
        "id": "1bdcb122cdf77620",
        "type": "inject",
        "z": "f5daca9f340cab37",
        "name": "",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "1",
        "payloadType": "num",
        "x": 110,
        "y": 220,
        "wires": [
            [
                "2573723df9e911e3"
            ]
        ]
    }
]

Picture
image

[Feature] Next Stage scheduled

Thank you for your node which I have been enjoying.

I would like to suggest a feature though. I am currently setting my minimum stage of charge on my solar system depending on the current stage. This has been working flawlessly. I have been caught out though when the stage jumps and loadshedding starts immediately for 4 hours. It would be great if I could base my SOC based on whether the next scheduled stage is higher than the current stage. Could you add the next scheduled stage as an output?

Thanks

[BUG]"TypeError: dates.stages[(EskomSePushInfo.calc.stage - 1)] is not iterable"

Describe the bug

The node currently returns the error: "TypeError: dates.stages[(EskomSePushInfo.calc.stage - 1)] is not iterable".
My curl query returns the correct data which confirms my credentials and account are working correctly.

To Reproduce
Steps to reproduce the behavior:

  1. Using node 'eskomsepush'
  2. Click on 'Deploy node with License key=token, Area id=westerncape-9-paarl and Status select= National(Eskom)'
  3. See error: "TypeError: dates.stages[(EskomSePushInfo.calc.stage - 1)] is not iterable"

Expected behavior
The correct data should be returned. Please note that loadshedding is currently suspended until 16:00 on Sunday, 17 September. The flow worked correctly yesterday while there was loadshedding.

Screenshots
If applicable, add screenshots to help explain your problem. See below:
Flow:
Screenshot 2023-09-17 at 09 55 04

Node config with error info:
Screenshot 2023-09-17 at 09 55 50

Flow
If applicable, add a flow to help explain your problem. Below the content of my flow in json:
[{"id":"fddc3c3b17e3caa7","type":"tab","label":"Victron","disabled":false,"info":"","env":[]},{"id":"c7e0a8b8221196b2","type":"junction","z":"fddc3c3b17e3caa7","x":780,"y":240,"wires":[["1304ce8952d56b0e","42af2b5e525397d7"]]},{"id":"d083105e39f8ba68","type":"debug","z":"fddc3c3b17e3caa7","name":"Load shedding","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":560,"y":60,"wires":[]},{"id":"1d3e18f144e4911a","type":"debug","z":"fddc3c3b17e3caa7","name":"Schedule and events","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":580,"y":460,"wires":[]},{"id":"42af2b5e525397d7","type":"mqtt out","z":"fddc3c3b17e3caa7","name":"Set minSOC via MQTT","topic":"victron-home/W/c0847d9b49b3/settings/0/Settings/CGwacs/BatteryLife/MinimumSocLimit","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"1f709b6e6000e30b","x":940,"y":240,"wires":[]},{"id":"d29469701d379fef","type":"eskomsepush","z":"fddc3c3b17e3caa7","name":"","licensekey":"my-license-key","area":"westerncape-9-paarl","statusselect":"eskom","test":false,"verbose":false,"x":210,"y":260,"wires":[["d083105e39f8ba68","685df7425884177e"],["1d3e18f144e4911a"]]},{"id":"1304ce8952d56b0e","type":"debug","z":"fddc3c3b17e3caa7","name":"Scheduled charging","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":940,"y":200,"wires":[]},{"id":"685df7425884177e","type":"switch","z":"fddc3c3b17e3caa7","name":"Stage","property":"stage","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"str"},{"t":"eq","v":"2","vt":"str"},{"t":"eq","v":"3","vt":"str"},{"t":"eq","v":"4","vt":"str"},{"t":"eq","v":"5","vt":"str"},{"t":"eq","v":"6","vt":"str"},{"t":"eq","v":"7","vt":"str"},{"t":"eq","v":"8","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":9,"x":430,"y":260,"wires":[["d52bbef6b535646e"],["d52bbef6b535646e"],["9a6d3dab537b880f"],["f1c3df4e680f41a6"],["02a4b5afeb44828f"],["a4c5cec636c88ea4"],["d9ce6b3c5e1fe35e"],["a5f3427bd40f7aa1"],["c80133f055cc326a"]],"inputLabels":["EskomSePush API"],"outputLabels":["stage 1","stage 2","stage 3","stage 4","stage 5","stage 6","stage 7","stage 8","otherwise"]},{"id":"9a6d3dab537b880f","type":"change","z":"fddc3c3b17e3caa7","name":"60%","rules":[{"t":"set","p":"payload","pt":"msg","to":"{"value": 60.0}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":610,"y":160,"wires":[["c7e0a8b8221196b2"]]},{"id":"02a4b5afeb44828f","type":"change","z":"fddc3c3b17e3caa7","name":"70%","rules":[{"t":"set","p":"payload","pt":"msg","to":"{"value": 70.0}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":610,"y":240,"wires":[["c7e0a8b8221196b2"]]},{"id":"a5f3427bd40f7aa1","type":"change","z":"fddc3c3b17e3caa7","name":"100%","rules":[{"t":"set","p":"payload","pt":"msg","to":"{"value": 100.0}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":610,"y":360,"wires":[["c7e0a8b8221196b2"]]},{"id":"a4c5cec636c88ea4","type":"change","z":"fddc3c3b17e3caa7","name":"80%","rules":[{"t":"set","p":"payload","pt":"msg","to":"{"value": 80.0}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":610,"y":280,"wires":[["c7e0a8b8221196b2"]]},{"id":"f1c3df4e680f41a6","type":"change","z":"fddc3c3b17e3caa7","name":"65%","rules":[{"t":"set","p":"payload","pt":"msg","to":"{"value": 65.0}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":610,"y":200,"wires":[["c7e0a8b8221196b2"]]},{"id":"d52bbef6b535646e","type":"change","z":"fddc3c3b17e3caa7","name":"50%","rules":[{"t":"set","p":"payload","pt":"msg","to":"{"value": 50.0}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":610,"y":120,"wires":[["c7e0a8b8221196b2"]]},{"id":"c80133f055cc326a","type":"change","z":"fddc3c3b17e3caa7","name":"40%","rules":[{"t":"set","p":"payload","pt":"msg","to":"{"value": 40.0}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":610,"y":400,"wires":[["c7e0a8b8221196b2"]]},{"id":"d9ce6b3c5e1fe35e","type":"change","z":"fddc3c3b17e3caa7","name":"90%","rules":[{"t":"set","p":"payload","pt":"msg","to":"{"value": 90.0}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":610,"y":320,"wires":[[]]},{"id":"1f709b6e6000e30b","type":"mqtt-broker","name":"","broker":"192.168.0.152","port":"1883","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"autoUnsubscribe":true,"birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closeRetain":"false","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willRetain":"false","willPayload":"","willMsg":{},"userProps":"","sessionExpiry":""}]

Software (please complete the following information):

  • node-red-contrib-eskomsepush version: 0.0.14

Additional context
Add any other context about the problem here.
It was working correctly yesterday, until I depleted my free quota. After midnight the quota was restored, but it then set the wrong stage. It set Stage 8 while there was in fact no active loadshedding. Test mode was enabled and I though the problem might be related to that. I then disabled test mode, but the result was the same. Below content of the json object displayed in debug window:
{"payload":{"value":100},"stage":"8","statusselect":"eskom","api":{"count":18,"limit":50},"calc":{"sleeptime":"63","stage":"8","active":true,"next":{"type":"schedule","start":1694930400000,"end":1694946600000,"stage":"8","duration":16200,"islong":true,"isHigherStage":false},"type":"schedule","start":1694930400000,"end":1694946600000,"secondstostatechange":11697,"duration":16200,"islong":true},"_msgid":"9c739d61bc181f6f"}

I then decided to delete the node and setup a new node (in case there was an issue with the existing node), but now get the error: "TypeError: dates.stages[(EskomSePushInfo.calc.stage - 1)] is not iterable" despite the correct credentials and settings and the curl confirming my account is working correctly. See below detail from curl:
curl --location --request GET 'https://developer.sepush.co.za/business/2.0/area?id=westerncape-9-paarl'
--header 'token: my-token'
{"events":[{"end":"2023-09-18T02:30:00+02:00","note":"Stage 3","start":"2023-09-18T00:00:00+02:00"},{"end":"2023-09-18T10:30:00+02:00","note":"Stage 4","start":"2023-09-18T08:00:00+02:00"},{"end":"2023-09-18T18:30:00+02:00","note":"Stage 4","start":"2023-09-18T16:00:00+02:00"},{"end":"2023-09-19T02:30:00+02:00","note":"Stage 4","start":"2023-09-19T00:00:00+02:00"},{"end":"2023-09-19T10:30:00+02:00","note":"Stage 4","start":"2023-09-19T08:00:00+02:00"},{"end":"2023-09-19T18:30:00+02:00","note":"Stage 4","start":"2023-09-19T16:00:00+02:00"}],"info":{"name":"Paarl (9)","region":"Western Cape"},"schedule":{"days":[{"date":"2023-09-17","name":"Sunday","stages":[["08:00-10:30"],["00:00-02:30","08:00-10:30"],["00:00-02:30","08:00-10:30"],["00:00-02:30","08:00-10:30","16:00-18:30"],["00:00-02:30","08:00-12:30","16:00-18:30"],["00:00-04:30","08:00-12:30","16:00-18:30"],["00:00-04:30","08:00-12:30","16:00-18:30"],["00:00-04:30","08:00-12:30","16:00-20:30"]]},{"date":"2023-09-18","name":"Monday","stages":[["16:00-18:30"],["08:00-10:30","16:00-18:30"],["00:00-02:30","08:00-10:30","16:00-18:30"],["00:00-02:30","08:00-10:30","16:00-18:30"],["00:00-02:30","08:00-10:30","16:00-20:30"],["00:00-02:30","08:00-12:30","16:00-20:30"],["00:00-04:30","08:00-12:30","16:00-20:30"],["00:00-04:30","08:00-12:30","16:00-20:30"]]},{"date":"2023-09-19","name":"Tuesday","stages":[[],["16:00-18:30"],["08:00-10:30","16:00-18:30"],["00:00-02:30","08:00-10:30","16:00-18:30"],["00:00-02:30","08:00-10:30","16:00-18:30"],["00:00-02:30","08:00-10:30","16:00-20:30"],["00:00-02:30","08:00-12:30","16:00-20:30"],["00:00-04:30","08:00-12:30","16:00-20:30"]]},{"date":"2023-09-20","name":"Wednesday","stages":[["00:00-02:30"],["00:00-02:30"],["00:00-02:30","16:00-18:30"],["00:00-02:30","08:00-10:30","16:00-18:30"],["00:00-04:30","08:00-10:30","16:00-18:30"],["00:00-04:30","08:00-10:30","16:00-18:30"],["00:00-04:30","08:00-10:30","16:00-20:30"],["00:00-04:30","08:00-12:30","16:00-20:30"]]},{"date":"2023-09-21","name":"Thursday","stages":[["06:00-08:30"],["06:00-08:30"],["06:00-08:30","22:00-00:30"],["06:00-08:30","14:00-16:30","22:00-00:30"],["06:00-10:30","14:00-16:30","22:00-00:30"],["06:00-10:30","14:00-16:30","22:00-00:30"],["06:00-10:30","14:00-16:30","22:00-00:30"],["06:00-10:30","14:00-18:30","22:00-00:30"]]},{"date":"2023-09-22","name":"Friday","stages":[["14:00-16:30"],["06:00-08:30","14:00-16:30"],["06:00-08:30","14:00-16:30"],["06:00-08:30","14:00-16:30","22:00-00:30"],["06:00-08:30","14:00-18:30","22:00-00:30"],["06:00-10:30","14:00-18:30","22:00-00:30"],["00:00-02:30","06:00-10:30","14:00-18:30","22:00-00:30"],["00:00-02:30","06:00-10:30","14:00-18:30","22:00-00:30"]]},{"date":"2023-09-23","name":"Saturday","stages":[["22:00-00:30"],["14:00-16:30","22:00-00:30"],["06:00-08:30","14:00-16:30","22:00-00:30"],["06:00-08:30","14:00-16:30","22:00-00:30"],["06:00-08:30","14:00-16:30","22:00-00:30"],["06:00-08:30","14:00-18:30","22:00-00:30"],["06:00-10:30","14:00-18:30","22:00-00:30"],["00:00-02:30","06:00-10:30","14:00-18:30","22:00-00:30"]]}],"source":"https://sepush.co.za/"}}

With verbose logging enabled I see the following in the debug window:
msg : Object content:
{"api":{"lastUpdate":"2023-09-17T07:25:58.329Z","info":{"allowance":{"count":34,"limit":50,"type":"daily"}}},"status":{"lastUpdate":"2023-09-17T07:25:59.129Z","info":{"status":{"capetown":{"name":"Cape Town","next_stages":[{"stage":"3","stage_start_timestamp":"2023-09-17T16:00:00+02:00"}],"stage":"0","stage_updated":"2023-09-16T22:00:00.342998+02:00"},"eskom":{"name":"Eskom","next_stages":[{"stage":"3","stage_start_timestamp":"2023-09-17T16:00:00+02:00"},{"stage":"4","stage_start_timestamp":"2023-09-18T05:00:00+02:00"}],"stage":"0","stage_updated":"2023-09-16T22:00:00.342998+02:00"}}}},"area":{"lastUpdate":"2023-09-17T07:26:00.787Z","info":{"events":[{"end":"2023-09-18T02:30:00+02:00","note":"Stage 3","start":"2023-09-18T00:00:00+02:00"},{"end":"2023-09-18T10:30:00+02:00","note":"Stage 4","start":"2023-09-18T08:00:00+02:00"},{"end":"2023-09-18T18:30:00+02:00","note":"Stage 4","start":"2023-09-18T16:00:00+02:00"},{"end":"2023-09-19T02:30:00+02:00","note":"Stage 4","start":"2023-09-19T00:00:00+02:00"},{"end":"2023-09-19T10:30:00+02:00","note":"Stage 4","start":"2023-09-19T08:00:00+02:00"},{"end":"2023-09-19T18:30:00+02:00","note":"Stage 4","start":"2023-09-19T16:00:00+02:00"}],"info":{"name":"Paarl (9)","region":"Western Cape"},"schedule":{"days":[{"date":"2023-09-17","name":"Sunday","stages":[["08:00-10:30"],["00:00-02:30","08:00-10:30"],["00:00-02:30","08:00-10:30"],["00:00-02:30","08:00-10:30","16:00-18:30"],["00:00-02:30","08:00-12:30","16:00-18:30"],["00:00-04:30","08:00-12:30","16:00-18:30"],["00:00-04:30","08:00-12:30","16:00-18:30"],["00:00-04:30","08:00-12:30","16:00-20:30"]]},{"date":"2023-09-18","name":"Monday","stages":[["16:00-18:30"],["08:00-10:30","16:00-18:30"],["00:00-02:30","08:00-10:30","16:00-18:30"],["00:00-02:30","08:00-10:30","16:00-18:30"],["00:00-02:30","08:00-10:30","16:00-20:30"],["00:00-02:30","08:00-12:30","16:00-20:30"],["00:00-04:30","08:00-12:30","16:00-20:30"],["00:00-04:30","08:00-12:30","16:00-20:30"]]},{"date":"2023-09-19","name":"Tuesday","stages":[[],["16:00-18:30"],["08:00-10:30","16:00-18:30"],["00:00-02:30","08:00-10:30","16:00-18:30"],["00:00-02:30","08:00-10:30","16:00-18:30"],["00:00-02:30","08:00-10:30","16:00-20:30"],["00:00-02:30","08:00-12:30","16:00-20:30"],["00:00-04:30","08:00-12:30","16:00-20:30"]]},{"date":"2023-09-20","name":"Wednesday","stages":[["00:00-02:30"],["00:00-02:30"],["00:00-02:30","16:00-18:30"],["00:00-02:30","08:00-10:30","16:00-18:30"],["00:00-04:30","08:00-10:30","16:00-18:30"],["00:00-04:30","08:00-10:30","16:00-18:30"],["00:00-04:30","08:00-10:30","16:00-20:30"],["00:00-04:30","08:00-12:30","16:00-20:30"]]},{"date":"2023-09-21","name":"Thursday","stages":[["06:00-08:30"],["06:00-08:30"],["06:00-08:30","22:00-00:30"],["06:00-08:30","14:00-16:30","22:00-00:30"],["06:00-10:30","14:00-16:30","22:00-00:30"],["06:00-10:30","14:00-16:30","22:00-00:30"],["06:00-10:30","14:00-16:30","22:00-00:30"],["06:00-10:30","14:00-18:30","22:00-00:30"]]},{"date":"2023-09-22","name":"Friday","stages":[["14:00-16:30"],["06:00-08:30","14:00-16:30"],["06:00-08:30","14:00-16:30"],["06:00-08:30","14:00-16:30","22:00-00:30"],["06:00-08:30","14:00-18:30","22:00-00:30"],["06:00-10:30","14:00-18:30","22:00-00:30"],["00:00-02:30","06:00-10:30","14:00-18:30","22:00-00:30"],["00:00-02:30","06:00-10:30","14:00-18:30","22:00-00:30"]]},{"date":"2023-09-23","name":"Saturday","stages":[["22:00-00:30"],["14:00-16:30","22:00-00:30"],["06:00-08:30","14:00-16:30","22:00-00:30"],["06:00-08:30","14:00-16:30","22:00-00:30"],["06:00-08:30","14:00-16:30","22:00-00:30"],["06:00-08:30","14:00-18:30","22:00-00:30"],["06:00-10:30","14:00-18:30","22:00-00:30"],["00:00-02:30","06:00-10:30","14:00-18:30","22:00-00:30"]]}],"source":"https://sepush.co.za/"}}},"calc":{"sleeptime":"124","stage":"0","active":false,"next":{"type":"event","start":1694988000000,"end":1694997000000,"stage":"3"}}}

Followed by msg: error
TypeError: dates.stages[(EskomSePushInfo.calc.stage - 1)] is not iterable

EskomSePush integration with inverter on/off 10 min prior Loadshedding/Grid return

Hi Dirkjanfaber

Can you please help me.
I'm trying to integrate with your EskomsePush by using your second output.
How and what do I use to get the start and end time of the current load-shedding as well as the time for the next expected load-shedding.
I want to use this to switch off the inverter before load-shedding starts (10min prior) and reconnect the inverter after 10min once grid has returned.
I'm experiencing huge surges and want to avoid them before load-shedding happens and after grid returned.
The Eskomsepush node is up and running and is showing the current stage and time in my area just need to know how to get those info as mentioned above.

Kind Regards,
J

Request failed with status code 429

Hi,
With the EskomSepush Free account and curl on MacOS and my token, I am getting a proper result. See below.

With that same token and the same area Id using your node I get the following error message in the debug window:
error: "Request failed with status code 429"

I am using Node Red V3.02 and have enough token left.


curl --location --request GET 'https://developer.sepush.co.za/business/2.0/area?id=eskmo-13-belabelawarmbadtownbelabelalimpopo' \

--header 'token: XXXXXXXX-XXXXXXXX-XXXXXXXX-DE6B65CD'

{"events":[{"end":"2023-06-11T23:30:00+02:00","note":"Stage 4","start":"2023-06-11T21:00:00+02:00"},{"end":"2023-06-12T15:30:00+02:00","note":"Stage 1","start":"2023-06-12T13:00:00+02:00"},{"end":"2023-06-12T23:30:00+02.........

[BUG] TypeError: Cannot read properties of undefined (reading 'start')

Describe the bug
Node appears to crash everytime it runs with the following error: TypeError: Cannot read properties of undefined (reading 'start')

To Reproduce
Steps to reproduce the behavior:

  1. Fresh install of the Node
  2. Using area capetown-11-meadowridge
  3. It appears that the correct stage is returned despite the error.

Software (please complete the following information):

  • node-red-contrib-eskomsepush version: 0.0.17

[BUG]

Describe the bug
Seemingly internal TypeError

To Reproduce
Steps to reproduce the behavior:
The node was working fine and it started giving issues without me touching it again.
I stopped referencing it and its still giving errors

Expected behavior
Output time to next LS and duration

Software (please complete the following information):

  • node-red-contrib-eskomsepush version: 0.0.12

[BUG] now.getUTCDate) missing brackets ()

Describe the bug
A clear and concise description of what the bug is.
I think there might be an error in the code on line 293:
if (new Date(EskomSePushInfo.calc.next.start).getUTCDay() !== now.getUTCDate) {

It should be:
if (new Date(EskomSePushInfo.calc.next.start).getUTCDay() !== now.getUTCDate()) {

To Reproduce
Steps to reproduce the behavior:

  1. Using node 'eskomsepush'
  2. Click on '....'
  3. See error
    I've seen issues where the status colour were not updated correctly after I switched between "test" and "active" modes.

Expected behavior
A clear and concise description of what you expected to happen.
Status colour should be updated to green if all working and switched from test to active.

Screenshots
If applicable, add screenshots to help explain your problem.

Flow
If applicable, add a flow to help explain your problem.

Software (please complete the following information):

  • node-red-contrib-eskomsepush version: v0.0.15

Additional context
Add any other context about the problem here.

[BUG] Updating every minute

Node is updating every minute, causing quota to be exhausted really quickly.

12 Jun 13:58:53 - [warn] [eskomsepush:Three Anchor Bay (7)] Running function checkAllowance
12 Jun 13:58:53 - [warn] [eskomsepush:Three Anchor Bay (7)] Running function updateStatus
12 Jun 13:58:53 - [warn] [eskomsepush:Three Anchor Bay (7)] Running function updateStatus
12 Jun 13:59:53 - [warn] [eskomsepush:Three Anchor Bay (7)] Running function updateSheddingStatus
12 Jun 13:59:53 - [warn] [eskomsepush:Three Anchor Bay (7)] Running function updateStatus
12 Jun 14:00:53 - [warn] [eskomsepush:Three Anchor Bay (7)] Running function updateSheddingStatus
12 Jun 14:00:53 - [warn] [eskomsepush:Three Anchor Bay (7)] Running function updateStatus
12 Jun 14:01:53 - [warn] [eskomsepush:Three Anchor Bay (7)] Running function updateSheddingStatus
12 Jun 14:01:53 - [warn] [eskomsepush:Three Anchor Bay (7)] Running function updateStatus
12 Jun 14:02:53 - [warn] [eskomsepush:Three Anchor Bay (7)] Running function updateSheddingStatus
12 Jun 14:02:53 - [warn] [eskomsepush:Three Anchor Bay (7)] Running function updateStatus
12 Jun 14:03:53 - [warn] [eskomsepush:Three Anchor Bay (7)] Running function updateSheddingStatus
12 Jun 14:03:53 - [warn] [eskomsepush:Three Anchor Bay (7)] Running function updateStatus
12 Jun 14:04:53 - [warn] [eskomsepush:Three Anchor Bay (7)] Running function updateSheddingStatus
12 Jun 14:04:53 - [warn] [eskomsepush:Three Anchor Bay (7)] Running function updateStatus
12 Jun 14:05:53 - [warn] [eskomsepush:Three Anchor Bay (7)] Running function updateSheddingStatus
12 Jun 14:05:53 - [warn] [eskomsepush:Three Anchor Bay (7)] Running function updateStatus
12 Jun 14:06:53 - [warn] [eskomsepush:Three Anchor Bay (7)] Running function updateSheddingStatus
12 Jun 14:06:53 - [warn] [eskomsepush:Three Anchor Bay (7)] Running function updateStatus

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.