SHARE
TWEET

Untitled

a guest Mar 18th, 2019 83 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.         var getDeviceSchema = new NodeSchema("get-device-state", "getDeviceState");
  2.         getDeviceSchema.name = "Get Device State";
  3.         getDeviceSchema.description = "Get the state of a specific device";
  4.         getDeviceSchema.config.add("deviceId", "home.automation.data.providers.DeviceListProvider");
  5.         var output = getDeviceSchema.outputs.add("deviceState", "home.automation.data.values.DeviceState");
  6.         output.label = "Device State";
  7.         NodeSchemaManager.register(getDeviceSchema);
  8.        
  9.         var setDeviceSchema = new NodeSchema("set-device-state", "setDeviceState");
  10.         setDeviceSchema.name = "Set Device State";
  11.         setDeviceSchema.description = "Set the state of a specific device";
  12.         setDeviceSchema.config.add("deviceId", "home.automation.data.providers.DeviceListProvider");
  13.         var input = setDeviceSchema.inputs.add("deviceState", "home.automation.data.values.DeviceState");
  14.         input.label = "Device State";
  15.         NodeSchemaManager.register(setDeviceSchema);
  16.        
  17.         var conditionSchema = new NodeSchema("condition", "condition");
  18.         conditionSchema.name = "Condition";
  19.         conditionSchema.description = "Evaluate a condition based on inputs";
  20.         conditionSchema.inputs.variable = true;
  21.         conditionSchema.inputs.variableSubType = "home.automation.data.values.ConditionExpr";
  22.         conditionSchema.inputs.variableEditable = true;
  23.         conditionSchema.outputs.variable = true;
  24.         conditionSchema.outputs.variableEditable = true;
  25.         NodeSchemaManager.register(conditionSchema);
  26.        
  27.        
  28.        
  29.        
  30.        
  31.        
  32.        
  33.        
  34.         var getDeviceState1 = new Node("get-device-state");
  35.         getDeviceState1.meta.set("x", 30);
  36.         getDeviceState1.meta.set("y", 30);
  37.         getDeviceState1.config.set("deviceId", "window-1");
  38.        
  39.         var getDeviceState2 = new Node("get-device-state");
  40.         getDeviceState2.meta.set("x", 30);
  41.         getDeviceState2.meta.set("y", 300);
  42.         getDeviceState2.config.set("deviceId", "window-2");
  43.  
  44.         var getDeviceState3 = new Node("get-device-state");
  45.         getDeviceState3.meta.set("x", 30);
  46.         getDeviceState3.meta.set("y", 600);
  47.         getDeviceState3.config.set("deviceId", "temp-sensor-1");
  48.  
  49.         var condition1 = new Node("condition");
  50.         condition1.meta.set("x", 400);
  51.         condition1.meta.set("y", 200);
  52.        
  53.         var setDeviceState1 = new Node("set-device-state");
  54.         setDeviceState1.meta.set("x", 800);
  55.         setDeviceState1.meta.set("y", 30);
  56.         setDeviceState1.config.set("deviceId", "light-1");
  57.        
  58.         var setDeviceState2 = new Node("set-device-state");
  59.         setDeviceState2.meta.set("x", 800);
  60.         setDeviceState2.meta.set("y", 300);
  61.         setDeviceState2.config.set("deviceId", "light-2");
  62.  
  63.         var setDeviceState3 = new Node("set-device-state");
  64.         setDeviceState3.meta.set("x", 800);
  65.         setDeviceState3.meta.set("y", 600);
  66.         setDeviceState3.config.set("deviceId", "heater-1");
  67.        
  68.        
  69.        
  70.        
  71.         var graph = new Graph();
  72.         graph.addNode(getDeviceState1);
  73.         graph.addNode(getDeviceState2);
  74.         graph.addNode(getDeviceState3);
  75.         graph.addNode(condition1);
  76.         graph.addNode(setDeviceState1);
  77.         graph.addNode(setDeviceState2);
  78.         graph.addNode(setDeviceState3);
  79.        
  80.        
  81.         var c = graph.connectNodes(getDeviceState1, "deviceState", condition1, "input1");
  82.         var c = graph.connectNodes(getDeviceState2, "deviceState", condition1, "input2");
  83.         var c = graph.connectNodes(getDeviceState3, "deviceState", condition1, "input3");
  84.  
  85.         var c = graph.connectNodes(condition1, "output1", setDeviceState1, "deviceState");
  86.         var c = graph.connectNodes(condition1, "output1", setDeviceState2, "deviceState");
  87.         var c = graph.connectNodes(condition1, "output2", setDeviceState3, "deviceState");
  88.         //var c = graph.connectNodes(condition1, "output3", setDeviceState1, "deviceState");
  89.        
  90.        
  91.        
  92.         var graphUI = new GraphUI();
  93.         graphUI.container = graphContainer;
  94.         graphUI.graph = graph;
  95.         graphUI.render();
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top