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:
- Using node 'eskomsepush'
- Click on 'Deploy node with License key=token, Area id=westerncape-9-paarl and Status select= National(Eskom)'
- 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](https://private-user-images.githubusercontent.com/130547447/268489914-a7628e32-ddd4-4fe6-8b38-3477b124c4c1.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjMyMzUwNjAsIm5iZiI6MTcyMzIzNDc2MCwicGF0aCI6Ii8xMzA1NDc0NDcvMjY4NDg5OTE0LWE3NjI4ZTMyLWRkZDQtNGZlNi04YjM4LTM0NzdiMTI0YzRjMS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwODA5JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDgwOVQyMDE5MjBaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1iZWM3NTExYzBjYjBlOWI1ZmNkNTFkZDI5YWM4OTg2OWViYmY0MGIzM2RjM2RmODQwYjlmODM3OGI1N2I0YzMzJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.mHdvA9oacApCXpzvQ6MFgRYqUb2nFnhWYZyezdyYtD0)
Node config with error info:
![Screenshot 2023-09-17 at 09 55 50](https://private-user-images.githubusercontent.com/130547447/268489985-f43b02c2-ed7e-481a-a9d7-366e86e5895a.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjMyMzUwNjAsIm5iZiI6MTcyMzIzNDc2MCwicGF0aCI6Ii8xMzA1NDc0NDcvMjY4NDg5OTg1LWY0M2IwMmMyLWVkN2UtNDgxYS1hOWQ3LTM2NmU4NmU1ODk1YS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwODA5JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDgwOVQyMDE5MjBaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1lYjI5YmRmZjA0Mzg4MjkyOWMzYmI3ZDU3Mzg0YzgwMDE1MWU2ZjMxYzgxYTY4N2VhOTIzZDc3YTY3MGFmMjA5JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.OetMwmrfnX7c5mGoyo-c9zvPwelq43_mNS-5jj9LQVg)
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