def alarm_action(request, action): s7conn = getS7Conn() a = alarm.Alarm(s7conn) if action == 'arm': a.arm() elif action == 'disarm': a.disarm() elif action == 'toggle_detector': idInt = 0 try: idInt = int(request.REQUEST["id"]) except: raise Http404 d = alarm.getDetectorByID(s7conn, idInt) d.toggle() context = { 'tag': 'lights', 'alarm': a, 'detectors': alarm.getDetectors(s7conn) } return render(request, "alarm.html", context)
@login_required def alarm_index(request): s7conn = getS7Conn() a = alarm.Alarm(s7conn) balance = "N/A" try: balance = float(sms.query_balance()) except Exception, e: logging.error("Failed to retrieve SMS account balance: %s" % e) context = { 'tag': 'alarm', 'alarm': a, 'detectors': alarm.getDetectors(s7conn), 'balance': balance } return render(request, "alarm.html", context) @csrf_exempt @login_required def alarm_action(request, action): s7conn = getS7Conn() a = alarm.Alarm(s7conn) if action == 'arm': a.arm() elif action == 'disarm': a.disarm() elif action == 'toggle_detector':
@login_required def alarm_index(request): s7conn = getS7Conn() a = alarm.Alarm(s7conn) balance = "N/A" try: balance = float(sms.query_balance()) except Exception, e: logging.error("Failed to retrieve SMS account balance: %s" % e) context = { 'tag': 'alarm', 'alarm': a, 'detectors': alarm.getDetectors(s7conn), 'balance': balance } return render(request, "alarm.html", context) @csrf_exempt @login_required def alarm_action(request, action): s7conn = getS7Conn() a = alarm.Alarm(s7conn) if action == 'arm': a.arm() elif action == 'disarm': a.disarm() elif action == 'toggle_detector': idInt = 0