def automation_actuator(actuatorname, state): if debug: print 'automation_actuator' actuator = automation.FindActuator(actuatorname) if actuator: stateMap = {'0':0, '1':1, 'on':1, 'off':0} if state in stateMap: actuator.SetState(stateMap[state]) flash('Actuator ' + actuatorname + ' turned ' + actuator.StateStr()) return redirect_back('automation_actuators')
def automation_add_actuator(controller_name): if debug: print 'automation_add_actuator' next = get_redirect_target() error_dict = DefaultDict() config_dict = StrippedCopy(request.form) param = DefaultDict(config_dict) controller = automation.FindController(controller_name) if not controller: flash('Unable to find controller named ' + controller_name) return redirect_back('automation_actuators') title = 'Add Actuator for ' + controller.Name() param['action'] = 'Add' if request.method == 'POST': if 'action' in request.form: del config_dict['action'] controller.ValidateNewActuator(config_dict, error_dict) if ErrorFound(error_dict): return render_template('automation-edit-actuator.html', title=title, controller=controller, next=next, error=error_dict, param=param) actuator = automation.AddActuator(controller, config_dict) flash('Added Actuator: ' + actuator.Names()) return redirect_back('automation_actuators') param['Controller'] = controller.Name() param['Order'] = automation.NextOrder() return render_template('automation-edit-actuator.html', title=title, controller=controller, next=next, error=error_dict, param=param)
def automation_add_controller(controller_type_name): if debug: print 'automation_add_controller' error_dict = DefaultDict() config_dict = StrippedCopy(request.form) param = DefaultDict(config_dict) controller_type = automation.FindControllerType(controller_type_name) if not controller_type: flash("No controller type named '" + controller_type_name + "'", 'error') return redirect(url_for('automation_controllers')) title = 'Add Controller for ' + controller_type.Name() param['action'] = 'Add' if request.method == 'POST': if 'action' in request.form: del config_dict['action'] controller_type.ValidateNewController(config_dict, error_dict) if ErrorFound(error_dict): return render_template('automation-edit-controller.html', title=title, controller_type=controller_type, error=error_dict, param=param) controller = automation.AddController(controller_type, param) flash('Added Controller: ' + controller.Name()) return redirect_back('automation_controllers') param['Type'] = controller_type.Name() return render_template('automation-edit-controller.html', title=title, controller_type=controller_type, error=error_dict, param=param)