forked from Isaksson/node-red-contrib-unifi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathunifi.html
269 lines (255 loc) · 16.3 KB
/
unifi.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
<script type="text/javascript">
RED.nodes.registerType('unificonfig', {
category: 'config',
defaults: {
name: { value: "" },
ip: { value: "", required: true },
port: { value: 8443, validate: RED.validators.number() },
site: { value: "default" },
unifios: { value: false },
ssl: { value: false },
},
credentials: {
username: { type: "text" },
password: { type: "password" }
},
label: function () {
return this.name || "Unifi Server";
}
});
</script>
<script type="text/x-red" data-template-name="unificonfig">
<div class="form-row">
<label for="node-config-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-config-input-name" placeholder="Name">
</div>
<div class="form-row">
<label for="node-config-input-ip"><i class="fa fa-globe"></i> Server</label>
<input class="input-append-left" type="text" id="node-config-input-ip" placeholder="IP Address" style="width: 40%;" >
<label for="node-config-input-port" style="margin-left: 10px; width: 35px; "> Port</label>
<input type="text" id="node-config-input-port" placeholder="Port" style="width:45px">
</div>
<div class="form-row">
<label> </label>
<input type="checkbox" id="node-config-input-unifios" placeholder="Unifi OS" style="display: inline-block; width: auto; vertical-align: top;">
<label for="node-config-input-unifios" style="width: 70%;">Unifi OS</label>
<br>
<label> </label>
<input type="checkbox" id="node-config-input-ssl" placeholder="SSL Verification" style="display: inline-block; width: auto; vertical-align: top;">
<label for="node-config-input-ssl" style="width: 70%;">SSL Verification</label>
</div>
<div class="form-row">
<label for="node-config-input-site"><i class="fa fa-list"></i> Site</label>
<input type="text" id="node-config-input-site" placeholder="Site Name">
</div>
<div class="form-row">
<label for="node-config-input-username"><i class="fa fa-user"></i> Username</label>
<input type="text" id="node-config-input-username" placeholder="Username">
</div>
<div class="form-row">
<label for="node-config-input-password"><i class="fa fa-lock"></i> Password</label>
<input type="password" id="node-config-input-password" placeholder="Password">
</div>
</script>
<script type="text/x-red" data-help-name="unificonfig">
<p>Shared configuration for the unifi controllers</p>
</script>
<script type="text/javascript">
RED.nodes.registerType('Unifi', {
category: 'output',
color: '#C0DEED',
defaults: {
name: { value: "" },
server: { type: "unificonfig", required: true },
command: { value: 1, required: true },
debug: { value: false },
},
inputs: 1,
outputs: 1,
icon: "bridge.png",
label: function () {
if (this.name) {
return this.name;
}
switch (this.command.toString()) {
case '1':
return 'Unifi: getSitesStats';
case '10':
return 'Unifi: getSiteSysinfo';
case '20':
return 'Unifi: getClientDevices';
case '30':
return 'Unifi: getAllUsers';
case '35':
return 'Unifi: getBlockedUsers';
case '40':
return 'Unifi: getUserGroups';
case '50':
return 'Unifi: getHealth';
case '60':
return 'Unifi: getDashboard';
case '70':
return 'Unifi: getAccessDevices';
case '80':
return 'Unifi: getRogueAccessPoints';
case '90':
return 'Unifi: getEvents';
case '100':
return 'Unifi: getAlarms';
case '110':
return 'Unifi: getWLanSettings';
case '120':
return 'Unifi: getPortConfig';
case '130':
return 'Unifi: getPortForwardSettings';
default:
return 'Unifi';
}
}
});
</script>
<script type="text/javascript">
RED.nodes.registerType('UnifiWS', {
category: 'output',
color: '#C0DEED',
defaults: {
name: { value: "" },
server: { type: "unificonfig", required: true },
},
inputs: 0,
outputs: 1,
icon: "bridge.png",
label: function () {
if (this.name) {
return this.name;
}
}
});
</script>
<script type="text/x-red" data-template-name="Unifi">
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-row">
<label for="node-input-server"><i class="fa fa-server"></i> Server</label>
<input type="text" id="node-input-server" placeholder="">
</div>
<div class="form-row">
<label for="node-input-command"><i class="fa fa-dot-circle-o"></i> Command</label>
<select id="node-input-command">
<option value="1">SitesStats</option>
<option value="10">SiteSysinfo</option>
<option value="20">ClientDevices</option>
<option value="30">AllUsers</option>
<option value="35">AllBlockedUsers</option>
<option value="40">UserGroups</option>
<option value="50">Health</option>
<option value="60">Dashboard</option>
<option value="70">AccessDevices</option>
<option value="80">RogueAccessPoints</option>
<option value="90">Events</option>
<option value="100">Alarms</option>
<option value="110">WLanSettings</option>
<option value="120">ListPortProfiles</option>
<option value="130">PortForwardSettings</option>
</select>
</div>
<div class="form-row">
<label for="node-input-debug"><i class="fa fa-bug"></i> Debug</label>
<input type="checkbox" id="node-input-debug" placeholder="Debug" style="display: inline-block; width: auto; vertical-align: top;">
</div>
</script>
<script type="text/x-red" data-template-name="UnifiWS">
<div class="form-row">
Alpha version: At this point anything could change or not work.
</div>
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-row">
<label for="node-input-server"><i class="fa fa-server"></i> Server</label>
<input type="text" id="node-input-server" placeholder="">
</div>
</script>
<script type="text/x-red" data-help-name="Unifi">
<p>Connects to a Unifi Controller and query/control UniFi devices.</p>
<p><code>msg.payload.command</code> is used to override the command selected in the node.<br> Example how to send a command from a function Node<br> <code>msg.payload = { command: "ClientDevices"};</code></p>
<p>Available Commands:</p>
<ul>
<li><code>SitesStats</code> : Site stats</li>
<li><code>SiteSysinfo</code> : Site sysinfo</li>
<li><code>ClientDevices</code> : Online client device(s)</li>
<li><code>AllUsers</code> : All client devices ever connected to the site</li>
<li><code>AllBlockedUsers</code> : All blocked client devices ever connected to the site</li>
<li><code>UserGroups</code> : User groups</li>
<li><code>Health</code> : Health metrics</li>
<li><code>Dashboard</code> : Dashboard metrics</li>
<li><code>AccessDevices</code> : Access points</li>
<li><code>RogueAccessPoints</code> : Rogue access points</li>
<li><code>Events</code> : Events</li>
<li><code>Alarms</code> : Alarms</li>
<li><code>WLanSettings</code> : WLan Settings</li>
<li><code>ListPortProfiles</code> : List Port Profiles</li>
<li><code>PortForwardSettings</code> : Port Forward Settings</li>
</ul>
<p>Special Commands: (No GUI)</p>
<li><code>DisableWLan</code> : Disable/Enable WLan { command: "disableWLan", wlan_id: "use _id from command WLanSettings", disable: true }</li>
<li><code>DisablePortForward</code> : Disable/Enable PortForward { command: "disablePortForward", portforward_id: "use _id from command PortForwardSettings", disable: true }</li>
<li><code>blockClient</code> : Block Client { command: "blockClient", mac: "client MAC address" }</li>
<li><code>unblockClient</code> : Unblock Client { command: "unblockClient", mac: "client MAC address" }</li>
<li><code>reconnectClient</code> : Reconnect Client { command: "reconnectClient", mac: "client MAC address" }</li>
<li><code>authorizeGuest</code> : Authorize Client { command: "authorizeGuest", mac: "client MAC address", minutes: "minutes until authorization expires" }</li>
<li><code>unauthorizeGuest</code> : Unauthorize Client { command: "unauthorizeGuest", mac: "client MAC address" }</li>
<li><code>restartAP</code> : Reboot an Access point { command: "restartAP", mac: "device MAC address" }</li>
<li><code>enableAP</code> : Enable an Access point { command: "enableAP", device_id: "24 char device id" }</li>
<li><code>disableAP</code> : Disable an Access point { command: "disableAP", device_id: "24 char device id" }</li>
<li><code>setAPLed</code> : Set LED for Access point { command: "setapled", device_id: "24 char device id", mode: "off/on/default" }</li>
<li><code>setSiteLed</code> : Set LED for Site { command: "setsiteled", mode: true/false }</li>
<li><code>site</code> : Connect to site name { site: "site name"}</li>
<li><code>getFirewallGroups</code> : Get list of firewall groups { command: "getFirewallGroups" }</li>
<li><code>addFirewallGroup</code> : Add firewall group { command: "addFirewallGroup", group_name: "group-name", group_type: "address-group|ipv6-address-group|port-group", group_members: ["CIDRs", "IPs"] }</li>
<li><code>editFirewallGroup</code> : Edit firewall group { command: "editFirewallGroup", group_id: "group id", group_name: "group-name", group_type: "address-group|ipv6-address-group|port-group", group_members: ["CIDRs", "IPs"] }</li>
<li><code>deleteFirewallGroup</code> : Delete firewall group { command: "deleteFirewallGroup", group_id: "group id" }</li>
<li><code>getFirewallRules</code> : Get a list of firewall rules { command: "getFirewallRules" }</li>
<li><code>getFirewallRule</code> : Get a firewall rule { command: "getFirewallRule, rule_id: "id" }</li>
<li><code>getFirewallRuleByName</code> : Get a firewall rule by its name{ command: "getFirewallRuleByName, rule_name: "name" }</li>
<li><code>enableFirewallRule</code> : Enable a firewall rule { command: "enableFirewallRule", rule_id: "id" }</li>
<li><code>disableFirewallRule</code> : Disable a firewall rule { command: "disableFirewallRule", rule_id: "id" }</li>
<li><code>getPoePortState</code> : Get the PoE state of port x { command: "getPoePortState", device_id: "id", port: "port number" }</li>
<li><code>enablePoePort</code> : Enable POE on port x { command: "enablePoePort", device_id: "id", port: "port number", poe_mode: "off|auto|pasv24|passthrough" }</li>
<li><code>disablePoePort</code> : Disable POE on port x { command: "disablePoePort", device_id: "id", port: "port number" }</li>
<li><code>forceProvision</code> : Force provision { command: "forceProvision", mac: "device MAC address" }</li>
<li><code>setPortProfiles</code> : setPortProfiles: Set overrides for multiple ports of a device { command: "setPortProfiles", device_id: "24 char device id", port_overrides: [ {"port_idx": 1, "portconf_id": "id of the port profile", "name": "friendly name of the port", "poe_mode": "off|auto" }, ... ] }</li>
<li><code>setLocate</code> : Enable flash device LED (or other indication based on device) { command: "setLocate", mac: "device MAC address" }</li>
<li><code>unsetLocate</code> : Disable flash device LED (or other indication based on device) { command: "unsetLocate", mac: "device MAC address" }</li>
<li><code>setWLanPassword</code> : Change WLan password { command: "setWLanPassword", wlan_id: "SSID ID", x_passphrase: "New password" }</li>
<li><code>getVouchers</code> : Get available Vouchers from Guest Portal { command: "getVouchers" }</li>
<li><code>createVouchers</code> : Create new Vouchers for Guest Usage { command: "createVouchers", minutes: "expiration time in minutes", count: "number of vouchers", quota: "'0' is for multi-use, '1' is for single-use", note: "note added to voucher", up: "upload speed limit in kbps (remove if not used)", down: "download speed limit in kbps (remove if not used)", mbytes: "data transfer limit in MB (remove if not used)"}</li>
<li><code>revokeVouchers</code> : Revoke voucher { command: "revokeVouchers", voucher_id : "24 char _id of the voucher" }</li>
<li><code>clientDevices</code> : Returns a single client device { command: "clientDevices", mac: "device MAC address" }</li>
<li><code>enableTrafficManagementRule</code> : Enable a traffic management rule { command: "enableTrafficManagementRule", rule_id: "id" }</li>
<li><code>disableTrafficManagementRule</code> : Disable a traffic management rule { command: "disableTrafficManagementRule", rule_id: "id" }</li>
<li><code>getTrafficManagementRule</code> : Get traffic management rules, optional add rule_id { command: "getTrafficManagementRule", rule_id: "id" }</li>
<li><code>getWLanSetting</code> : Get WLan setting for selected WLan { command: "getWLanSetting", wlan_id: "id" }</li>
<li><code>setWLanFilter</code> : Set Device Access Filtering { command: "setWLanFilter", wlan_id: "id", policy: "allow|deny", mac: ['MAC Address'] }</li>
<li><code>setDNSServer</code> : Set DHCP DNS Server 1 and 2 { command: "setDNSServer", network_id: "id", dns1: "x.x.x.x", dns2: "x.x.x.x" }</li>
<li><code>getNetworkConf</code> : Get network configuration { command: "getNetworkConf" }</li>
<li><code>setAPLedColor</code> : Set LED color for Access point { command: "setapledcolor", device_id: "24 char device id", color: "Color Hex code" }</li>
<li><code>getRadiusUsers</code> : Get all radius users { command: "getRadiusUsers" }</li>
<li><code>getRadiusProfiles</code> : Get all radius profiles { command: "getRadiusProfiles" }</li>
<li><code>createRadiusUser</code> : Create radius user { command: "createRadiusUser", name: "account name", x_password: "password", tunnel_type: "optional 1-13", tunnel_medium_type: "optional 1-15", vlan: "optional vlan id" }</li>
<li><code>updateRadiusUser</code> : Update radius user { command: "updateRadiusUser", user_id: "24 char string _id of the user", name: "optional account name", x_password: "optional password", tunnel_type: "optional 1-13", tunnel_medium_type: "optional 1-15", vlan: "optional vlan id" }</li>
<li><code>deleteRadiusUser</code> : Delete radius user { command: "deleteRadiusUser", user_id: "24 char string _id of the user" }</li>
<p>Returns all data in JSON parsable strings/objects</p>
<p>For more information see the <a href="https://github.com/Isaksson/node-red-contrib-unifi" target="_blank">GitHub</a> site.</p>
<p>Version 0.3.10</p>
</script>
<script type="text/x-red" data-help-name="UnifiWS">
<p><u>BETA</u></p>
<p>Connects to a Unifi Controller</p>
<p>Returns all data in JSON parsable strings/objects</p>
<p>For more information see the <a href="https://github.com/Isaksson/node-red-contrib-unifi" target="_blank">GitHub</a> site.</p>
<p>Version 0.3.10</p>
</script>