generated from marcieltorres/python-boilerplate-project
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: get kWh tariff from usage calculator
- Loading branch information
Showing
6 changed files
with
57 additions
and
18 deletions.
There are no files selected for viewing
This file contains 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 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 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 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,19 @@ | ||
from aiohttp import ClientSession | ||
|
||
from iec_api.usage_calculator.calculator import UsageCalculator | ||
|
||
usage_calculator = UsageCalculator() | ||
|
||
|
||
async def get_usage_calculator(session: ClientSession) -> UsageCalculator: | ||
"""Get Usage Calculator from IEC API data.""" | ||
|
||
if not usage_calculator.is_loaded: | ||
await usage_calculator.load_data(session) | ||
|
||
return usage_calculator | ||
|
||
|
||
async def get_kwh_tariff(session: ClientSession) -> float: | ||
calculator = await get_usage_calculator(session) | ||
return calculator.get_kwh_tariff() |
This file contains 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 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