-
Notifications
You must be signed in to change notification settings - Fork 0
/
example_unified_smoke_test.py
62 lines (45 loc) · 1.62 KB
/
example_unified_smoke_test.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
62
"""Smoke test."""
import asyncio
import os
from rich import print
from intellifire4py import UnifiedFireplace
from intellifire4py.cloud_interface import IntelliFireCloudInterface
from intellifire4py.const import IntelliFireApiMode
import logging
logging.basicConfig(level=logging.DEBUG)
logging.getLogger("aiohttp").setLevel(logging.DEBUG)
def parse_env_file() -> None:
"""Parse .env file."""
with open(".env") as f:
for line in f:
try:
key, value = line.strip().split("=")
print("Writing key", key)
os.environ[key] = value
except FileNotFoundError:
print("-- Could not find a .env file")
pass
except ValueError:
pass
async def main() -> None:
"""Main smoketest."""
parse_env_file()
username = os.environ["IFT_USER"] # noqa: F841
password = os.environ["IFT_PASS"] # noqa: F841
# Make cloud interface
cloud_interface = IntelliFireCloudInterface(use_http=True)
# Load in user data
user_json: str = os.getenv("USER_JSON") # type: ignore
user_data = cloud_interface.load_user_data(user_json)
fp = (
await UnifiedFireplace.build_fireplaces_from_user_data(
user_data, use_http=True, verify_ssl=False
)
)[0]
await fp.set_read_mode(IntelliFireApiMode.NONE)
await fp.async_validate_connectivity(timeout=30)
print(f"Local [{fp.local_connectivity}] Cloud [{fp.cloud_connectivity}]")
print(fp.dump_user_data_json)
if __name__ == "__main__":
loop = asyncio.get_event_loop()
loop.run_until_complete(main())