Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,

 

as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.

 

As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!

 

Regards,

Smart Home Forum by FIBARO Team


  • 0

Home Center automatically check your presence at home


Question

Posted

The objective of this functionality is to determine that your are at home based on your phone connexion to your wifi network and use that information on your Home Center for example to switch off your alarm automatically when you are in and switch it On when you are out...

Most of phones are impossible to be easily found as soon as they are on sleeping mode; therefore a simple ping won’t work.

I’ve done this workaround with the help of a raspberry and fing which is a free powerful network tool that can be run on most of platforms.

The plus of this solution is that it's working on HC lite because there is no LUA or virtual device necessary, works with iPhones with recent IOS version even when wifi looks to be off when device is sleeping and no extra application to be installed, tasker on android is not needed for this purpose , and it's complient with all phones that i had the chance to test: iPhones, Androids, windows phone; it's absolutly transparent, no need to wake up your device, just do nothing

Please login or register to see this image.

/emoticons/default_icon_wink.gif" alt=";-)" /> .. !

prerequisite: You must have a server running permanently ( a raspberry or a nas server ...)

Step 1

In the HC create a variable in this example “Presence”with two values “Present” and “Absent”.

If you decide to change the name don’t forget to amend the file named "test_presence.sh" that we are going to talk about on step 7.

Step 2

Install Fing in your server, the command will differ depending on your unix distribution.

In my case a debian on my RPI I used the following:

Please login or register to see this code.

Test that is ok and try:

Sudo Fing

If all is all right you can jump to step 4 else go to next step.

Step 3

If fing don’t execute it’s probably because some libraries are missing or obsolete in this case try the following command:

Please login or register to see this code.

Step 4

In /etc edit the file rc.local add the following command and save :

Please login or register to see this code.

If necessary adapt the network mask in my case 192.168.1.0 is the first IP address fing will start scanning (it will scan your entire network starting by this IP)

Step 5

In /var/www create a new directory called “ping” in order to have this result:

Please login or register to see this code.

Step 6

In /home create a new directory and name it as you want (in my case tony) we will use it on step 7 & 8

Step 7

Create a file "test_presence.sh" and copy the code find below. IPDUSERVEUR must be set with your phone address.

Change user/mot with your HC user/pass and IP with your HC ip address.

Copy that file on the directory that you have created in step 6

Step 8

Create a file « exec_presence »and copy the code find below, change the directory name with the name craeated in step 6 :

/home/XXXXX (/home/tony in my case)

Copy the script « exec_presence » into /etc/init.d. Make sure grants are ok on that file:

Please login or register to see this code.

and execute following command (might change depending on your unix) :

Please login or register to see this code.

(it will allow the scipt to be automatically execute at after the boot)

On your browser try 192.168.X.X/ping/lan.html (where 192.168.X.X is the ip of your server where ping is running). You should see a page with all your network connections.

Check the variable on your HC is correctly reflecting your presence.

For the very first run (only after the server boot) your phone should be in wake up mode to be correctly identified, after it becomes transparent. You can disconnect/reconnect your phone from your network, put it on sleeping mode and check all is all right.

creat a file named "exec_presence" and copy following code:

Please login or register to see this code.

creat a file named "test_presence.sh" and copy following code:

In this loop the sleep is set to 10 it's ok for test purpose but you could be set to 30 for normal run.

Please login or register to see this code.

Have fun.

Recommended Posts

  • 0
Posted
Hello,

 

Tony270570, congratulations on the post. Fantastic.

 

He was great and helped me a lot.

 

As a suggestion to those who have little experience in linux and programming, like me.

 

- I have raspbmc on my Raspberry. In my case the command "curl" did not work (I took a long time to figure it out). Therefore, as a suggestion, you must install.

 

sudo apt-get update

sudo apt-get install curl

 

- When the tutorial send edit the sh files:

 

Sudo nano /etc/rc.local (eg)

sudo nano test_presence.sh

 

To exit editing: ctrl + x

 

- Me only worked when I gave the following command at

test_presence:

 

sudo chmod 755 test_presence.sh

 

From what I remember, these were the main difficulties.

 

Always remember to back up your raspberry.

 

---

 

Please, if anyone has a suggestion for me:

 

- I would like to add a second phone. Here at home we are me and my wife, is there any way to also include this in the script? Example: If her phone and my phone is out, the alarm will be activated.

 

The only way I thought was to create another "test_presence" but would overload the raspberry. I will can do it in the same script?

 

To the friends who put as a suggestion to use "beacons", also I found it excellent. But here in Brazil it is hard to find this kind of equipment. (Accessory).

 

Ps: I apologize for my grammatical errors. I'm using google translator.

  • 0
Posted

How stable is this solution? I have a WAP and a network extender and my Android phones seem to drop in and out of connectivity (although I am not sure if they are just jumping from one network to another) from time to time, so I wonder if this solution would be reliable.

  • 0
Posted
Hello aleks,

 

I realized several tests and all worked well. My biggest problem now is:

 

- How to include your phone my wife?
  • 0
Guest azevenhuizen
Posted

TWIMC,

 

Adopt HansS script to this, to shoot at a GlobalVar directly and skip the VD

Please login or register to see this code.

Also change this:

Please login or register to see this code.

  • 0
Posted

Thank you Tony270570 for this great post!

 

 

I got the system to recognise my phone but I can't get the variable to change. I'm using HCL with 4.057 beta.

 

I'm trying to use this line in test_presence.sh : 

Please login or register to see this code.

Shouldn't this work?

 

 

If this globalVariable can't be used how could I get this HTTP command work instead?

Please login or register to see this code.

  • 0
Posted

Just tested the curl call to change global variable, and it still seems to work as I described. Had some trouble getting it to work though, which seems to be caused by some kind of copy/paste error. In the end, I only noticed this by putting Charles proxy app between the shell and Fibaro. I typed the command manually directly on a shell, then it worked.

  • 0
Posted

Thank you HansS for your reply!

 

I have tried to get this working for hours, with everything I can come up with. (Command directly to shell, have made different variables, booted HCL, etc..)

 

Could the issue be this 4.057 beta version? HansS are you using this or previous version?

  • 0
Posted

Hi all. I have a HP Microserver Gen8 that is always on and id like to get this project setup on here.  

 

Can anyone give me a step-step uide how to install in a Windows environment.

 

Thanks all,

 

Hallamnet

  • 0
Posted

Trying to get this working with Geofency but struggling to get a final script working as I'm not really that familiar with PHP and Curl.

All I want to do is take the json data from Geofency and put some of that data in to 2 or 3 Global Variables on the HC2.

Can anybody help with a complete working php script?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...