Too many requests, try again later
Closed this issue · 4 comments
Hi,
Is there any way to get around the "Too many requests, try again later" error?
I want to be able to make a smart button that can close, open and stop a blind. Currently this isn't possible as one command after another creates this issue.
Any help would be appreciated, thank you.
👋 Hello,
Like that it’s hard to help you, can you share your script?
Thanks for your reply :) This is what I have so far:
import asyncio
import time
from pyhoma.client import TahomaClient
SUPPORTED_ENDPOINTS = {
"Cozytouch": "https://ha110-1.overkiz.com/enduser-mobile-web/enduserAPI/",
"eedomus": "https://ha101-1.overkiz.com/enduser-mobile-web/enduserAPI/",
"Hi Kumo": "https://ha117-1.overkiz.com/enduser-mobile-web/enduserAPI/",
"Rexel Energeasy Connect": "https://ha112-1.overkiz.com/enduser-mobile-web/enduserAPI/",
"Somfy Connexoon IO": "https://tahomalink.com/enduser-mobile-web/enduserAPI/",
"Somfy Connexoon RTS": "https://ha201-1.overkiz.com/enduser-mobile-web/enduserAPI/",
"Somfy TaHoma": "https://tahomalink.com/enduser-mobile-web/enduserAPI/",
"Somfy (Australia)": "https://ha201-1.overkiz.com/enduser-mobile-web/enduserAPI/",
"Somfy (Europe)": "https://tahomalink.com/enduser-mobile-web/enduserAPI/",
"Somfy (North America)": "https://ha401-1.overkiz.com/enduser-mobile-web/enduserAPI/",
}
USERNAME = "*"
PASSWORD = "*"
DEVICE = "Office"
COMMAND = "open"
async def main() -> None:
async with TahomaClient(USERNAME, PASSWORD, api_url=SUPPORTED_ENDPOINTS["Somfy (Europe)"]) as client:
try:
await client.login()
except Exception as exception: # pylint: disable=broad-except
print(exception)
return
IDTOSEND = ""
COMMANDTOSEND = COMMAND
if DEVICE == "Office":
IDTOSEND = "{deviceID}"
elif DEVICE == "Patio Doors":
IDTOSEND = "{deviceID}"
elif DEVICE == "Living room 1":
IDTOSEND = "{deviceID}"
elif DEVICE == "Living room 2":
IDTOSEND = "{deviceID}"
elif DEVICE == "Spare bedroom":
IDTOSEND = "{deviceID}"
elif DEVICE == "Master bedroom":
IDTOSEND = "{deviceID}"
else:
return
await client.execute_command(IDTOSEND, {"name": COMMANDTOSEND})
asyncio.run(main())`
Above I have removed the device ID's but essentially I want to be able to pass through the device name and command, and have the script execute that.
I plan on having a smart button hitting an api with those 2 variables, which then executes this in a cloud service.
Thank you!
Also just to add, this does work. But whenever I execute it a few times in succession, I get the "too many requests" and then cant use it for a few minutes.
@benmckillop this is because you call login() too often. When you keep reusing the session, you shouldn't need this all the time.