File: gas.py

package info (click to toggle)
python-easyenergy 2.1.2-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 852 kB
  • sloc: python: 772; makefile: 5
file content (26 lines) | stat: -rw-r--r-- 844 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
"""Asynchronous Python client for the easyEnergy API."""

import asyncio
from datetime import date, timedelta

from easyenergy import EasyEnergy, VatOption


async def main() -> None:
    """Show example on fetching the gas prices from easyEnergy."""
    async with EasyEnergy(vat=VatOption.INCLUDE) as client:
        today = date(2024, 1, 30)

        gas_today = await client.gas_prices(start_date=today, end_date=today)
        next_hour = gas_today.utcnow() + timedelta(hours=1)

        print("--- GAS TODAY ---")
        print(f"Extremas prices: {gas_today.extreme_prices}")
        print(f"Average price: {gas_today.average_price}")
        print()
        print(f"Current hourprice: {gas_today.current_price}")
        print(f"Next hourprice: {gas_today.price_at_time(next_hour)}")


if __name__ == "__main__":
    asyncio.run(main())