ioBroker.unifi icon indicating copy to clipboard operation
ioBroker.unifi copied to clipboard

Reconnect WiFi client #466 (reopened because of stall)

Open cavernerg opened this issue 2 years ago • 4 comments

Describe the idea by @Tranquility76 Hi,

in the Unifi App and Webinterface you have the option to reconnect a WiFi client initiated by the AP. This is useful if you have IoT devices that sometime hangup in the WiFi connection. (can be recognized if the "experience" value of the client goes down)

If you press "reconnect" the AP drops the connection of the client and the client reconnects and everything is fine. I would like to automated this "reconnect", but the adapter is missing this functionality.

cavernerg avatar May 04 '22 04:05 cavernerg

https://github.com/Art-of-WiFi/UniFi-API-client/blob/master/src/Client.php#335 Line 335 describes the desired function. Can this possibly be done with node-unifi and a javascript-script by now?

cavernerg avatar May 04 '22 04:05 cavernerg

I think it would be a very useful feature for many users. I will use it.

Duggles1301 avatar May 08 '22 21:05 Duggles1301

Es war möglich mit diesem Skript. Leider kriege ich seit neuestem einen 403er dazu.

`const Unifi = require('node-unifi'); const unifi = new Unifi.Controller({host: '192.168.178.1', port: '443', sslverify: false});

var macID;

on({id: "0_userdata.0.vis.ReconnectNetworkDevices.macID"/macID/, change: "ne"}, async function (obj) { console.log('Ausgelöst'); //console.log(obj.state ? obj.state.val : ""); var value = obj.state.val; var oldValue = obj.oldState.val; if ((obj.state ? obj.state.val : "") != '') { await reconnectMacID(value); } setStateDelayed('0_userdata.0.vis.ReconnectNetworkDevices.macID', '', false, parseInt(((5000) || "").toString(), 10), false); });

function reconnectMacID(macID) { (async () => { try { // LOGIN const loginData = await unifi.login('user', 'password'); console.log('login: ' + loginData);

// GET SITE STATS
const reconnect = await unifi.reconnectClient(macID);
console.log('Reconnect: ' + reconnect);
console.log(JSON.stringify(reconnect));



// LOGOUT
const logoutData = await unifi.logout();
console.log('logout: ' + JSON.stringify(logoutData));

} catch (error) { console.log('ERROR: ' + error); } })(); }

`

cavernerg avatar Aug 01 '22 15:08 cavernerg

I think the issue can be closed #597

pafade89 avatar Sep 12 '23 11:09 pafade89