-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MyQ updates, scan_interval, status retries #17535
MyQ updates, scan_interval, status retries #17535
Conversation
- default SCAN_INTERVAL defined as 120 seconds not the standard 15 seconds - SCAN_INTERVAL (the default of 120 seconds) can be overridden in configuration.yaml with scan_interval on the component - Switch to 0.0.16 of the pymyq library which includes an endpoint change for get_status, its a more direct endpoint and the return is much smaller. Also retries 3 times for status update if server returns an error. - change init to check door status immediately and if fails fall back to None, better than waiting for the update to get the status after HA start/restart - Updates to close_cover and open_cover based on @ehendrix23 code with additional status check. Does two things, retries sending the open/close command if it initially fails the API call. Once API is successfull it queries status until it gets an open or close status or fails. Provides a quicker update of confirmed open/close than waiting for update to occur. - Change to update to check for False from pymyq and return either current status or None.
@@ -76,7 +79,11 @@ def __init__(self, myq, device): | |||
self.myq = myq | |||
self.device_id = device['deviceid'] | |||
self._name = device['name'] | |||
self._status = None | |||
|
|||
if self.myq.get_status(self.device_id): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this and instead call add_entities
with second argument True
. It will make sure update
is called during entity addition.
Also, this would have made two requests to get the same status. That seems inefficient.
"after 6 attempts", self._name) | ||
break | ||
iterations += 1 | ||
sleep(10) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sleep is not allowed in our thread pool.
current = self.myq.get_status(self.device_id) | ||
if current is not False: | ||
self._status = current | ||
else: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This case is already handled in is_closed
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is also usage of sleep
in the pymyq library. That isn't allowed either while using the home assistant thread pool. If you need to sleep either run a separate thread or move to asyncio.
@MartinHjelmare Thanks for the feedback! I will get the items requested changed. I didn't like the use of sleep myself and will look into changing things to asyncio (haven't used it before) as that appears the best path. I did just find information in the developer docs so I will get going through those. I'm not really a python programmer so I'm feeling some of this out along on the way. |
@arraylabs I'm a MyQ owner and am well-versed in |
@bachya I would welcome a PR or any help you could provide. I've only had a chance to glance over the asyncio docs on the dev site but haven't been able to dig into them yet. |
You got it! I’ll be in touch soon. |
@arraylabs I've submitted a PR to turn your library to async: arraylabs/pymyq#11 – I've also included suggestions for how to proceed with this PR. Let me know! |
This PR seems to have gone stale. Closing it. |
Description:
Related issue (if applicable): fixes #17301 #16244 #16078 #9193(maybe)
Pull request in home-assistant.io with documentation (if applicable): home-assistant/home-assistant.io#6873
Example entry for
configuration.yaml
(if applicable):Checklist:
tox
. Your PR cannot be merged unless tests passIf user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
REQUIREMENTS
variable (example).requirements_all.txt
by runningscript/gen_requirements_all.py
..coveragerc
.If the code does not interact with devices: