arraylabs / pymyq

Python wrapper for MyQ API
MIT License
112 stars 42 forks source link

Need assistance on getting status updates #177

Open k5map opened 1 year ago

k5map commented 1 year ago

@arraylabs ... very much appreciate your Python library. I've been monitoring the "hjdhjd/myq" app but am not proficient in JS or TS or yours is best solution for me.

I've successfully written a short app to get the status of my MyQ devices using the sample code in the readme. Now I'd like to do a loop to monitor the status of my devices (every 5-10 seconds). Since I've executed the login function and assigned it to a var, what function must I use to refresh the status of my devices?

Goose66 commented 1 year ago

Use the api.update_device_info() method to update the status of all devices. Note that this is throttled in frequency to once every 5 seconds in the code. However, in my opinion performing status polling every 5 seconds over a long period is too frequent and will eventually result in Chamberlain throttling or suspending your account or potentially altering or shutting down the interface.

k5map commented 1 year ago

@Goose66 Much thanks for the update_device_info() info... I've been reading the post on @hjdhjd/myq's Github so was aware of not calling it frequently to avoid Chamberlain from blacklisting my IP but still appreciate the heads up.

k5map commented 1 year ago

@Goose66 I have one additional question... am I able to call update_device_info() repeatedly without having to login again? My concern is after x amount of time, does my login credentials expire.

Goose66 commented 11 months ago

When the api object initially authorizes through oAuth, it receives a token TTL value ("expires_in") from the MyQ service. I believe the api object keeps up with this and refreshes the token as needed as long as the api object is alive. My implementation (which is different from pymyq) uses a default token TTL of 60 min.