Skip to content

Vendor idfm-api library into custom component#6

Merged
azman0101 merged 1 commit intomainfrom
fix-manifest-dependency-version-9090987666122794083
Jan 13, 2026
Merged

Vendor idfm-api library into custom component#6
azman0101 merged 1 commit intomainfrom
fix-manifest-dependency-version-9090987666122794083

Conversation

@azman0101
Copy link
Owner

This pull request introduces support for using multiple API keys with the IDFM integration to better handle rate limiting from the Île-de-France Mobilités PRIM API. It adds a new wrapper class to manage multiple keys, updates the integration to use this wrapper throughout, and improves documentation and attribution for the APIs and datasets used.

Multi-API Key Support:

  • Added a new MultiKeyIDFMApi wrapper class in api_wrapper.py that manages multiple API keys, automatically rotating between them when rate limits (HTTP 429) are encountered. This ensures continued service availability even when one key is rate limited.
  • Updated the integration setup (__init__.py and config_flow.py) to parse and use multiple API keys, replacing direct use of IDFMApi with MultiKeyIDFMApi in all relevant places. [1] [2] [3] [4] [5]

Refactoring and Internal Improvements:

  • Refactored imports throughout the integration to use relative imports for the local version of the idfm_api library, ensuring the bundled version is always used. [1] [2] [3]

Documentation and Attribution:

  • Added a new API_INFO.md file documenting how the integration uses the PRIM API, including endpoint details, authentication, and data sources.
  • Added attribution.py with clear licensing and data source references for both the open data and API components.

Bundled API Library:

  • Bundled the IDFMApi library directly into the integration under idfm_api/, ensuring all API logic is self-contained and maintained within the integration.

These changes make the integration more robust against rate limiting, improve maintainability, and enhance transparency regarding data sources and licensing.

- Copy the `idfm_api` source code from the custom fork (branch `feature/expose-request-error...`) directly into `custom_components/idfm/idfm_api/`.
- Remove the external `git+https://` dependency from `manifest.json`.
- Update all internal imports in the component (e.g., `from idfm_api import ...`) to relative imports (`from .idfm_api import ...`) to use the local copy.
- This resolves dependency installation issues and ensures the component has access to the required `RequestError` class.
- Update version to 2.3.2.
@semanticdiff-com
Copy link

semanticdiff-com bot commented Jan 13, 2026

Review changes with  SemanticDiff

Changed Files
File Status
  custom_components/idfm/manifest.json  75% smaller
  API_INFO.md Unsupported file format
  custom_components/idfm/__init__.py  0% smaller
  custom_components/idfm/api_wrapper.py  0% smaller
  custom_components/idfm/config_flow.py  0% smaller
  custom_components/idfm/entity.py  0% smaller
  custom_components/idfm/idfm_api/__init__.py  0% smaller
  custom_components/idfm/idfm_api/attribution.py  0% smaller
  custom_components/idfm/idfm_api/dataset.py  0% smaller
  custom_components/idfm/idfm_api/models.py  0% smaller
  custom_components/idfm/idfm_api/utils.py  0% smaller

@azman0101 azman0101 merged commit b839c11 into main Jan 13, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant