Page 5 of 7

Re: Yet another presence detection method

Posted: Tuesday 20 February 2018 18:34
by vulbas
hi, sorry for my english, google translate is my friend lol.
I installed on my AC88U with merlin.
did I fill up well?
#! / Bin / sh
cru a PRESENCE "*/1 * * * * /jffs/scripts/presence_detection xx.xx.xx.xx 3888"

when I type ./presence_detection xx.xx.xx.xx IDX3888 I get the message [: On: unknown operand or [: Off: unknown operand
my phone is recognized. in domoticz the switch does not change state.
is a script needed in LUA in domoticz?


can you help me please?

Re: Yet another presence detection method

Posted: Tuesday 20 February 2018 19:47
by Surroot
Hi!

It seems like a mistake happened when you copied the script.
Try copy and paste again and replace the script on your router.

Good luck

Re: Yet another presence detection method

Posted: Saturday 24 February 2018 15:49
by vulbas
Hello,
it does not work.
is it necessary to put a script in domoticz? LUA, python ....?

Re: Yet another presence detection method

Posted: Saturday 24 February 2018 16:17
by Surroot
vulbas wrote: Saturday 24 February 2018 15:49 Hello,
it does not work.
is it necessary to put a script in domoticz? LUA, python ....?
No it's not necessary, just try the steps from the description of the first post again.

BR

Re: Yet another presence detection method

Posted: Saturday 24 February 2018 17:35
by vulbas
if you have an idee

Code: Select all

#! /bin/sh
cru a PRESENCE "*/1 * * * * /jffs/scripts/presence_detection 74:23:44:F7:2C:9B IDX3692"

Code: Select all

#!/bin/sh

mac=$1
idx=$2
device_present=Off
domoticz_status=`curl -s "http://vulbas:[email protected]:8080/json.htm?\
type=devices&rid=$idx" | grep Status | awk '{print $3}' | sed 's/[",]//g'`

# look in 2.4GHz (eth1) network for device
for x in `wl -i eth1 assoclist | awk '{print $2}'`; do
 if [ $x = $mac ]; then
        device_present=On
 fi
done

# look in 5GHz (eth2) network for device
for x in `wl -i eth2 assoclist | awk '{print $2}'`; do
 if [ $x = $mac ]; then
        device_present=On
 fi
done

# tell domoticz the new device status
if [ $domoticz_status != $device_present ]; then
 if [ $device_present = "On" ]; then
        curl -s "http://vulbas:[email protected]:8080/json.htm?\
        type=command&param=switchlight&idx=$idx&switchcmd=On" > /dev/null
 else
        curl -s "http://vulbas:[email protected]:8080/json.htm?\
        type=command&param=switchlight&idx=$idx&switchcmd=Off" > /dev/null
 fi
fi
[youtube]https://youtu.be/qeTwzoC8qvQ?t=56s[/youtube]

Re: Yet another presence detection method

Posted: Saturday 24 February 2018 17:39
by Surroot
Ah sorry, I see. "IDX" was intended to be replaced by only a number, not by IDX+number.
So your commands have to look like this:

cru a PRESENCE "*/1 * * * * /jffs/scripts/presence_detection 74:23:44:F7:2C:9B 3692"

Best regards.

Re: Yet another presence detection method

Posted: Saturday 24 February 2018 18:00
by vulbas
I had tested for IDX ;)


https://youtu.be/X_YdIgSoNlA

Re: Yet another presence detection method

Posted: Saturday 24 February 2018 18:03
by Surroot
vulbas wrote: Saturday 24 February 2018 18:00 I had tested for IDX ;)


https://youtu.be/X_YdIgSoNlA
You could try setting the status manually by executing:
curl -s "http://domoticzUser:domoticzPassword@domoticzIP:domoticzPort/json.htm?\ type=command&param=switchlight&idx=3692&switchcmd=On"

Re: Yet another presence detection method

Posted: Saturday 24 February 2018 18:14
by vulbas

Re: Yet another presence detection method

Posted: Saturday 24 February 2018 18:17
by Surroot
vulbas wrote: Saturday 24 February 2018 18:14 Image

https://i62.servimg.com/u/f62/17/98/85/70/bad11.png

