Ultimate Wifi and Bluetooth Presence Detection

All kinds of 'OS' scripts
Yustmenl
Posts: 43
Joined: Wednesday 28 September 2016 17:26
Target OS: Raspberry Pi
Domoticz version: 3.5997
Contact:

Re: Ultimate Wifi and Bluetooth Presence Detection

Post by Yustmenl » Wednesday 29 March 2017 10:27

I am having problems running the script, i have been looking throught the posts of the same problem but none of the solutions seem to work :(

when running
sudo sh ./script.sh
i get
./telrichard.sh: 21: ./telrichard.sh: [[: not found
./telrichard.sh: 31: ./telrichard.sh: [[: not found
./telrichard.sh: 41: ./telrichard.sh: [[: not found
./telrichard.sh: 51: ./telrichard.sh: [[: not found
Status in sync Wifi 1st attempt

when running
sudo ./script
i get
sudo: ./telrichard.sh: command not found

when running
./script
i get
bash: ./telrichard.sh: Permission denied

i already used dos2unix on the file
and created the file with touch and filled it with nano
but somehow i can't get it to work

so now i am out of ideas hopefully someone here can help me.
Rasberry Pi 3; Razberry 2.0; RFXCOM

ben53252642
Posts: 418
Joined: Saturday 02 July 2016 5:17
Target OS: Linux
Domoticz version: Beta
Contact:

Re: Ultimate Wifi and Bluetooth Presence Detection

Post by ben53252642 » Wednesday 29 March 2017 13:14

This should fix it:

sudo chmod 755 telrichard.sh
then run:
sudo ./telrichard.sh

Yustmenl
Posts: 43
Joined: Wednesday 28 September 2016 17:26
Target OS: Raspberry Pi
Domoticz version: 3.5997
Contact:

Re: Ultimate Wifi and Bluetooth Presence Detection

Post by Yustmenl » Wednesday 29 March 2017 13:18

wel it's running now with sudo ./telrichard.sh
but i still get

./telrichard.sh: 21: ./telrichard.sh: [[: not found
./telrichard.sh: 31: ./telrichard.sh: [[: not found
./telrichard.sh: 41: ./telrichard.sh: [[: not found
./telrichard.sh: 51: ./telrichard.sh: [[: not found
Status in sync Wifi 1st attempt

any idea what can be the solution for that?
Rasberry Pi 3; Razberry 2.0; RFXCOM

ben53252642
Posts: 418
Joined: Saturday 02 July 2016 5:17
Target OS: Linux
Domoticz version: Beta
Contact:

Re: Ultimate Wifi and Bluetooth Presence Detection

Post by ben53252642 » Wednesday 29 March 2017 13:32

Try sudo bash ./telrichard.sh

u still get the error?

Yustmenl
Posts: 43
Joined: Wednesday 28 September 2016 17:26
Target OS: Raspberry Pi
Domoticz version: 3.5997
Contact:

Re: Ultimate Wifi and Bluetooth Presence Detection

Post by Yustmenl » Wednesday 29 March 2017 13:34

thats's it thanks wil change it in cron to
Rasberry Pi 3; Razberry 2.0; RFXCOM

ben53252642
Posts: 418
Joined: Saturday 02 July 2016 5:17
Target OS: Linux
Domoticz version: Beta
Contact:

Re: Ultimate Wifi and Bluetooth Presence Detection

Post by ben53252642 » Wednesday 29 March 2017 13:41

Cool,

The first line of the script:

Code: Select all

#!/bin/bash
Is supposed to tell systems to run it as a bash script but for some reason your system seems to ignore that.

Anyway you can run it with that command:

sudo bash ./telrichard.sh

And it essentially does the same thing. :D

Yustmenl
Posts: 43
Joined: Wednesday 28 September 2016 17:26
Target OS: Raspberry Pi
Domoticz version: 3.5997
Contact:

Re: Ultimate Wifi and Bluetooth Presence Detection

Post by Yustmenl » Wednesday 29 March 2017 13:50

Looks i removed to much from the script

Code: Select all

#!/bin/bash
was missing :oops:
Rasberry Pi 3; Razberry 2.0; RFXCOM

Yustmenl
Posts: 43
Joined: Wednesday 28 September 2016 17:26
Target OS: Raspberry Pi
Domoticz version: 3.5997
Contact:

Re: Ultimate Wifi and Bluetooth Presence Detection

Post by Yustmenl » Wednesday 05 April 2017 8:38

I found out that the WIFI ping isn't working with my and my girlfriends phone.
Does anyone have an idea if this can be solved? or is this becuase of the power saving from the phones?
Rasberry Pi 3; Razberry 2.0; RFXCOM

ToneStrife
Posts: 21
Joined: Sunday 16 April 2017 17:02
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Ultimate Wifi and Bluetooth Presence Detection

Post by ToneStrife » Sunday 16 April 2017 18:44

Hello to anyone!

I get the sensor working correctly but I'm having problems to get it in the startup. I'm running the script in a Rpi3
startup.sh file is

Code: Select all

cd /home/pi/domoticz/scripts
# Start Carlos Mobile Ping Monitor
#/usr/bin/screen -S PingCarlosMobile -d -m ./carlos_phone.sh
And the file in init.d is

Code: Select all

#!/bin/sh
### BEGIN INIT INFO
# Provides: Startscripts
# Required-Start: $network
# Required-Stop: $network
# Default-Start: 2 3 5
# Default-Stop:
# Description: 
### END INIT INFO

case "$1" in
'start')
        sudo sh /home/pi/domoticz/scripts/startup.sh
        ;;
'stop')
        ;;
*)
        echo "Usage: $0 { start | stop }"
        ;;
esac
exit 0
I have added the file to the startup using defaults command. But on startup is not detecting changes. Any help?

chrisk81
Posts: 1
Joined: Thursday 11 May 2017 17:58
Target OS: Windows
Domoticz version:
Contact:

Re: Ultimate Wifi and Bluetooth Presence Detection

Post by chrisk81 » Thursday 11 May 2017 18:03

I'm using this code to detect my iPhone bluetooth. I've found it to be rock solid so far and it also gives the RSSI. Can anyone see any issues with it?

Code: Select all

#!/bin/bash

sudo hcitool cc AA:BB:CC:DD:EE:FF 2> /dev/null

while true
do
	bt=$(hcitool rssi AA:BB:CC:DD:EE:FF 2> /dev/null)
	if [ "$bt" == "" ]; then
		sudo hcitool cc AA:BB:CC:DD:EE:FF  2> /dev/null
		bt=$(hcitool rssi AA:BB:CC:DD:EE:FF 2> /dev/null)
	fi
	
	echo "$bt"
done

beounet
Posts: 8
Joined: Wednesday 16 November 2016 20:58
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Ultimate Wifi and Bluetooth Presence Detection

Post by beounet » Saturday 08 July 2017 12:41

A very nice script indeed!! works fine till now!!
Thanks a lot Ben!
I think that it will be a good idea to include some sort of security here!!
As i see if the domoticz page is code protected then the virtual switch does not refresh it's state!!
One more is that the same happens if the virtual switch is also password protected!
Protecting the switch is usefull in order to prevent accidentally change of the state!!

rudiraz
Posts: 11
Joined: Thursday 31 December 2015 17:00
Target OS: Raspberry Pi
Domoticz version: latest
Contact:

Re: Ultimate Wifi and Bluetooth Presence Detection

Post by rudiraz » Tuesday 07 November 2017 15:24

Hi,

I do not need the commandline output. I obly need the script for witching the alarm-switches on and off.
How do I have to use this script then.?
Starting manually ist not the right way...?!

schulpr
Posts: 120
Joined: Thursday 01 January 2015 10:10
Target OS: NAS (Synology & others)
Domoticz version: Beta
Contact:

Re: Ultimate Wifi and Bluetooth Presence Detection

Post by schulpr » Friday 01 December 2017 15:41

Hi,

I'm getting this error: ./iphone_rob.sh: 75: ./iphone_rob.sh: Syntax error: "done" unexpected (expecting "then").

Anyone an idea what's going wrong?

Regards, Rob

theo69
Posts: 81
Joined: Sunday 04 June 2017 12:57
Target OS: Raspberry Pi
Domoticz version: la. beta
Location: World
Contact:

Re: Ultimate Wifi and Bluetooth Presence Detection

Post by theo69 » Wednesday 03 January 2018 19:51

Hi I am a Newbi and have no clue how to add a script like this, is there somebody that can write down all the steps for me?

I have two phones with these Bluetooth Mac Adress: 00:14:22:01:23:45 and 00:0a:95:9d:68:16
Love my Xiaomi Gateway in connection with homebridge and domoticz on my PI3
Xiaomi Gateway Domoticz Wiki

theo69
Posts: 81
Joined: Sunday 04 June 2017 12:57
Target OS: Raspberry Pi
Domoticz version: la. beta
Location: World
Contact:

Re: Ultimate Wifi and Bluetooth Presence Detection

Post by theo69 » Wednesday 03 January 2018 20:26

okay its running (more or less) however my Dummy switch is not changing using this code:

Code: Select all

echo "Status out of sync, correcting..."
if [ "$device" = On ] ; then
echo "$Name" "Online"
curl -s "http://"10.0.1.32:8080"/json.htm?type=command&param=switchlight&idx="$392"&switchcmd=On" 2>/dev/null 1>/dev/null
else
echo "$Name" "Offline"
curl -s "http://"10.0.1.32:8080"/json.htm?type=command&param=switchlight&idx="$392"&switchcmd=Off" 2>/dev/null 1>/dev/null
fi
fi
Love my Xiaomi Gateway in connection with homebridge and domoticz on my PI3
Xiaomi Gateway Domoticz Wiki

User avatar
jvdz
Posts: 1367
Joined: Tuesday 30 December 2014 20:25
Target OS: Raspberry Pi
Domoticz version: Stable
Location: Westland/Netherlands
Contact:

Re: Ultimate Wifi and Bluetooth Presence Detection

Post by jvdz » Wednesday 03 January 2018 20:30

Guess that needs to be:

Code: Select all

curl -s "http://"10.0.1.32:8080"/json.htm?type=command&param=switchlight&idx=392&switchcmd=On" 2>/dev/null 1>/dev/null
else
echo "$Name" "Offline"
curl -s "http://"10.0.1.32:8080"/json.htm?type=command&param=switchlight&idx=392&switchcmd=Off" 2>/dev/null 1>/dev/null
A $ infront means it is a variable defined before and guess 392 is the actual IDX for the dummy switch.

Jos

theo69
Posts: 81
Joined: Sunday 04 June 2017 12:57
Target OS: Raspberry Pi
Domoticz version: la. beta
Location: World
Contact:

Re: Ultimate Wifi and Bluetooth Presence Detection

Post by theo69 » Wednesday 03 January 2018 20:32

jvdz wrote:
Wednesday 03 January 2018 20:30
Guess that needs to be:

Code: Select all

curl -s "http://"10.0.1.32:8080"/json.htm?type=command&param=switchlight&idx=392&switchcmd=On" 2>/dev/null 1>/dev/null
else
echo "$Name" "Offline"
curl -s "http://"10.0.1.32:8080"/json.htm?type=command&param=switchlight&idx=392&switchcmd=Off" 2>/dev/null 1>/dev/null
A $ infront means it is a variable defined before and guess 392 is the actual IDX for the dummy switch.

Jos
yep found that myself right now :oops:

Only problem now, i can only start the sh with sudo bash iphone.sh
Love my Xiaomi Gateway in connection with homebridge and domoticz on my PI3
Xiaomi Gateway Domoticz Wiki

theo69
Posts: 81
Joined: Sunday 04 June 2017 12:57
Target OS: Raspberry Pi
Domoticz version: la. beta
Location: World
Contact:

Re: Ultimate Wifi and Bluetooth Presence Detection

Post by theo69 » Wednesday 03 January 2018 20:41

Also a lot of times when i switch of bluetooth on the phone, it still shows online...
Love my Xiaomi Gateway in connection with homebridge and domoticz on my PI3
Xiaomi Gateway Domoticz Wiki

User avatar
jvdz
Posts: 1367
Joined: Tuesday 30 December 2014 20:25
Target OS: Raspberry Pi
Domoticz version: Stable
Location: Westland/Netherlands
Contact:

Re: Ultimate Wifi and Bluetooth Presence Detection

Post by jvdz » Wednesday 03 January 2018 20:51

What is the problem with running it without sudo? Access to curl or the scriptfile?
The script should tell you what it finds. Which version are you using and did you also use the IP address as that looks like it is required for the script I see on the first page? (I am not using this version and wrote my own LUA version)

Jos

theo69
Posts: 81
Joined: Sunday 04 June 2017 12:57
Target OS: Raspberry Pi
Domoticz version: la. beta
Location: World
Contact:

Re: Ultimate Wifi and Bluetooth Presence Detection

Post by theo69 » Wednesday 03 January 2018 22:09

if I just use sudo (without bash) it says

Code: Select all

Command not found

and if I just write bash (without sudo) it says

Code: Select all

Can't create socket: Operation not permitted
Status out of sync, correcting...
Can you share your LUA Srcipt with me please?
Love my Xiaomi Gateway in connection with homebridge and domoticz on my PI3
Xiaomi Gateway Domoticz Wiki

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests