Open dvx76 opened 5 days ago
if self._requests['batterycharge'].get('id', False):
timestamp = self._requests.get('batterycharge', {}).get('timestamp', datetime.now())
expired = datetime.now() - timedelta(minutes=3)
if expired > timestamp:
self._requests.get('batterycharge', {}).pop('id')
else:
raise SkodaRequestInProgressException('Charging action already in progress')
If I'm not mistaken the Vehicle
class keeps a map of outstanding requests by 'type' (e.g. batterycharge
here) and if a previous requests is outstanding, the new request is rejected.
I will integrate the MQTT server that Skoda is using to push updates to the app in the next days, and then we don't need to poll anymore at all :)
On Sun, Sep 15, 2024, 14:45 Fabrice Devaux @.***> wrote:
if self._requests['batterycharge'].get('id', False): timestamp = self._requests.get('batterycharge', {}).get('timestamp', datetime.now()) expired = datetime.now() - timedelta(minutes=3) if expired > timestamp: self._requests.get('batterycharge', {}).pop('id') else: raise SkodaRequestInProgressException('Charging action already in progress')
If I'm not mistaken the Vehicle class keeps a map of outstanding requests by 'type' (e.g. batterycharge here) and if a previous requests is outstanding, the new request is rejected.
— Reply to this email directly, view it on GitHub https://github.com/skodaconnect/homeassistant-myskoda/issues/5#issuecomment-2351577373, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALME5RYZTPVPC6KSC3P5ATZWV6M5AVCNFSM6AAAAABOHZB6BOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNJRGU3TOMZXGM . You are receiving this because you are subscribed to this thread.Message ID: @.***>
Currently requests, e.g. to change the charge limit, will just queue and end up all executing. The 'problem' is that these requests can take a lot of time (10's of seconds, used to be more like minutes in the past).
E.g. if you change the charge limit to 90 and then to 80, you'll get something like this:
The old integration would cap the number of parallel requests to 1 I believe. Will try to find a reference.
We may also want to relax the poll frequency in the
set_
methods (currently 15s) to avoid getting rate limited. Also wondering if we could update just the entity being (instead of everything, which I understand is whatcoordinator.async_refresh()
will do.I'm also curious what the best-practice is for HA when updating number entities where the execution of the update request is high asynchronous like here.