-
Notifications
You must be signed in to change notification settings - Fork 2
ci: modernize and harden GitHub Actions workflows #197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f4bae6f
ci: modernize and harden GitHub Actions workflows
firstof9 778f4e7
ci: update testing matrix and setup to target Python 3.14
firstof9 7a75f3c
ci: migrate setup.py to pyproject.toml and modernize publish workflow
firstof9 48c98a6
docs: update README.md to be more descriptive and comprehensive
firstof9 8317037
address PR review comments and fix mypy test failures
firstof9 264ae82
Swap linting to ruff and add pre-commit hooks
firstof9 6948f78
fix: resolve PR review comments on error handling and pyproject class…
firstof9 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| repos: | ||
| - repo: https://github.com/astral-sh/ruff-pre-commit | ||
| rev: v0.15.14 | ||
| hooks: | ||
| - id: ruff | ||
| args: [--fix] | ||
| - id: ruff-format | ||
| - repo: https://github.com/pre-commit/pre-commit-hooks | ||
| rev: v5.0.0 | ||
| hooks: | ||
| - id: check-yaml | ||
| - id: end-of-file-fixer | ||
| - id: trailing-whitespace | ||
| - id: check-added-large-files | ||
| - id: debug-statements |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,4 +2,4 @@ | |
| "files.associations": { | ||
| "*.yaml": "home-assistant" | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,139 @@ | ||
| # python-openei | ||
| Python Library for OpenEI.org Rest data | ||
|
|
||
| A python library for consuming OpenEI.org rest data and outputting it into an easy to use format. | ||
| [](https://pypi.org/project/python-openei/) | ||
| [](https://opensource.org/licenses/MIT) | ||
|
|
||
| An asynchronous Python library for consuming utility rate data from the [OpenEI.org](https://openei.org) API and outputting it into an easy-to-use format. | ||
|
|
||
| ## Features | ||
|
|
||
| - **Asynchronous API**: Fully built on `aiohttp` for non-blocking network calls. | ||
| - **Auto Caching**: Automatically caches API responses locally (24-hour expiration) to stay within rate limits. | ||
| - **Utility Plan Lookup**: Find utility rate plans by coordinates (latitude/longitude) or street address. | ||
| - **Rate Schedule Queries**: Calculates current and upcoming energy rates, demand rates, adjustments, and tier/sell rates for any given date and time. | ||
|
|
||
| --- | ||
|
|
||
| ## Installation | ||
|
|
||
| Install using `pip`: | ||
|
|
||
| ```bash | ||
| pip install python-openei | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## Quick Start | ||
|
|
||
| You will need an API key from [OpenEI.org](https://openei.org/wiki/Special:Register). | ||
|
|
||
| ### Basic Usage | ||
|
|
||
| Here is a quick example of how to retrieve and query energy rates for a specific plan: | ||
|
|
||
| ```python | ||
| import asyncio | ||
| from openeihttp import Rates | ||
|
|
||
| async def main(): | ||
| # Initialize Rates helper | ||
| # Retrieve a specific plan (e.g. "539fca56ec12157c50403bf6") | ||
| api = Rates( | ||
| api="YOUR_OPENEI_API_KEY", | ||
| plan="539fca56ec12157c50403bf6", | ||
| cache_file="my_rate_cache.json" # Optional local cache file | ||
| ) | ||
|
|
||
| # Fetch/update the rate plan details | ||
| await api.update() | ||
|
|
||
| print(f"Rate Plan Name: {api.rate_name}") | ||
| print(f"Current Energy Rate: ${api.current_rate}/kWh") | ||
| print(f"Current Sell Rate: ${api.current_sell_rate}/kWh") | ||
|
|
||
| # Check what the next rate will be and when it changes | ||
| next_time = api.next_energy_rate_structure_time | ||
| next_rate = api.next_energy_rate_structure | ||
| print(f"Next rate change at: {next_time} (structure ID: {next_rate})") | ||
|
|
||
| asyncio.run(main()) | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## Plan Lookup | ||
|
|
||
| If you do not know the plan ID, you can look up available plans using a latitude/longitude pair or a physical address: | ||
|
|
||
| ```python | ||
| import asyncio | ||
| from openeihttp import Rates | ||
|
|
||
| async def lookup(): | ||
| # Set up lookup using latitude and longitude | ||
| api = Rates( | ||
| api="YOUR_OPENEI_API_KEY", | ||
| lat=37.7749, | ||
| lon=-122.4194, | ||
| radius=5.0 # Optional search radius in miles | ||
| ) | ||
|
|
||
| plans = await api.lookup_plans() | ||
|
|
||
| # plans will be grouped by utility name | ||
| for utility, plan_list in plans.items(): | ||
| print(f"\nUtility: {utility}") | ||
| for plan in plan_list: | ||
| print(f" - {plan['name']} (Plan Label: {plan['label']})") | ||
|
|
||
| asyncio.run(lookup()) | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## API Reference | ||
|
|
||
| ### Properties | ||
|
|
||
| The `Rates` object exposes the following properties after a successful `update()`: | ||
|
|
||
| | Property | Return Type | Description | | ||
| | :--- | :--- | :--- | | ||
| | `rate_name` | `str` | Name of the utility rate plan. | | ||
| | `approval` | `bool` | Approval status of the rate plan on OpenEI. | | ||
| | `current_rate` | `float \| None` | Current active energy rate in $/kWh. | | ||
| | `current_sell_rate` | `float \| None` | Current net-metering / sell rate in $/kWh. | | ||
| | `current_adjustment` | `float \| None` | Current rate adjustment value in $/kWh. | | ||
| | `next_energy_rate_structure` | `int \| None` | Upcoming energy rate structure ID. | | ||
| | `next_energy_rate_structure_time` | `datetime \| None` | The time at which the next energy rate structure starts. | | ||
| | `current_demand_rate` | `float \| None` | Current demand rate. | | ||
| | `current_demand_adjustment`| `float \| None` | Current demand rate adjustment. | | ||
| | `demand_unit` | `str \| None` | The unit of the demand rate. | | ||
| | `monthly_tier_rate` | `float \| None` | Current tier rate based on monthly meter reading. | | ||
| | `distributed_generation` | `str \| None` | Distributed generation rules / net-metering type. | | ||
| | `mincharge` | `tuple[float, str] \| None` | Minimum charge amount and units (e.g. `(10.0, "$/month")`). | | ||
| | `fixedchargefirstmeter` | `tuple[float, str] \| None` | Fixed charge amount and units for the first meter. | | ||
|
|
||
| ### Methods | ||
|
|
||
| - `await api.update()`: Updates the internal data. Loads from cache if fresh, otherwise fetches from API and caches locally. | ||
| - `await api.update_data()`: Forces a fresh API call (bypassing cache) and rewrites the cache file. | ||
| - `await api.clear_cache()`: Deletes the cache file if one was configured. | ||
| - `api.rate(date: datetime)`: Look up the energy rate for a specific date and time. | ||
| - `api.sell_rate(date: datetime)`: Look up the sell/net-metering rate for a specific date and time. | ||
| - `api.demand_rate(date: datetime)`: Look up the demand rate for a specific date and time. | ||
|
|
||
| --- | ||
|
|
||
| ## Development | ||
|
|
||
| This project uses `tox` to run checks and tests across Python versions. | ||
|
|
||
| ### Run Tests and Linters | ||
|
|
||
| Make sure you have `tox` installed, then run: | ||
|
|
||
| ```bash | ||
| tox | ||
| ``` |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.