Yet another presence detection method

Moderator: leecollings

vulbas
Posts: 37
Joined: Tuesday 20 February 2018 17:59
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Yet another presence detection method

Post 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?
User avatar
Surroot
Posts: 31
Joined: Wednesday 18 January 2017 11:28
Target OS: Linux
Domoticz version: beta
Location: Vienna
Contact:

Re: Yet another presence detection method

Post 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
vulbas
Posts: 37
Joined: Tuesday 20 February 2018 17:59
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Yet another presence detection method

Post by vulbas »

Hello,
it does not work.
is it necessary to put a script in domoticz? LUA, python ....?
User avatar
Surroot
Posts: 31
Joined: Wednesday 18 January 2017 11:28
Target OS: Linux
Domoticz version: beta
Location: Vienna
Contact:

Re: Yet another presence detection method

Post 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
vulbas
Posts: 37
Joined: Tuesday 20 February 2018 17:59
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Yet another presence detection method

Post 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]
User avatar
Surroot
Posts: 31
Joined: Wednesday 18 January 2017 11:28
Target OS: Linux
Domoticz version: beta
Location: Vienna
Contact:

Re: Yet another presence detection method

Post 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.
vulbas
Posts: 37
Joined: Tuesday 20 February 2018 17:59
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Yet another presence detection method

Post by vulbas »

I had tested for IDX ;)


https://youtu.be/X_YdIgSoNlA
User avatar
Surroot
Posts: 31
Joined: Wednesday 18 January 2017 11:28
Target OS: Linux
Domoticz version: beta
Location: Vienna
Contact:

Re: Yet another presence detection method

Post 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"
vulbas
Posts: 37
Joined: Tuesday 20 February 2018 17:59
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Yet another presence detection method

Post by vulbas »

User avatar
Surroot
Posts: 31
Joined: Wednesday 18 January 2017 11:28
Target OS: Linux
Domoticz version: beta
Location: Vienna
Contact:

Re: Yet another presence detection method

Post 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=
vulbas
Posts: 37
Joined: Tuesday 20 February 2018 17:59
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Yet another presence detection method

Post 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#
User avatar
Surroot
Posts: 31
Joined: Wednesday 18 January 2017 11:28
Target OS: Linux
Domoticz version: beta
Location: Vienna
Contact:

Re: Yet another presence detection method

Post 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=
vulbas
Posts: 37
Joined: Tuesday 20 February 2018 17:59
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Yet another presence detection method

Post 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
User avatar
Surroot
Posts: 31
Joined: Wednesday 18 January 2017 11:28
Target OS: Linux
Domoticz version: beta
Location: Vienna
Contact:

Re: Yet another presence detection method

Post by Surroot »

you forgot to replace $idx with the ID of your switch
vulbas
Posts: 37
Joined: Tuesday 20 February 2018 17:59
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Yet another presence detection method

Post 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
vulbas
Posts: 37
Joined: Tuesday 20 February 2018 17:59
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Yet another presence detection method

Post by vulbas »

Image

Image


it does not work automatically
vulbas
Posts: 37
Joined: Tuesday 20 February 2018 17:59
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Yet another presence detection method

Post 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
vulbas
Posts: 37
Joined: Tuesday 20 February 2018 17:59
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Yet another presence detection method

Post 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
timop
Posts: 57
Joined: Sunday 03 January 2016 17:10
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Yet another presence detection method

Post 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"
vulbas
Posts: 37
Joined: Tuesday 20 February 2018 17:59
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Yet another presence detection method

Post by vulbas »

ho thank you.
it worked without the "
but i do not know how to have two phone :(
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest