indykoning / PyPi_GrowattServer

MIT License
70 stars 32 forks source link

Added optional (defaults off) auto-generation of User-Agent field when library is started #40

Closed muppet3000 closed 1 year ago

muppet3000 commented 1 year ago

Implements fix for #38

I know I said I'd email you about this implementation @indykoning however I thought it would be best to just implement it and then discuss it here.

This is a completely backwards compatible change that allows a user of the library to either:

  1. Auto-generate a User-Agent string by pulling it from a valid source online, this is then used for the duration of the api object
  2. Specify their own User-Agent string (which is what is defaulted to if the auto-generate fails for any reason)
  3. (Default) - Use the default value of the User-Agent string which was introduced in 1.2.3

This way users are able to control what they use as the User-Agent until we can get Growatt to properly engage about what throttling they are doing with the library.

My plan for Home Assistant is to allow users to optionally specify their own User-Agent field i.e. match the one used on their mobile phone, or fall back to a randomly generated one.

NOTE - I want to also update the README file for this before it is merged, but I figured we'd end up discussing it here first, once we've finalised the implementation then I'll update the documentation.

indykoning commented 1 year ago

This has already been fixed in https://github.com/indykoning/PyPi_GrowattServer/pull/42 🚀