def nodelist(): if not zwave.net: abort(414) main_fields = [ "node_id", "name", "location", "product_name", "manufacturer_name" ] fields = [ "query_stage", "type", "specific", "product_type", "product_id", "manufacturer_id" ] status_props = [ "is_awake", "is_beaming_device", "is_failed", "is_frequent_listening_device", "is_info_received", "is_listening_device", "is_locked", "is_ready", "is_routing_device", "is_security_device", "is_sleeping", "is_zwave_plus" ] props = [ "basic", "capabilities", "command_classes", "device_type", "generic", "stats", "max_baud_rate", "neighbors", "num_groups", "role", "security", "version" ] tmp = main_fields + fields + status_props + props return ret_jajax([to_json(zwave.get_node_details(node_id, tmp)) \ for node_id in zwave.net.nodes])
def available_ctrl_actions(ctrl_idx=0): ctrl = zwave.ctrl[ctrl_idx] if len(zwave.ctrl) > ctrl_idx else None if ctrl is None or not zwave.net: return ret_jerr(404, "Network and/or Controller inactive") # @TODO: order these similar to the ones in node (also seperate POST/GET) return ret_jajax((CTRL_ACTIONS + CTRL_ATTRS))
def available_ctrl_actions(ctrl_idx=0): ctrl = zwave.ctrl[ctrl_idx] if len(zwave.ctrl) > ctrl_idx else None if ctrl is None: abort(415) if not zwave.net: abort(414) # @TODO: order these similar to the ones in node (also seperate POST/GET) return ret_jajax([ "start", "stop", "add_node", "assign_return_route", "cancel_command", "capabilities", "device", "is_primary_controller", "stats", "library_config_path", "library_description", "library_type_name", "library_user_path", "library_version", "name", "node", "node_id", "options", "owz_library_version", "python_library_config_version", ])
def available_net_actions(): if zwave.net is None: abort(414) return ret_jajax([ "heal", "start", "stop", "home_id", "is_ready", "nodes_count", "write_config", "get_scenes", "scenes_count", "test", "sleeping_nodes_count", "state" ])
def ctrlaction(action, ctrl_idx=0): ctrl = zwave.ctrl[ctrl_idx] if len(zwave.ctrl) > ctrl_idx else None if ctrl is None: abort(415) if not zwave.net: abort(414) if not hasattr(ctrl, action): abort(404) ret = get_member(ctrl, action, request.args) if isinstance(ret, set): ret = list(sorted(ret)) return ret_jajax({ "returned": ret, "executed": action, "controller": ctrl.to_dict() })
def ctrlaction(action, ctrl_idx=0): ctrl = zwave.ctrl[ctrl_idx] if len(zwave.ctrl) > ctrl_idx else None if ctrl is None or not zwave.net: return ret_jerr(404, "Network and/or Controller inactive") if action not in (CTRL_ACTIONS + CTRL_ATTRS): return ret_jerr(404, "Requested action: {} not available".format(action)) ret = action_handler(CTRL_ATTRS, CTRL_SUB_ACTIONS, CTRL_WRAPPED, action, request.args, zwave.get_main_ctrl(), zwave) if isinstance(ret, set): ret = list(sorted(ret)) return ret_jajax({ "returned": ret, "executed": action, "controller": ctrl.to_dict() })
def list_routes(): from random import randint output = [] for rule in app.url_map.iter_rules(): options = {} opt2str = {} for arg in rule.arguments: if arg in ["num", "node_id", "value_id", "index"]: opt2str[arg] = (randint(12331, 32425), "int") options[arg] = opt2str[arg][0] elif arg in ["member", "path"]: opt2str[arg] = (randint(54355, 68684), "string") options[arg] = str(opt2str[arg][0]) else: options[arg] = arg methods = ','.join(rule.methods) url = url_for(rule.endpoint, **options) for val, (num, dtype) in opt2str.items(): url = url.replace(str(num), "<{}:{}>".format(dtype, val)) line = urllib.parse.unquote("{:<35s} {:<40s} {:<20s}". \ format(url, methods, rule.endpoint)) output.append(line) return ret_jajax(list(sorted(output)))
def getgroups(node_id): x = [g.to_dict() for g in zwave.get_node(node_id).groups.values()] return ret_jajax(x)
def node_actions(): return ret_jajax((NODE_ACTIONS + NODE_ATTRS))
def nodelist(): if not zwave.net: return ret_jerr(404, "Network and/or Controller inactive") return ret_jajax([to_json(zwave.get_node_details(node_id, NODE_ATTRS)) \ for node_id in zwave.net.nodes])
def available_net_actions(): if zwave.net is None: return ret_jerr(404, "Network and/or Controller inactive") return ret_jajax((NET_ACTIONS + NET_ATTRS))
def netinfo(): if zwave.net is None: return ret_jerr(404, "Network and/or Controller inactive") return ret_jajax(zwave.net.to_dict())
def list_signals(): from signals import net_signals return ret_jajax([sig[0] for sig in net_signals])
def netinfo(): if zwave.net is None: abort(414) return ret_jajax(zwave.net.to_dict())