skagmo / ha_vwid

Volkswagen ID component for Home Assistant
71 stars 25 forks source link

Update Rate #2

Closed GaoMax closed 3 years ago

GaoMax commented 3 years ago

Hi, thank you for this great integration. It works like a charm and enables automations like charging notifications etc. I'm using an automation to increase the update rate while charging to 1 minute and I've seen that the component uses a scan interval of 10 minutes. I've changed that default 10 minutes to 5 minutes (in the sensor.py), but HA doesn't seem to respect it. Do you have an idea on how to change to update rate? Could you maybe add a config option for the update rate?

skagmo commented 3 years ago

Hi. Thanks, and nice to hear that you got it up and working.

SCAN_INTERVAL is a special variable which defines how often Home Assistant will call async_update. This logic is handled only by Home Assistant and not the component. I have tried changing it, and it seems to work fine. In sensor.py, try to add e.g. "_LOGGER.error("Updating")" in the function "async def async_update(self):" and you'll probably see that it's logged at the expected interval.

However, updating more often than every 10 minute probably does not make sense, because the car is only pushing data to the server approx. every 10 minute (at least from what I can see), so you'll only receive the same data from the server many times if updating more often.

GaoMax commented 3 years ago

Got it. It works great. I was using Last Updates/Last Changed in the HA UI as an indication as when it scanned, I've misinterpreted that value. The car pushes an update when the charging state is changed, so in worst case HA notices the change in SCAN_INTERVAL time, that's why I'm having it at 5min now. While charging it also updates it status to the server every ~1 min.