I would like to change the scan interval of the Spotify integration, and as such I was planning on making a pull request to allow the ability to input the scan interval (either from config (option?) flow or from YAML, but not relevant atm). However, I do not see the ability to change the interval dynamically, as it appears that all media_player
integrations use a constant SCAN_INTERVAL
that they define at the top of the file, which the main media_player
uses during its async_setup
, and I have no idea how to change it once it’s been set.
I figure that this is partially intentional, as I have seen mention that we don’t want a few users to set it to a super specific small value and overload Spotify (most recently from Frenck in the HA Discord here). However, I would counter that argument with Spotify specifically, as they have rate-limiting that would prevent such a situation; plus Spotify would most likely target the specific app (client ID + secret) in question rather than HA as a whole.
As a personal anecdote, in a separate project I have been doing a request every 0.5 seconds, resulting in ~100k requests a day (versus ~3k from HA updating every 30 seconds) for the past 1-2 years without an issue. I do understand that we can’t rely on this being allowed on a larger scale ofc, but just how it’s been for me.
I also figure that if we did want to implement this, it should be more generic than just Spotify (since hypothetically it could apply to all media_player
's) but I figure that isn’t my call.
As such, I was wondering if someone could point me to the right direction on how to do so, if it would even be allowed.
It should be noted that this solution does not seem to work. E.g.:
media_player:
- platform: spotify
scan_interval: 10