-
Notifications
You must be signed in to change notification settings - Fork 29
/
run_aio.py
52 lines (42 loc) · 1.5 KB
/
run_aio.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
#%%
import asyncio
import json
import logging
import os
import random
import time
from pysiaalarm.aio import SIAAccount, SIAClient, SIAEvent
logging.basicConfig(level=logging.DEBUG)
async def main():
events = []
async def func(event: SIAEvent):
# if random.random() > 0.8:
# raise ValueError
events.append(event)
with open("tests\\ha.json", "r") as f:
config = json.load(f)
account = [SIAAccount(config["account_id"], config["key"])]
async with SIAClient(
config["host"], config["port"], account, function=func
) as client:
# client.start()
sleep_time = 12000
print("--------------------------------------------------")
# await asyncio.sleep(20)
# print(f"Client started... adding extra account")
# accounts = client.accounts
# accounts.append(SIAAccount("FFFFFFFFF", config["key"]))
# client.accounts = accounts
# print("--------------------------------------------------")
print(f"Running for another {sleep_time} seconds")
await asyncio.sleep(sleep_time / 2)
print(client.counts)
await asyncio.sleep(sleep_time / 2)
print("--------------------------------------------------")
# for ev in events:
# print(ev)
print("--------------------------------------------------")
print(len(events))
print(client.counts)
print("--------------------------------------------------")
asyncio.run(main())