Skip to content
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

Real time example #287

Merged
merged 2 commits into from
Jan 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ import asyncio
import aiohttp
import tibber

ACCESS_TOKEN = tibber.const.DEMO_TOKEN

def _callback(pkg):
print(pkg)
data = pkg.get("data")
Expand All @@ -73,16 +71,15 @@ def _callback(pkg):

async def run():
async with aiohttp.ClientSession() as session:
tibber_connection = tibber.Tibber(ACCESS_TOKEN, websession=session, user_agent="change_this")
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.get_event_loop()
loop.run_until_complete(run())
loop = asyncio.run(run())
```

The library is used as part of Home Assistant.
Expand Down