How to re-connect client / Is it possible? [SOLVED]

Posted on
Tue Jan 30, 2018 7:34 am
autolog offline
Posts: 3988
Joined: Sep 10, 2013
Location: West Sussex, UK [GMT aka UTC]

How to re-connect client / Is it possible? [SOLVED]

Hi Karl,
In the UniFi Dashboard Client tab, it is possible to click on a reconnect button to force a reconnect to a client device.
Is it possible to do this via the plugin?

Scenario is that I have a problematic LIFX bulb (a downlighter that has a large RSJ beam directly line of sight between it and the UniFi AP) that goes no-ack (MIA) and a reconnect seems to sort out the issue. I can detect when this happens in my LIFX plugin and if I could force a reconnect, it would help resolve my issue. :)
Last edited by autolog on Thu Feb 01, 2018 1:53 am, edited 1 time in total.

Posted on
Tue Jan 30, 2018 10:09 am
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: How to re-connect client / Is it possible?

the plugin does NOT talk to the unifi key ..

if we can do this on the switch , router or AP yes ..

the POE power cycle is done on the switch level though an ssh session .. If you can find something on the discussion forums let me know .. I have not found anything

here is how the power cycle works:

Code: Select all
set userID [lindex $argv 0 ]
set password [lindex $argv 1 ]
set ipNumber [lindex $argv 2 ]
set port [lindex $argv 3]
set endToken [lindex $argv 4]

set timeout 10
spawn  ssh $userID@$ipNumber
expect {
    "(yes/no)? " {
        send "yes\n"
        sleep 0.1
        expect "assword: " { send "$password\n"}
    }
    "assword: " {
        send "$password\n"
    }
}

sleep 1
expect "$endToken" {
    sleep 0.1
    send "telnet localhost 23\r"
    sleep 0.1
    send "enable\r"
    sleep 0.05
    send "configure\r"
    sleep 0.05
    send "interface 0/$port\r"
    sleep 0.05
    send "poe opmode shutdown\r"
    sleep 0.3
    send "poe opmode auto\r"
    sleep 0.05
    send "exit\r"
    sleep 0.05
    send "exit\r"
    sleep 0.05
    send "exit\r"
    sleep 0.05
    send "exit\r"
    sleep 0.05
    send "exit\r"
    }
sleep 0.2
expect eof

Posted on
Tue Jan 30, 2018 11:37 am
autolog offline
Posts: 3988
Joined: Sep 10, 2013
Location: West Sussex, UK [GMT aka UTC]

Re: How to re-connect client / Is it possible?

Found this on github: Art-of-WiFi/UniFi-API-client

It is written for PHP and based on some info released by Ubiquiti and some wire-sharking.

There is a Request for an API thread here: API full documentation

Not sure if this is any help? :)

Posted on
Tue Jan 30, 2018 11:54 am
DaveL17 offline
User avatar
Posts: 6743
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: How to re-connect client / Is it possible?

Code: Select all
expect "assword:

Is that anything like an #assToggle? :D

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Tue Jan 30, 2018 12:06 pm
Colorado4Wheeler offline
User avatar
Posts: 2794
Joined: Jul 20, 2009
Location: Colorado

Re: How to re-connect client / Is it possible?

Yes, I think it is...

My Modest Contributions to Indigo:

HomeKit Bridge | Device Extensions | Security Manager | LCD Creator | Room-O-Matic | Smart Dimmer | Scene Toggle | Powermiser | Homebridge Buddy

Check Them Out Here

Posted on
Wed Jan 31, 2018 4:34 pm
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: How to re-connect client / Is it possible?

this seem to do the trick:
Code: Select all
curl  --insecure -c /tmp/unificookie  --data "{'username':'YOURID','password':'YOURPWD'}" https://YOURIP:8443/api/login
curl  --insecure -b /tmp/unificookie  --data '{"cmd":"kick-sta","mac":"xx:xx:xx:xx:xx:xx"}'  https://YOURIP:8443/api/s/default/cmd/stamgr
1. login and store the login token in/tmp/unificookie ("-c"); "-- insecure" as you likely have not a registered certificate on your cloud-key
2. send cmd kick-sta for mac # xx.xx.xx.... to stamgr with "-b" read cookie
replace "default" with your site name and mac # must be lower case.. and ip and userid / pwd

will add this to the plugin

Karl

Posted on
Wed Jan 31, 2018 9:55 pm
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: How to re-connect client / Is it possible?

Jon,

try v 7.10.80 it has re-connect as well as block / unblock menus/actions


Karl

Posted on
Thu Feb 01, 2018 1:51 am
autolog offline
Posts: 3988
Joined: Sep 10, 2013
Location: West Sussex, UK [GMT aka UTC]

Re: How to re-connect client / Is it possible?

Hi Karl,

Brilliant, it works very well. :D

Thank you for doing this, it really is appreciated. :)

Posted on
Thu Feb 01, 2018 12:26 pm
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: How to re-connect client / Is it possible? [SOLVED]

looking into adding some more items to it ..

hesitating to add things like shutdown gateway .. setup networks .. they do not make sense to have them automated from indigo

could you check out https://github.com/Art-of-WiFi/UniFi-API-client/blob/master/src/Client.php

which of those makes sense to add?

have added print unifi system device info

Posted on
Thu Feb 01, 2018 12:50 pm
autolog offline
Posts: 3988
Joined: Sep 10, 2013
Location: West Sussex, UK [GMT aka UTC]

Re: How to re-connect client / Is it possible? [SOLVED]

Hi Karl,
I have had a quick look and not sure how much more needs adding?
I think one really needs a use case for each one to say why it would be useful and what issue it would solve.
You could spend a lot of time adding in function that will never get used. :)

Posted on
Thu Feb 01, 2018 1:38 pm
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: How to re-connect client / Is it possible? [SOLVED]

Jo,
added 2 easy ones: print client, system device info, health info and fixed a smaller issue with GW device mac#
Karl

Posted on
Sun Feb 04, 2018 3:09 pm
autolog offline
Posts: 3988
Joined: Sep 10, 2013
Location: West Sussex, UK [GMT aka UTC]

Re: How to re-connect client / Is it possible? [SOLVED]

Hi Karl,
Upgraded to 7.10.82 and getting this error when executing an Action to reconnect:
uniFiAP Error Error in plugin execution ExecuteAction:

Traceback (most recent call last):
File "plugin.py", line 1246, in buttonConfirmReconnectCALLBACKaction
File "plugin.py", line 1249, in buttonConfirmReconnectCALLBACK
KeyError: key selectedDevice not found in dict

I selected a LIFX Lamp from the pulldown list. :)

Posted on
Sun Feb 04, 2018 3:52 pm
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: How to re-connect client / Is it possible? [SOLVED]

sorry for that .. too many options to test .. this one should work:
https://www.dropbox.com/s/ha966s7kubu7k0g/uniFiAP-v-7.10.83.zip?dl=1

will also post the same on GitHub


Karl

Posted on
Sun Feb 04, 2018 4:40 pm
autolog offline
Posts: 3988
Joined: Sep 10, 2013
Location: West Sussex, UK [GMT aka UTC]

Re: How to re-connect client / Is it possible? [SOLVED]

Hi Karl,
Thanks - that fixed it. :)

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 2 guests