Skip to content
This repository was archived by the owner on Mar 9, 2026. It is now read-only.

Added simple generic x-user-agent to prevent from being blocked ("quota")#743

Merged
rikroe merged 5 commits intobimmerconnected:masterfrom
phreaks:x-user-agent-fix
Sep 5, 2025
Merged

Added simple generic x-user-agent to prevent from being blocked ("quota")#743
rikroe merged 5 commits intobimmerconnected:masterfrom
phreaks:x-user-agent-fix

Conversation

@phreaks
Copy link
Contributor

@phreaks phreaks commented Sep 4, 2025

Breaking change

n/a

Proposed change

Added simple generic x-user-agent to prevent from being blocked ("quota exceeded").

BMW has apparently introduced a quota for HTTP requests, which are counted based on the HTTP header x-user-agent. Because this header key is hard-coded into the code and this integration is very popular, the server-side threshold may be exceeded under certain circumstances.

To prevent this, part of the x-user-agent is now generated dynamically. The same x-user-agent should now always be generated for each installation (server, container).

Type of change

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (which adds functionality to this library)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

n/a

Checklist

  • The code change is tested and works locally.
  • Tests have been added to verify that the new code works.

Testcase

My home-assistant instance is running as an LXC using Proxmox Linux (ha-container with portainer).

  • first copy complete code from bimmer_connected on your LXC
  • then mount the host volume to /usr/local/lib/python3.13/site-packages/bimmer_connected (in my case)
  • restart container via portainer
  • connect into newly startet ha-container (console) to verify successfully mounting
  • go to ha and use existing bmw integration as always > Unique x-user-agent is now managed "under the hood".

@phreaks phreaks mentioned this pull request Sep 5, 2025
5 tasks
@rikroe
Copy link
Member

rikroe commented Sep 5, 2025

Nice, thank you!

Cannot test it right now, I assume you have it running already?

Does it also work with the 5 minute interval in Home Assistant?

@phreaks
Copy link
Contributor Author

phreaks commented Sep 5, 2025

@rikroe yes, it works since yesterday with standard polling flawless on my side.

@codecov
Copy link

codecov bot commented Sep 5, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (a1c80ca) to head (7ba147c).
⚠️ Report is 16 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##            master      #743   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           17        17           
  Lines         1431      1476   +45     
=========================================
+ Hits          1431      1476   +45     
Flag Coverage Δ
3.10 100.00% <100.00%> (ø)
3.11 100.00% <100.00%> (ø)
3.12 100.00% <100.00%> (ø)
3.13 100.00% <100.00%> (?)
3.8 100.00% <100.00%> (ø)
3.9 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rikroe
Copy link
Member

rikroe commented Sep 5, 2025

Thanks, could you please exclude PLW1641 from pyproject.toml, then I hope we're good!

@phreaks
Copy link
Contributor Author

phreaks commented Sep 5, 2025

arrrg... formatting. I'll check it.

@rikroe
Copy link
Member

rikroe commented Sep 5, 2025

Could be that this is ruff's way of telling the world I have neglected this too long. And you have to deal with it, sorry!

@phreaks
Copy link
Contributor Author

phreaks commented Sep 5, 2025

Haha... don't worry. Fixed!

Copy link
Member

@rikroe rikroe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, many thanks for this!

@rikroe rikroe merged commit b993d6a into bimmerconnected:master Sep 5, 2025
11 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants