Skip to content

Commit

Permalink
Real time example (#287)
Browse files Browse the repository at this point in the history
* Update README.md

* Update README.md
  • Loading branch information
Danielhiversen committed Jan 28, 2024
1 parent f0df710 commit d0ffcab
Showing 1 changed file with 2 additions and 5 deletions.
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

0 comments on commit d0ffcab

Please sign in to comment.