-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.py
61 lines (52 loc) · 1.96 KB
/
example.py
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
"""Test run."""
import asyncio
import json
from pathlib import Path
from aiotedee import TedeeClient
from aiotedee.lock import TedeeLock
async def main():
with open(f"{Path(__file__).parent}/config.json", encoding="utf-8") as f:
data = json.load(f)
# personal_token = data["personalToken"]
ip = data["ip"]
local_token = data["localToken"]
# client = await TedeeClient.create(personal_token, local_token, ip)
client = TedeeClient(local_ip=ip, local_token=local_token)
# await client.cleanup_webhooks_by_host("test")
# bridge = await client.get_local_bridge()
# await client.delete_webhook(5)
# await client.register_webhook("http://192.168.1.151/events")
await client.get_locks()
# await client.sync()
# await client.sync()
# bridges = await client.get_bridges()
# client = await TedeeClient.create(
# personal_token, local_token, ip, bridge_id=bridges[0].bridge_id
# )
locks = client.locks
print(1)
await client.sync()
print(2)
await client.sync()
for lock in locks:
print("----------------------------------------------")
print("Lock name: " + lock.lock_name)
print("Lock id: " + str(lock.lock_id))
print("Lock Battery: " + str(lock.battery_level))
print("Is Locked: " + str(client.is_locked(lock.lock_id)))
print("Is Unlocked: " + str(client.is_unlocked(lock.lock_id)))
# await client.register_webhook("http://test.local", headers=[{"Authorization": "Basic " + "test"}])
print(3)
await client.sync()
await client.unlock(lock.lock_id)
# await asyncio.sleep(5)
# await client.open(lock.id)
# await asyncio.sleep(5)
# await client.open(lock.id)
# await asyncio.sleep(5)
# await client.lock(lock.id)
# await asyncio.sleep(5)
# await client.unlock(lock.id)
# await asyncio.sleep(5)
# await client.pull(lock.id)
asyncio.run(main())