:o :(
remove "\ " in between htm? and type=

Re: Yet another presence detection method

Posted: Saturday 24 February 2018 18:20
by vulbas
curl -s "http://vulbas:[email protected]:8080/json.htm? type=command&param=switchlight&idx=$idx&switchcmd=On"
<html><head><title>Bad Request</title></head><body><h1>400 Bad Request</h1></body></html>admin@RT-AC88U-2648:/jffs/scripts#

Re: Yet another presence detection method

Posted: Saturday 24 February 2018 19:29
by Surroot
vulbas wrote: Saturday 24 February 2018 18:20 curl -s "http://vulbas:[email protected]:8080/json.htm? type=command&param=switchlight&idx=$idx&switchcmd=On"
<html><head><title>Bad Request</title></head><body><h1>400 Bad Request</h1></body></html>admin@RT-AC88U-2648:/jffs/scripts#
There is still a space symbol between json.htm? and type=

Re: Yet another presence detection method

Posted: Sunday 25 February 2018 16:28
by vulbas
hello surout
i have installed a new domoticz and i make a hard reset of my router, the problem is the same.
i don't understand

with a still a space symbol between json.htm? and type=

admin@RT-AC88U-2648:/jffs/scripts# curl -s "http://vulbas:[email protected]:8080/json.htm? type=command&param=switchlight&idx=$idx&switchcmd=On"
<html><head><title>Bad Request</title></head><body><h1>400 Bad Request</h1></body></html>

with no space symbol between json.htm? and type=

admin@RT-AC88U-2648:/jffs/scripts# curl -s "http://vulbas:[email protected]:80 ... itchcmd=On"
{
"status" : "ERR"



i have the asus router AC88U with merlin 384.3

Image

Image

Re: Yet another presence detection method

Posted: Sunday 25 February 2018 16:41
by Surroot
you forgot to replace $idx with the ID of your switch

Re: Yet another presence detection method

Posted: Sunday 25 February 2018 17:21
by vulbas
ho sorry, i don't understand that :? :? :?

this is good ?

Code: Select all

#!/bin/sh

mac=$1
idx=$2
device_present=Off
domoticz_status=`curl -s "http://vulbas:[email protected]:8080/json.htm?\
type=devices&rid=3692" | grep Status | awk '{print $3}' | sed 's/[",]//g'`

# look in 2.4GHz (eth1) network for device
for x in `wl -i eth1 assoclist | awk '{print $2}'`; do
 if [ $x = $mac ]; then
        device_present=On
 fi
done

# look in 5GHz (eth2) network for device
for x in `wl -i eth2 assoclist | awk '{print $2}'`; do
 if [ $x = $mac ]; then
        device_present=On
 fi
done

# tell domoticz the new device status
if [ $domoticz_status != $device_present ]; then
 if [ $device_present = "On" ]; then
        curl -s "http://vulbas:[email protected]:8080/json.htm?\
        type=command&param=switchlight&idx=3692&switchcmd=On" > /dev/null
 else
        curl -s "http://vulbas:[email protected]:8080/json.htm?\
        type=command&param=switchlight&idx=3692&switchcmd=Off" > /dev/null
 fi
fi

Re: Yet another presence detection method

Posted: Monday 26 February 2018 14:31
by vulbas
Image

Image


it does not work automatically

Re: Yet another presence detection method

Posted: Monday 26 February 2018 22:10
by vulbas
avec ce code ça fonctionne presque.
le on s'allume automatiquement.
mais il ne s'eteint pas automatiquement

with this code it works almost.
it turns on automatically.
but it does not turn off automatically

:? :roll: :| :cry:


Image

Re: Yet another presence detection method

Posted: Tuesday 06 March 2018 19:48
by vulbas
hello,
finaly that work for my phone !!! :D :D

but i whant put an another phone, and that don't work :(

Code: Select all

cru a PRESENCE "*/1 * * * * /jffs/scripts/presence_detection 74:23:44:F7:2C:9B 3701
cru a PRESENCE "*/1 * * * * /jffs/scripts/presence_detection D4:A3:3D:20:51:69 3705
how to add a second phone on the code ?
the IDX is only 3701 on this code :(

Code: Select all

#!/bin/sh

mac=$1
idx=$2
device_present=Off
domoticz_status=`curl -s "xxxxxxxxxxxxxxx/json.htm?type=devices&rid=3701" | grep Status | awk '{print $3}' | sed 's/[",]//g'`

# look in 2.4GHz (eth1) network for device
for x in `wl -i eth1 assoclist | awk '{print $2}'`; do
 if [ $x = $mac ]; then device_present=On
 fi
done

# look in 5GHz (eth2) network for device
for x in `wl -i eth2 assoclist | awk '{print $2}'`; do
 if [ $x = $mac ]; then device_present=On
 fi
done

# tell domoticz the new device status
if [ $domoticz_status != $device_present ]; then
 if [ $device_present = "On" ]; then
        curl -s "xxxxxxxxxxxxxxxxxx/json.htm?type=command&param=switchlight&idx=3701&switchcmd=On" > /dev/null
 else
        curl -s "xxxxxxxxxxxxxxxxxxxxx/json.htm?type=command&param=switchlight&idx=3701&switchcmd=Off" > /dev/null
 fi
fi

Re: Yet another presence detection method

Posted: Tuesday 06 March 2018 19:58
by timop
your cru commands are missing ending "
should be:

Code: Select all

cru a PRESENCE "*/1 * * * * /jffs/scripts/presence_detection 74:23:44:F7:2C:9B 3701"
cru a PRESENCE "*/1 * * * * /jffs/scripts/presence_detection D4:A3:3D:20:51:69 3705"

Re: Yet another presence detection method

Posted: Tuesday 06 March 2018 20:21
by vulbas
ho thank you.
it worked without the "
but i do not know how to have two phone :(