Presence detection using UniFi Controller (Ubiquiti Networks)

All kinds of 'OS' scripts
mcmikev
Posts: 151
Joined: Tuesday 26 May 2015 8:11
Target OS: Raspberry Pi
Domoticz version: beta
Location: right here
Contact:

Re: Presence detection using UniFi Controller (Ubiquiti Networks)

Post by mcmikev » Sunday 14 January 2018 16:34

Hi BakSeeDaa,

I am also having problems with the scripts now.
I run it on a seperate RPi2 and used to work but now with (i guess because of that it stopped working) cloudkey firmware version 0.8.9 it does not work anymore. \

Code: Select all

pi@rpi2:~/domoticz/scripts/unifi-detect $ ./unifi_detect.sh
Running unifi_detect.sh 1.0.1
Exiting with a result code of : 401
pi@rpi2:~/domoticz/scripts/unifi-detect $
I have looked at the url, port and credentials and they are fine.

Do you have any info regarding the working status with CK 0.8.9 version and Unifi version 5.7.15.0

mcmikev
Posts: 151
Joined: Tuesday 26 May 2015 8:11
Target OS: Raspberry Pi
Domoticz version: beta
Location: right here
Contact:

Re: Presence detection using UniFi Controller (Ubiquiti Networks)

Post by mcmikev » Sunday 14 January 2018 16:57

Update:

It does work!

My unifi password was not right anymore. CloudKey and unifi had different passwords (due to reset I had to do a while back)
I don't have an issue now :-)

Sorry but also thanks!

prekz
Posts: 3
Joined: Sunday 13 August 2017 22:20
Target OS: Linux
Domoticz version:
Contact:

Re: Presence detection using UniFi Controller (Ubiquiti Networks)

Post by prekz » Monday 05 February 2018 22:52

When i run the script (without crontab enabled/configured) i get the following message:

Code: Select all

