Skip to content

Commit

Permalink
Add debug script
Browse files Browse the repository at this point in the history
  • Loading branch information
sebr committed Feb 9, 2022
1 parent 937bbb0 commit 3ed8287
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
@@ -1,4 +1,7 @@
.DS_Store
__pycache__
*.pyc

tmp

debug/[0-9]*
38 changes: 38 additions & 0 deletions debug/debug.py
@@ -0,0 +1,38 @@
# Script utility to debug device/program info from logs

import json
import os
import sys

if len(sys.argv) < 2:
print("Not enough arguments")
sys.exit()

folder = sys.argv[1]

script_dir = os.path.dirname(os.path.realpath(__file__))

devices_json = os.path.join(script_dir, folder + "/devices.json")

with open(devices_json) as devicesFile:
devices = json.load(devicesFile)
devicesFile.close()


for device in devices:
if device.get("type") == "bridge":
continue

name = device.get("name")

if device.get("type") == "sprinkler_timer":
zones = device.get("zones")
print(f"{'Sprinkler':>10}: {name}")
print(f"{'Zones':>10}: ({len(zones)})")
for zone in device.get("zones"):
zn = zone.get("name")
print(f"{zn:<12}: {zn}")

if device.get("type") == "flood_sensor":
print("Flood sensor:")
print(f" Name: {name:<6}")

0 comments on commit 3ed8287

Please sign in to comment.