| ------------------------ | ---------------------------------------------- |--------- | ------- |
| host | Hostname of IP address of the UniFi Controller | Required | - |
| port | Port of the UniFi Controller | Required | - |
+| unifios | If the UniFi Controller is running on UniFi OS | Required | false |
| username | The username to access the UniFi Controller | Required | - |
| password | The password to access the UniFi Controller | Required | - |
| refresh | Refresh interval in seconds | Optional | 10 |
things/unifi.things
```
-Bridge unifi:controller:home "UniFi Controller" [ host="unifi", port=8443, username="$username", password="$password", refresh=10 ] {
+Bridge unifi:controller:home "UniFi Controller" [ host="unifi", port=8443, unifios=false, username="$username", password="$password", refresh=10 ] {
Thing wirelessClient matthewsPhone "Matthew's iPhone" [ cid="$cid", site="default", considerHome=180 ]
}
```
// Public API
public void start() throws UniFiException {
+ if (unifios) {
+ obtainCsrfToken();
+ }
+
login();
}
logout();
}
- public void login() throws UniFiException {
+ public void obtainCsrfToken() throws UniFiException {
csrfToken = "";
+ UniFiControllerRequest<Void> req = newRequest(Void.class);
+ req.setPath("/");
+ executeRequest(req);
+ }
+
+ public void login() throws UniFiException {
UniFiControllerRequest<Void> req = newRequest(Void.class);
req.setPath(unifios ? "/api/auth/login" : "/api/login");
req.setBodyParameter("username", username);