Running unifi_detect.sh 1.0.1
There is no output so i don't know if the script is running. As Cellphones i used the name that is known in the unifi controller (android-macadress for example). I don't see my virtual switches turned on or off when the script runs (also when i run it under crontab i don't see them changing).

Can anyone help?

EDIT: after an hour i fixed the problem, turns out the unifi second site had a # in front..

Other question, how long does it take to turn the signal "off" i have the idea it takes a couple of minutes when the cellphone leaves the unifi controler (and turns the virtual switch off in domoticz) is there a way to speed up this process?

rasper
Posts: 27
Joined: Sunday 10 January 2016 23:46
Target OS: Raspberry Pi
Domoticz version: Stable
Location: Netherlands
Contact:

Re: Presence detection using UniFi Controller (Ubiquiti Networks)

Post by rasper » Wednesday 07 February 2018 14:36

prekz wrote:
Monday 05 February 2018 22:52
When i run the script (without crontab enabled/configured) i get the following message:

Code: Select all

Running unifi_detect.sh 1.0.1
There is no output so i don't know if the script is running. As Cellphones i used the name that is known in the unifi controller (android-macadress for example). I don't see my virtual switches turned on or off when the script runs (also when i run it under crontab i don't see them changing).

Can anyone help?

EDIT: after an hour i fixed the problem, turns out the unifi second site had a # in front..

Other question, how long does it take to turn the signal "off" i have the idea it takes a couple of minutes when the cellphone leaves the unifi controler (and turns the virtual switch off in domoticz) is there a way to speed up this process?
it takes 10 minutes for the wifi client list in the unifi to get updated if a device disconnects, I also sometimes have random disconnects while the device is connected to wifi, but it then doesnt show up in the list of connected clients. for that i added an additional bluetooth ping as a safety net (but not my whole house has bluetooth reach so sometimes still a false message)

Falken
Posts: 6
Joined: Thursday 22 February 2018 22:20
Target OS: Raspberry Pi
Domoticz version: 3.8934
Contact:

Re: Presence detection using UniFi Controller (Ubiquiti Networks)

Post by Falken » Saturday 24 February 2018 15:30

I get: chmod: cannot access '/home/pi/domoticz/scripts/unifi-detect/unifi_detect.sh': No such file or directory


But the file is there, what am I doing wrong?

timop
Posts: 68
Joined: Sunday 03 January 2016 18:10
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Presence detection using UniFi Controller (Ubiquiti Networks)

Post by timop » Tuesday 27 February 2018 16:17

@Falken: file isnt there ls -l /home/pi/domoticz/scripts/unifi-detect

is it possible to check from arp in/from Unifi controller, like in asus APs, it works immediately when fevice is off from wifi
viewtopic.php?f=61&t=15531

timop
Posts: 68
Joined: Sunday 03 January 2016 18:10
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Presence detection using UniFi Controller (Ubiquiti Networks)

Post by timop » Tuesday 27 February 2018 16:35

I added little feature, my devices are password protected and I added to script couple things:

Code: Select all

domoticz_ip=192.168.XXX.XXX # Domoticz IP or host name
domoticz_port=8080
dompasscode=YourOwnSwitchPassCode 

domoState=$(curl --silent "http://$domoticz_ip:$domoticz_port/json.htm?type=devices&rid=$1&passcode=$dompasscode")
	
curl --silent --output /dev/null "http://$domoticz_ip:$domoticz_port/json.htm?type=command&param=switchlight&idx=$1&switchcmd=$2&passcode=$dompasscode"


Maes
Posts: 53
Joined: Tuesday 05 April 2016 20:45
Target OS: -
Domoticz version:
Contact:

Re: Presence detection using UniFi Controller (Ubiquiti Networks)

Post by Maes » Sunday 11 March 2018 22:27

Hi BakSeeDa,

Hoping you can help me out here. I've been using your script without any problems for several months already. However, since a couple of days the script doesn't recognise my phone leaving or entering the house anymore. The stupid thing is that it's still working perfectly for my wife's phone.

I double checked the device ID and the unifi client name several times but nothing has changed. The only things that have changed is that I updated the unifi cloud key and access points and my phone (galaxy s8) has been updated to android 8. I don't know if this matters at all because I still see my phone being connected in the unifi client list under the same client name.

I also noticed that when I run the script manually, it DOES switch off/on for my phone, but not when it's running under Cron...

Any idea what this could be?

Luuc_a
Posts: 67
Joined: Tuesday 16 July 2013 10:12
Target OS: Raspberry Pi
Domoticz version: Beta
Contact:

Re: Presence detection using UniFi Controller (Ubiquiti Networks)

Post by Luuc_a » Thursday 22 March 2018 12:44

Maes wrote:
Sunday 11 March 2018 22:27
Hi BakSeeDa,

Hoping you can help me out here. I've been using your script without any problems for several months already. However, since a couple of days the script doesn't recognise my phone leaving or entering the house anymore. The stupid thing is that it's still working perfectly for my wife's phone.

I double checked the device ID and the unifi client name several times but nothing has changed. The only things that have changed is that I updated the unifi cloud key and access points and my phone (galaxy s8) has been updated to android 8. I don't know if this matters at all because I still see my phone being connected in the unifi client list under the same client name.

I also noticed that when I run the script manually, it DOES switch off/on for my phone, but not when it's running under Cron...

Any idea what this could be?
Today I started with this script because I have a Unifi Controller to and all works fine. First I had the same issue like you en with the following adjustment it works also with cron.

Edit the first rule of the script from:

Code: Select all

#!/usr/bin/env bash
to

Code: Select all

#!/bin/bash
Maybe it will works for you to

denver
Posts: 12
Joined: Sunday 17 December 2017 8:19
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Presence detection using UniFi Controller (Ubiquiti Networks)

Post by denver » Sunday 25 March 2018 9:34

Not sure how to put

Code: Select all

*/5 * * * * /home/pi/domoticz/scripts/unifi-detect/unifi_detect.sh
in crontab, any help appreciated, thanks..

CronoS
Posts: 55
Joined: Wednesday 15 July 2015 23:40
Target OS: -
Domoticz version:
Contact:

Re: Presence detection using UniFi Controller (Ubiquiti Networks)

Post by CronoS » Wednesday 11 April 2018 12:56

I am running this script on a Synology with Domoticz, where my Unifi controller is in Azure. I can successfully get the content; but the script seems to hang, it only sometimes flip the switch and the script doesn't seems to stop. . Anyone knows what to expect on a Synology ?

credenty
Posts: 9
Joined: Saturday 12 November 2016 12:07
Target OS: Windows
Domoticz version:
Contact:

Re: Presence detection using UniFi Controller (Ubiquiti Networks)

Post by credenty » Wednesday 18 April 2018 7:40

Hello, I do not know if there will be more people like me. Would there be any possibility of doing a scrip for windows?

Delfuego
Posts: 2
Joined: Sunday 29 July 2018 16:18
Target OS: Linux
Domoticz version: 4.9700
Location: The Netherlands
Contact:

Re: Presence detection using UniFi Controller (Ubiquiti Networks)

Post by Delfuego » Friday 10 August 2018 12:31

credenty wrote:
Wednesday 18 April 2018 7:40
Hello, I do not know if there will be more people like me. Would there be any possibility of doing a scrip for windows?
Maybe my DzVents script runs on Windows!? Does not depend on Curl.
viewtopic.php?f=59&t=24453
Let me know if it works on Windows!

cmartens75
Posts: 6
Joined: Monday 23 April 2018 10:43
Target OS: Raspberry Pi
Domoticz version:
Location: Netherlands
Contact:

Re: Presence detection using UniFi Controller (Ubiquiti Networks)

Post by cmartens75 » Wednesday 05 September 2018 21:47

Hi all, the script is working fine for multiple months already. However, I would like to have the passwords removed from the script. Is this possible? If yes, how can this be done? Thanks in advance for your reaction and ideas.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest