-
-
Notifications
You must be signed in to change notification settings - Fork 30.8k
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
Periodically refresh overkiz states #99499
Conversation
Hey there @iMicknl, @vlebourl, @tetienne, @nyroDev, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
Somfy gates & garage doors will not automatically send state updates. They have to be explicitly requested. The TaHoma app/web interface therefore asks all devices to send their state updates on start. This change adds a new OverkizDeviceRefreshCoordinator for impacted devices and will periodically (5min) ask the specific device to send state updates. Note that even though these devices typically also provide commands such as refreshPedestrianPosition/refreshPartialPosition but they do not cause the device to send its actual state to the gateway. See Somfy-Developer/Somfy-TaHoma-Developer-Mode#26 and iMicknl/ha-tahoma#167.
c17ee43
to
b201132
Compare
|
||
async def _async_update_data(self) -> None: | ||
"""Trigger device state refresh on Overkiz platform.""" | ||
await self.client.refresh_device_states(self.device_url) |
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 is not really a use-case where the data update coordinator is required imo, since you don't receive any data here.
See iMicknl/ha-tahoma#271 for my initial try 3 years ago. Code is very outdated, but shows you another approach. You could use async_track_time_interval
to call a function every x minutes.
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.
Allright, I'll migrate it to async_track_time_interval
.
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.
Great, let me know if you need help! This issue (#103183) looks related.
OVERKIZ_REFRESH_DEVICE_STATES_DEVICES: list[UIClass | UIWidget] = [ | ||
UIClass.GARAGE_DOOR, | ||
UIClass.GATE, | ||
] |
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.
Could we make this more specific? I am not sure if an UIClass (or widget) is specific enough. There are many many Overkiz devices and perhaps we should scope this on the controllable_name
?
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.
Sure, makes sense.
Hi, I've done some test with the gate and the result is interesting. The conlusion is that the gate doesn't send is position when you use the remote, BUT, the state is update to Unknown. So we can detect when state need to be update. I read that @iMicknl dont like idea to refresh the state of all the device every 5 minutes. So I think we can use it better :
I joind the test I have done. Hope it could help |
No? I just mentioned that there are better ways in Home Assistant to call a function every x minutes. DataUpdateCoordinator is not the best mechanism for this. Thanks for your test document, this could help to investigate other ways as well. |
Not in this PR, you wrote on an other topic that is not the best way to do this according somfy, and that it could surchage the server |
Thanks for the additional testing! I can double check if the behavior is the same that I get. In general, your tests were all done without this patch, correct?
From your document that is only the case when you close the gate. Setting to pedestrian seemed to work fine. Or am I overlooking something?
I fully agree that polling is bad, but I fear at this point in time, there's no way around. The problem that I'm trying to additionally solve is getting my physically wired buttons to work. And for these I get no updates at all - it's not even going to 'unknown' unfortunately. For reference, I also link my discussion with Somfy here: Somfy-Developer/Somfy-TaHoma-Developer-Mode#26 (comment) There is btw a difference between the old PR iMicknl/ha-tahoma#271 where all devices are asked for updates, and this PR where only the specific 'bad' devices are polled for state updates. |
I had formating my test to be more readeable and did another test. I don't know why, but yes, the pedrestrian state is pick up by the motor. And the open an closed state are udpate to the unknown state. I think we couldn't say anymore that the state is note udpate, in fact, it's update but not with the value we want. But, we could do something. I made a automation that send a stop command when state of select is unknown for 20 seconds. With this I don't have my gate report open hour before automatic update. If I could have the possibility to call the refresh command you've done in the python tahoma v1.11 directly in home assitant, I could call it instead of stop command. (When the gate is open and closed with the remote, sometimes the stop command stop the gate ... Not the best way to do it...) |
Hi, Did you encounter any problems with rejected requests during your tests? I got data: {'errorCode': 'TOO_MANY_OPERATIONS_IN_PROGRESS', 'error': 'Too many asynchronous jobs for GATEWAY:XXXX-XXXX-XXXX, try again later'} Any idea ? |
Thanks. This is much clearer now, and I can reproduce the exact same behavior. Please forget the cover entity for the moment. For any other value than 'closed' it will show as 'open'. I think this is caused by this code part but it's unrelated to this PR.
Same here. If I use the 'partial button' on the 'keygo io remote' it is announced in the API as 'Partial'. When closing it again it's set to 'Unknown'. That looks like a bug to me either in the motors or in the backend. This leaves us with 2 somewhat independent problems:
For (1) I don't see an alternative to periodically polling these devices. (2) would also be solved by polling periodically, but it could indeed be improved by requesting the state once if it's 'unknown' for a some period (like 20seconds). I got an email that you commented also because you see the same issue with RS100 motors for covers - did you delete the comment again? There seems to be a hybrid variant, that supports io homecontrol and wired buttons. It could surely be that they suffer from the same issue. Question is if we can detect them reliably. Do you have the repsonse to
@iMicknl I'd like to hear your opinion on it. I can try to implement also (2) or a service, but I perfere to do it in a way that has a chance to be accepted in HA core.
What exactly did you do to get this? I assume this is just 'normal' rate limiting on the backend side and can happen on extensive testing / usage. |
It's look go to me. Maybe 5 second until state is not 'unknown' anymore be better.
That's right, go RS100 Io Hybrid with wired button. Don't see anything that could detect them...
After some reserch, it seems there are a limit of ten command send. But this is another subject. |
I'm coming maybe a little bit late here, but I have an other use case where a "refresh" request should be made. On my device, the "refresh" API endpoint doesn't return an error. But: Which leads to my question: And maybe we can go a little further by also implementing a function And finally, if the refresh needs to be done using something else? |
@fetzerch @nyroDev apologies for my late reply. Hereby my view on this issue: As shared earlier, I don't think a DataUpdateCoordinator is the right way. This is way too complex, and it only needs an API endpoint to call. Best would be to leverage State refreshes that are required after a command execution could be added right after the execution in the entity code, if this wouldn't be solved by the scheduled state refresh. We cannot support all devices in an optimal way, because some device just don't support real-time states.
How would this work? For the devices where this feature has been developed for, we don't know when a state update is required. Regarding your other comment that it needs this update every 5 minutes, that could work for these devices, but might complicate the code a lot? Compared a simple task that is scheduled every x minutes.
This would be good to check. In theory this endpoint should call all these commands automatically, same as the official app does. |
There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days. |
There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days. |
Proposed change
Somfy gates & garage doors will not automatically send state updates. They have to be explicitly requested. The TaHoma app/web interface therefore asks all devices to send their state updates on start.
This change adds a new
OverkizDeviceRefreshCoordinator
for impacted devices and will periodically (5min) ask the specific device to send state updates.Note that even though these devices typically also provide commands such as
refreshPedestrianPosition
/refreshPartialPosition
but they do not cause the device to send its actual state to the gateway.See Somfy-Developer/Somfy-TaHoma-Developer-Mode#26 and iMicknl/ha-tahoma#167.
This PR still requires iMicknl/python-overkiz-api#956 and a version bump of
python-overkiz-api
.Note that this is my first contribution to Home Assistant and so far I have been able to test this only with a Somfy Dexxo Smart io garage door motor. It would certainly be helpful to get this tested by others impacted by iMicknl/ha-tahoma#167.
Type of change
Additional information
refreshState
periodically iMicknl/ha-tahoma#167Checklist
black --fast homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
..coveragerc
.To help with the load of incoming pull requests: