andig / pimatic-fritz

Pimatic plugin for Fritz!Box SmartHome and FritzDect!200 Node
GNU General Public License v2.0
8 stars 6 forks source link

[Request] Improve polling performance #46

Closed Wolfpaxx closed 6 years ago

Wolfpaxx commented 6 years ago

andig, your plugin is great - but I'm running it to the limits. With too many devices, the polling tasks are stacking up and switch commands are executed hours later. My problem in detail: https://forum.pimatic.org/topic/4318/fritz-plugin-performance-and-integration-of-contact-devices

Can you check other ways to improve the polling performance and support more devices at a higher polling rate?

If you say that you see a way to realize that, I would be happy to chip myself in with a 100€ donation to support your work.

andig commented 6 years ago

Interesting request :) Thanks for pushing this plugin to the limits!

I understand AVM is looking into better smarthome support. At the time being though, the API is naive, i.e. requires clients to use longpolling. The fritzapi approach to that has been to use the official APIs where available and fallback to XML API or screen scraping where not.

While the regular APIs support a single device at a time only, the XML API also supports bulk which would be the right way for performance improvement, though at the cost of maintainability.

Out of curiosity: which fritz box device are you running this on? I've noticed that the latest generation offers significantly better API performance. Did you consider lowering the polling intervall to not swap the API with query requests?

Wolfpaxx commented 6 years ago

Thank you for your quick reply! So, if I understand you right, it could be possible to switch the API, but you're currently not planning it due it will be a lot of work an will make your plugin less flexible? Totally understandable! I'm currently running a FritzBox 7490. So you guess switching to a 7590 could give me a performance boost?! Lowering the polling intervalls is what I'm currently considering to do. I guess I'll go up to five minutes with the 21 temperature sensors and the 12 thermostate values. For the switch devices, I try to keep them on the default 60 seconds and increase the smoke detectors to 15 seconds. For the button device, I currently see no use until polling is lower than one second. A great solution would be, if AVM integrated a curl-function with the sensor devices, so you can push an event to the pimatic instead of polling/pulling it from the FritzBox... I wonder if that's already on their feature request list?

andig commented 6 years ago

I'm currently running a FritzBox 7490. So you guess switching to a 7590 could give me a performance boost?!

I have a 6590 and it rocks

I wonder if that's already on their feature request list?

A better approach would be a websocket server on side of FritzBox- low overhead and scales well. If you want send an inquiry to AVM, it might help to get more requests than just from the usual suspects.

Wolfpaxx commented 6 years ago

Finally feedback from my side: I switched to a 7590 and the performance boost is outstanding! I also encountered that switching operations are more quickly done. Now there is almost no delay between acitvating an Amazon Dash Button and the Fritz outlet switching. So for everyone with the same problem: a hardware upgrade will do the trick! :-)