bisand / node-red-contrib-panasonic-comfort-cloud

MIT License
5 stars 3 forks source link

Too many requests #17

Closed smadds closed 9 months ago

smadds commented 1 year ago

I got the node linked to our Comfort Cloud again recently after a lot of time waiting for Panasonic to rebuild their system. It all worked fine, but we noticed recently the automation was not working again.

If I try to open the phone app it says the account is blocked, and the node is returning this when requesting the status of an aircon unit:

msg : Object
object
message: "Too Many Requests"
code: 42901
httpCode: 429
statusCode: 429
statusMessage: ""

I'm polling for status every 5 minutes for 2 separate units (2 status requests each set to interval of 5mins). Seems like a reasonable time period - is anyone else experiencing this issue?

smadds commented 1 year ago

The app is not happy!

20230712_072323

hannuterasloihde commented 11 months ago

I now also faced the same situation. I was only pulling data for two units every 15 minutes. This probably has nothing to do with this code but Panasonic has tightened their API request limits. Although a bit too tight for my liking.

keukenrol commented 11 months ago

I have this as well. Even with refresh times of 30 minutes. I have 7 airconditioning units inside, each requiring their own api call.

Unfortunately panasonic has no local functionality, which forces us to use their cloud api.

Looking for a solution... for the moment, the node is deactivated.

hannuterasloihde commented 11 months ago

What I have notice is that the limit seems to be how many requests are sent in a short period of time. Not the total number of requests during the whole day. I have 4 units and they way I have set this up in node red is that I read the status of all devices with the groups node as this will return all statuses of the whole account. This is reading the status once per hour.

Then everytime I send a device update message and/or read the status of a single device, I a have a rate/delay node which is configured to send an event to comfort cloud only once per 15 seconds, it buffers and delays the next messages. In effect this results in the messages to be throttled towards comfort cloud web service to a maximum of one message per 15 seconds.

The end result is that I am roughly sending about 10 messages per hour to comfort cloud and it doesn't any more lock my user account. I think the change that mostly "fixed" this is the throttling of the messages. This ofcourse makes the flow a bit more complicated, so it would be nice if this throttling could be coded directly into this node red component.

Here is a simplified picture of my flow which routes all messages through the throttling node:

image
bisand commented 9 months ago

Since @hannuterasloihde already have a perfectly good solution to this problem, I will close this issue. I do not think I will add a rate limiter to the components for the time being. It will most likely add unnecessary complexity to the code base.

smadds commented 5 months ago

I realise this is closed, but as a follow-up for anyone needing help getting this working...

I tried @hannuterasloihde solution (thanks!), but every 15sec triggered the error. I increased it to 1min and seems good now. I moved all my Panasonic calls to a separate flow and linked in and out, using the topic on the input to indicate which node to route to. I have also added a selector on the status output to allow routing back to the calling flow based on the GUID of the device. JSON for the flow is below the screenshot if anyone wants to import it.

image

[ { "id": "13f7d71bfcee0fe2", "type": "debug", "z": "52c38f1824c8df8c", "name": "", "active": false, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "targetType": "full", "statusVal": "", "statusType": "auto", "x": 1550, "y": 1700, "wires": [] }, { "id": "0024d1775cdecabf", "type": "pcc-command", "z": "52c38f1824c8df8c", "name": "AIrcon Control", "comfortCloudConfig": "", "deviceId": "", "x": 1360, "y": 1700, "wires": [ [ "13f7d71bfcee0fe2" ] ] }, { "id": "8d0df04c2160143d", "type": "delay", "z": "52c38f1824c8df8c", "name": "", "pauseType": "rate", "timeout": "15", "timeoutUnits": "seconds", "rate": "1", "nbRateUnits": "1", "rateUnits": "minute", "randomFirst": "1", "randomLast": "5", "randomUnits": "seconds", "drop": false, "allowrate": false, "outputs": 1, "x": 870, "y": 1700, "wires": [ [ "633705580fcbb390" ] ] }, { "id": "30948d4f6e24625b", "type": "link in", "z": "52c38f1824c8df8c", "name": "Panasonic device control", "links": [], "x": 565, "y": 1700, "wires": [ [ "950c6eae5d072de2", "8d0df04c2160143d" ] ] }, { "id": "9ffdf812bcc52357", "type": "comment", "z": "52c38f1824c8df8c", "name": "Panasonic Comfort Control", "info": "Put all the calls in 1 place to prevent rate overload", "x": 590, "y": 1420, "wires": [] }, { "id": "950c6eae5d072de2", "type": "debug", "z": "52c38f1824c8df8c", "name": "", "active": false, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "targetType": "full", "statusVal": "", "statusType": "auto", "x": 710, "y": 1760, "wires": [] }, { "id": "633705580fcbb390", "type": "switch", "z": "52c38f1824c8df8c", "name": "Message type from topic", "property": "topic", "propertyType": "msg", "rules": [ { "t": "eq", "v": "groups", "vt": "str" }, { "t": "eq", "v": "control", "vt": "str" }, { "t": "eq", "v": "status", "vt": "str" } ], "checkall": "true", "repair": false, "outputs": 3, "x": 1110, "y": 1700, "wires": [ [ "1bcbc8f321ef17dc" ], [ "0024d1775cdecabf" ], [ "eff8eb3e12975417" ] ] }, { "id": "eff8eb3e12975417", "type": "pcc-device", "z": "52c38f1824c8df8c", "name": "Aircon Status", "comfortCloudConfig": "", "deviceId": "", "x": 1350, "y": 1780, "wires": [ [ "ce52bcce227794ef", "72eedce53a5b8223" ] ] }, { "id": "ce52bcce227794ef", "type": "switch", "z": "52c38f1824c8df8c", "name": "Status to devices", "property": "payload.deviceGuid", "propertyType": "msg", "rules": [ { "t": "eq", "v": "Put 1st Device ID here...", "vt": "str" }, { "t": "eq", "v": "2nd here etc.", "vt": "str" }, { "t": "eq", "v": "", "vt": "str" }, { "t": "eq", "v": "", "vt": "str" } ], "checkall": "true", "repair": false, "outputs": 4, "x": 1590, "y": 1780, "wires": [ [ "dba207fc23162af3" ], [ "1f226606f089f8e9" ], [ "3a921bf89cf3690d" ], [ "7ef578004fa6e2c6" ] ], "outputLabels": [ "1st device name here", "2nd here", "3rd here", "4th here" ] }, { "id": "dba207fc23162af3", "type": "link out", "z": "52c38f1824c8df8c", "name": "Warehouse Status", "mode": "link", "links": [], "x": 1755, "y": 1720, "wires": [] }, { "id": "1f226606f089f8e9", "type": "link out", "z": "52c38f1824c8df8c", "name": "Semple Status", "mode": "link", "links": [], "x": 1755, "y": 1760, "wires": [] }, { "id": "b06fdedd81e144ef", "type": "debug", "z": "52c38f1824c8df8c", "name": "", "active": false, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "targetType": "full", "statusVal": "", "statusType": "auto", "x": 1550, "y": 1620, "wires": [] }, { "id": "d82f25c5129fad70", "type": "inject", "z": "52c38f1824c8df8c", "name": "Query groups", "props": [ { "p": "payload" }, { "p": "topic", "vt": "str" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "groups", "payload": "", "payloadType": "date", "x": 650, "y": 1540, "wires": [ [ "8d0df04c2160143d" ] ] }, { "id": "d9c196daaab5c9ac", "type": "comment", "z": "52c38f1824c8df8c", "name": "Get list of devices on our account", "info": "", "x": 610, "y": 1500, "wires": [] }, { "id": "1bcbc8f321ef17dc", "type": "pcc-groups", "z": "52c38f1824c8df8c", "name": "AIrcon Groups", "comfortCloudConfig": "", "x": 1360, "y": 1620, "wires": [ [ "b06fdedd81e144ef" ] ] }, { "id": "72eedce53a5b8223", "type": "debug", "z": "52c38f1824c8df8c", "name": "", "active": false, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "targetType": "full", "statusVal": "", "statusType": "auto", "x": 1550, "y": 1860, "wires": [] }, { "id": "3a921bf89cf3690d", "type": "link out", "z": "52c38f1824c8df8c", "name": "link out 9", "mode": "link", "links": [], "x": 1755, "y": 1800, "wires": [] }, { "id": "7ef578004fa6e2c6", "type": "link out", "z": "52c38f1824c8df8c", "name": "link out 10", "mode": "link", "links": [], "x": 1755, "y": 1840, "wires": [] } ]