Jump to content
Guides for the Forum Read more... ×
Poradniki na Forum Read more... ×
  • 0
jodohl

Presence detection by WiFi

Question

A smart home should know you have arrived without being told. Arriving on a pitch dark freezing cold November evening in Oslo, Norway loaded with carrier bags and all lights turning on when you approach the door. Wonderful idea.

 

So I dived into HC2 Geofencing. Only to find that a useful position update frequency (5-10 seconds) killed my mobile battery. Started thinking of ways your LAN could tell HC2 that the Master had returned, but found the limits of my network competence.

 

Now enter this clever French guy:

Please login or register to see this link.

 who came upon the idea of checking the presence of the MAC address of your mobile device on your LAN. 

 

What he did was simply to make HC2 probe the presence of the mobile MAC address on the LAN ARP table. Frequently probing when not at home, less frequently when at home to ensure quick response when arriving at the door as well as reduce risk of "false departures" when at home. Seemed to work perfectly. The code is nicely written, clearly commented and implementation well explained. A true role model to follow for all the codeaholics out there publishing brilliant code that cannot be implemented or understood outside the immediate congregation.

 

Happy for a while, until I learnt that iPhone has the habit of turning off WiFi after screen closes. Not only is WiFi turned off, but the MAC apparently disappears from the ARP table. My house went into all lights off Absent mode and WAF nosedived....:-( Turned out to be a well known fact and commented on numerous web sites.

 

Here is my workaround: I kept Sebcbien´s presence/absence VDs running in its original form, but made my absence scene manual, with a 15 min delayed setting of a status variable to "Away". My thinking is that pushing a button when actually leaving is no big deal. And good security practise if and when I include a door lock in the system.

 

The arrival scene is however kept automatic and will respond within seconds once you return on the LAN. But you will have to activate the mobile screen to ensure quick WiFi logon and response. Not perfect, but quite good actually. Here are the elements:

 

(1) Sebcbien´s Virtual Device code above, version 2.10 (you might need to activate Google translate from French in the Domotique Forum). This VD code will set a 0/1 Absence/Presence variable. One VD and variable for each family member's mobile MAC address is advisable. You will need to modify in the code (a) The name of your absence/presence variable (b) Your mobile MAC address - to be entered in the VD address field (c) The ID numbering of your icons to be used. Seems I am the only person in the world not knowing that you can easily find this number by right clicking the icon and select "Inspect". Amazingly difficult to find this annoyingly simple procedure.

(2) The code has the ability to change the VD icon depending on Absence/Presence. Quite nice and useful.

(3) A (manual) "Leave" scene that when activated does the leave job, turns off lights etc and triggers a 15 min delayed second scene that eventually sets a status variable to "Away" once you are well away from your door. I had to set up a second scene, since a variable apparently cannot be set with delay in the block editor. This can probably be solved easily in LUA.

(4) An automatic "Arrive" scene that is triggered whenever one of the above mentioned VD variables is set to 1 AND the status variable is "Away". This scene will then turn on lights and devices and set the status variable to "Home". 

 

This approach, although not as elegant as I would have liked to see this, will prevent the "Leave" scene from being triggered when iPhone goes to sleep.

 

I would be great to receive improvement proposals or alternative ideas

Edited by jodohl
typos

Share this post


Link to post
Share on other sites

17 answers to this question

Recommended Posts

  • 1

@

Please login or register to see this link.

; I am new to IFTT so could you please tell me which details you filled in the applet webhook in order to update the variable on your Fibaro?

 

 

Share this post


Link to post
Share on other sites
  • 0

The topic has been moved from "

Please login or register to see this link.

" to "

Please login or register to see this link.

".

 

Temat został przeniesiony z "

Please login or register to see this link.

" do "

Please login or register to see this link.

".

Share this post


Link to post
Share on other sites
  • 0

Hi,

I did something similar, but different. Have scene that checks iPhones presence by pinging directly to  iPhone's  IP (have set on my router constant IP for all five users) and the code is very simple, just few lines. To overcome WiFi issue, I'm using GPS location of fibaro application. It works fine on iPhones with some delay (could be few minutes), but it's better to shutdown the lights and other appliance few minutes later instead of turning OFF when person in home. In addition I'm using motion sensors to identify presence at home and keep everything up and running.

Right now the issue is that sometimes users removing auto connection to WiFi,  so yours and mine procedure won't identify the user.... my backup again GPS location...

In general same idea with different approach.

Now my second backup (which works better than all above) is that I placed two motion sensors outside to identify if someone comes or leaves. By counting the motion I'm able to identify the number of members  at home and when to turn the home off or on.... off course I use all options to make sure that the solution is fully proof. 

 

 

Edited by cag014

Share this post


Link to post
Share on other sites
  • 0

You can try with IFTTT.... Install app on your phone, make 2 location applets (1 for entrance area and 1 for leaving area) and use in applet webhook to update variable on your fibaro. Then use this variable as a trigger to start a scene. 

 

I use it and works like a charme

  • Like 1

Share this post


Link to post
Share on other sites
  • 0

I'm using bluetooth beacons, so im not consuming my phones battery with geofencing. The checks are running in Python on a Pi and submits Api calls to Virtual Device. That device updates my global vars for presence which would trigger other scenes and switch lights either on or off.

 

 

 

 

  • Like 1

Share this post


Link to post
Share on other sites
  • 0

@bl5cky Are you prepared to share this code and approach with the group? Are you identifying individuals being present or just a somebody present ?

  • Like 1

Share this post


Link to post
Share on other sites
  • 0
3 minutes ago, andyp said:

@bl5cky Are you prepared to share this code and approach with the group? Are you identifying individuals being present or just a somebody present ?

 

@andyp Give me some more time for testing and shaping it. I'm definately not a coding expert but I managed it to work.

 

I'm identifiying individuals, my wife and myself have both a Gigaset Keeper that runs on bluetooth low energy. My script scans for the Bluetooth adress if its in range. If so, it triggers the variable of the individual and change the state. From that point everyone would be free how they treat this wihtin their fibaro environment.

 

  • Like 1

Share this post


Link to post
Share on other sites
  • 0

@bl5cky  Intersting I look forward to seeing your update after you have had time to test. I have many uses for it but have never been able to get accurate location based on GPS options or WifI.

Share this post


Link to post
Share on other sites
  • 0
On 1/6/2018 at 6:05 PM, Reintjan said:

You can try with IFTTT.... Install app on your phone, make 2 location applets (1 for entrance area and 1 for leaving area) and use in applet webhook to update variable on your fibaro. Then use this variable as a trigger to start a scene. 

 

I use it and works like a charme

I did it as well but how did you solve in the webhook  in IFTTT w.r.t "user" and "password"?   Your webhook should look like http://user:password@IPaddress_of_ HomeCentre......  unfortunaly user:password is not support in http request anymore, so I cannot get it to work.

Share this post


Link to post
Share on other sites
  • 0
3 hours ago, Levinson_7331 said:

I did it as well but how did you solve in the webhook  in IFTTT w.r.t "user" and "password"?   Your webhook should look like http://user:password@IPaddress_of_ HomeCentre......  unfortunaly user:password is not support in http request anymore, so I cannot get it to work.

Use in webhook:

Please login or register to see this link.

.....

 

user = username for local login, not fibaro account

password = password for local login

ipaddress = your ip for access from outside world to your home

 

Make sure you set a forwardrule in your router to homecenter so you can access it. I myslef use different port then 80 to access my homecenter so in webhook i use ipaddress:port and portnumber is smae as forwardrule in my router.

 

Hope this helps you a bit further

 

p.s. for security, as fibaro does not support https, define a local user with only access to device which you send webhook to. Otherwise interception of webtraffic could lead to complete access to your homecenter from outside!

On ‎8‎-‎1‎-‎2018 at 4:02 PM, HKrook said:

@

Please login or register to see this link.

; I am new to IFTT so could you please tell me which details you filled in the applet webhook in order to update the variable on your Fibaro?

 

 

Please login or register to see this link.

ofbutton

 

Change user, password, ipaddress, yourdevicenumber and numberofbutton in link above to what you use in your homecenter.

 

Hope this helps

Share this post


Link to post
Share on other sites
  • 0
On 11/16/2017 at 11:13 PM, cag014 said:

Have scene that checks iPhones presence by pinging directly to  iPhone's  IP (have set on my router constant IP for all five users)

Would you share the scene? @cag014

Share this post


Link to post
Share on other sites
  • 0
8 hours ago, net said:

Would you share the scene? @cag014

@net

Recently have changed the scene to virtual device, but the code is there. You just need to change the names and their IP Addresses in side the code.

Please make sure that your router assigns manual IP addresses for phones, I mean each phone will have same dedicated IP address.

Please login or register to see this attachment.

Edited by cag014

Share this post


Link to post
Share on other sites
  • 0

Hello

 I'm new in this theme. Many Thanks for The VD. But the code found no Phone. I Hav a Samsung S7. Not Root. Android 8.

 

Ping from Pc to the IP is ok. But not from the HC2 with this VD. Is this a Problem from Lua in Wlan? or.. what must i do in the Phone? Open Port???

Thanks for each Idea..

 

Lusim

Edited by Lusim

Share this post


Link to post
Share on other sites
  • 0
On 11/10/2017 at 5:25 AM, jodohl said:

A smart home should know you have arrived without being told. Arriving on a pitch dark freezing cold November evening in Oslo, Norway loaded with carrier bags and all lights turning on when you approach the door. Wonderful idea.

 

So I dived into HC2 Geofencing. Only to find that a useful position update frequency (5-10 seconds) killed my mobile battery. Started thinking of ways your LAN could tell HC2 that the Master had returned, but found the limits of my network competence.

 

Now enter this clever French guy:

Please login or register to see this link.

 who came upon the idea of checking the presence of the MAC address of your mobile device on your LAN. 

 

What he did was simply to make HC2 probe the presence of the mobile MAC address on the LAN ARP table. Frequently probing when not at home, less frequently when at home to ensure quick response when arriving at the door as well as reduce risk of "false departures" when at home. Seemed to work perfectly. The code is nicely written, clearly commented and implementation well explained. A true role model to follow for all the codeaholics out there publishing brilliant code that cannot be implemented or understood outside the immediate congregation.

 

Happy for a while, until I learnt that iPhone has the habit of turning off WiFi after screen closes. Not only is WiFi turned off, but the MAC apparently disappears from the ARP table. My house went into all lights off Absent mode and WAF nosedived....:-( Turned out to be a well known fact and commented on numerous web sites.

 

Here is my workaround: I kept Sebcbien´s presence/absence VDs running in its original form, but made my absence scene manual, with a 15 min delayed setting of a status variable to "Away". My thinking is that pushing a button when actually leaving is no big deal. And good security practise if and when I include a door lock in the system.

 

The arrival scene is however kept automatic and will respond within seconds once you return on the LAN. But you will have to activate the mobile screen to ensure quick WiFi logon and response. Not perfect, but quite good actually. Here are the elements:

 

(1) Sebcbien´s Virtual Device code above, version 2.10 (you might need to activate Google translate from French in the Domotique Forum). This VD code will set a 0/1 Absence/Presence variable. One VD and variable for each family member's mobile MAC address is advisable. You will need to modify in the code (a) The name of your absence/presence variable (b) Your mobile MAC address - to be entered in the VD address field (c) The ID numbering of your icons to be used. Seems I am the only person in the world not knowing that you can easily find this number by right clicking the icon and select "Inspect". Amazingly difficult to find this annoyingly simple procedure.

(2) The code has the ability to change the VD icon depending on Absence/Presence. Quite nice and useful.

(3) A (manual) "Leave" scene that when activated does the leave job, turns off lights etc and triggers a 15 min delayed second scene that eventually sets a status variable to "Away" once you are well away from your door. I had to set up a second scene, since a variable apparently cannot be set with delay in the block editor. This can probably be solved easily in LUA.

(4) An automatic "Arrive" scene that is triggered whenever one of the above mentioned VD variables is set to 1 AND the status variable is "Away". This scene will then turn on lights and devices and set the status variable to "Home". 

 

This approach, although not as elegant as I would have liked to see this, will prevent the "Leave" scene from being triggered when iPhone goes to sleep.

 

I would be great to receive improvement proposals or alternative ideas

Sir,

can you please share that VD here as I am from India and is not able to open the link (

Please login or register to see this link.

)

 

thanks.

Share this post


Link to post
Share on other sites
  • 0
  • Inquirer
  • On ‎9‎/‎5‎/‎2018 at 7:54 AM, bpkurmi said:

    Sir,

    can you please share that VD here as I am from India and is not able to open the link (

    Please login or register to see this link.

    )

     

    thanks.

    Sorry for not responding. Right now my HC2 has crashed and I have serious restore problems. Hence, I cannot share my VD. Will get back to you if and when I get a new HC2 back on track. The Fibaro backup/restore is a halfway house. Have been told that a cloud solution is now launched. A bit late for me, I'm afraid.

    Share this post


    Link to post
    Share on other sites
    • 0

    I came up with a solution to this and its been working well so far.  It can use either 'Find Friends' on the iPhone or 'Life360' (iphone/android).

     

    There is a bit of set up, but in a nutshell, both apps can send emails to a mail box when you arrive or leave an area. I wrote a web service that interfaces with the Fibaro HC2 and with it you can check your email notification box.

     

    This then sets a global variable in the Fibaro HC2 and subsequently you can then set events to occur 'on change' or when the value is home or away.

     

    The web service is here for anyone interested :

    Please login or register to see this link.

     

    Share this post


    Link to post
    Share on other sites
    • 0

    Can some please provide a link to VD, because it is not downloadable in Australia as well 

    Share this post


    Link to post
    Share on other sites

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now

    ×