Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/danielhiversen/pytibber
Async Python 3 library for Tibber
https://github.com/danielhiversen/pytibber
Last synced: 4 days ago
JSON representation
Async Python 3 library for Tibber
- Host: GitHub
- URL: https://github.com/danielhiversen/pytibber
- Owner: Danielhiversen
- License: gpl-3.0
- Created: 2017-09-23T17:12:29.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-11-11T19:16:47.000Z (about 1 month ago)
- Last Synced: 2024-12-15T06:00:43.360Z (12 days ago)
- Language: Python
- Homepage:
- Size: 455 KB
- Stars: 97
- Watchers: 11
- Forks: 37
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# pyTibber
[![PyPI version](https://badge.fury.io/py/pyTibber.svg)](https://badge.fury.io/py/pyTibber)
Python3 library for [Tibber](https://tibber.com/).
Get electricity price and consumption.
If you have a Tibber Pulse or Watty you can see your consumption in real time.
[Buy me a coffee :)](http://paypal.me/dahoiv)
Go to [developer.tibber.com/](https://developer.tibber.com/) to get your API token.
## Install
```
pip3 install pyTibber
```## Example:
```python
import tibber.const
import tibber
import asyncioasync def start():
tibber_connection = tibber.Tibber(tibber.const.DEMO_TOKEN, user_agent="change_this")
await tibber_connection.update_info()
print(tibber_connection.name)home = tibber_connection.get_homes()[0]
await home.fetch_consumption_data()
await home.update_info()
print(home.address1)await home.update_price_info()
print(home.current_price_info)# await tibber_connection.close_connection()
loop = asyncio.run(start())
```## Example realtime data:
An example of how to subscribe to realtime data (Pulse/Watty):
```python
import tibber.const
import asyncioimport aiohttp
import tibberdef _callback(pkg):
print(pkg)
data = pkg.get("data")
if data is None:
return
print(data.get("liveMeasurement"))async def run():
async with aiohttp.ClientSession() as session:
tibber_connection = tibber.Tibber(tibber.const.DEMO_TOKEN, websession=session, user_agent="change_this")
await tibber_connection.update_info()
home = tibber_connection.get_homes()[0]
await home.rt_subscribe(_callback)while True:
await asyncio.sleep(10)loop = asyncio.run(run())
```The library is used as part of Home Assistant.