phlyght/test.py

24 lines
540 B
Python
Raw Normal View History

2022-11-30 12:08:35 +00:00
from asyncio import run, get_running_loop, sleep
2022-11-28 02:43:36 +00:00
2022-11-30 12:08:35 +00:00
from phlyght.http import Router
from phlyght import models
2022-11-28 02:43:36 +00:00
2022-11-28 08:54:10 +00:00
try:
from rich import print # noqa
except ImportError:
...
2022-11-28 02:43:36 +00:00
async def main():
2022-11-30 12:08:35 +00:00
router = Router("Your Bridge Auth key", bridge_ip="https://192.168.1.1")
# this will start listening in the background for all events sent out by the bridge
router.subscribe()
2022-11-28 10:48:43 +00:00
2022-11-29 23:14:56 +00:00
while True:
2022-11-30 12:08:35 +00:00
# this will query for all lights every 10 seconds
print(await router.get_lights)
await sleep(10.0)
2022-11-28 02:43:36 +00:00
run(main())