Beispiel #1
0
def alarm(zone_name, state):
    # Check if we're activated
    if global_storage["alarm_zones_activated"] == False:
        return "done"
    # Check valid input
    assert zone_name in alarm_state
    assert state in ["good", "bad"]
    
    # Update state table
    alarm_state[zone_name] = state
    
    # Redraw our graphics.
    cur_floor = None
    if zone_name in big_bottom:
        floor = "bottom"
        cur_floor = big_bottom
    elif zone_name in big_middle:
        floor = "middle"
        cur_floor = big_middle
    elif zone_name in big_top:
        floor = "top"
        cur_floor = big_top
        
    draw_image(floor, "big", [zone for zone in alarm_state if alarm_state[zone] == "bad" and zone in cur_floor], global_storage["img_count"])
    draw_image(floor, "small", [zone for zone in alarm_state if alarm_state[zone] == "bad" and zone in cur_floor], global_storage["img_count"])
    key = {"top": "h", "middle": "i", "bottom": "j"}[floor]
    os.system("/opt/casa/helpers/send_key.sh %s" % key)
    global_storage["img_count"] += 1
    return "done"
Beispiel #2
0
import time
import os
import threading

from alarm_graphics import draw_image
from alarm_graphics_constants import big_bottom, big_middle, big_top

app = Flask(__name__)
global_storage = {"img_count": 1, "alarm_zones_activated": False}
alarm_state = {}

for entry in big_bottom: alarm_state[entry] = "good"
for entry in big_middle: alarm_state[entry] = "good"
for entry in big_top: alarm_state[entry] = "good"

draw_image("top", "big", [zone for zone in alarm_state if alarm_state[zone] == "bad" and zone in "top"], 0)
draw_image("top", "small", [zone for zone in alarm_state if alarm_state[zone] == "bad" and zone in "top"], 0)

draw_image("middle", "big", [zone for zone in alarm_state if alarm_state[zone] == "bad" and zone in "middle"], 0)
draw_image("middle", "small", [zone for zone in alarm_state if alarm_state[zone] == "bad" and zone in "middle"], 0)

draw_image("bottom", "big", [zone for zone in alarm_state if alarm_state[zone] == "bad" and zone in "bottom"], 0)
draw_image("bottom", "small", [zone for zone in alarm_state if alarm_state[zone] == "bad" and zone in "bottom"], 0)

VID_PATH = "/opt/casa/videos/"
AID_PATH = "/opt/casa/sounds/"
##### Updating commands - these are called by external devices to push thru status info.

@app.route("/alarm/zone/activate")
def activate():
    global_storage["alarm_zones_activated"] = True