Files
TotalConnect/check_fullstatus_json.py
T

26 lines
918 B
Python
Executable File

import json
from total_connect_client.client import TotalConnectClient
from total_connect_client.const import make_http_endpoint
creds = json.load(open('credentials.json', encoding='utf-8'))['accounts'][0]
client = TotalConnectClient(creds['username'], creds['password'], load_details=False)
client.authenticate()
location_id = 1417027
endpoint = make_http_endpoint(f"api/v3/locations/{location_id}/partitions/fullStatus")
res = client.http_request(endpoint=endpoint, method="GET")
print("Keys at root of fullStatus response:")
print(list(res.keys()))
print("\nValue of ArmingState at root:")
print(res.get("ArmingState"))
print("\nValue of PanelStatus -> ArmingState:")
panel_status = res.get("PanelStatus", {})
print(panel_status.get("ArmingState"))
print("\nPartitions data:")
for p in panel_status.get("Partitions", []):
print(f" PartitionID={p.get('PartitionID')}, ArmingState={p.get('ArmingState')}")