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


Tony270570

Question

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.

Link to comment
Share on other sites

Recommended Posts

  • 0
Guest Grupawrc

HansS, great, many ghanks for your answer. One more: are you put to the scene - turn on or of lights" a reapeat which check every minute if the variable in hom or not ?

Link to comment
Share on other sites

  • 0
I use Geofency for the proximity app (not Geofancy, note the slight difference in name). Geofancy is the free app, the one I use is Geofency, which costs a couple of euros/dollars. With the latter, you can setup an web hook, and also test that specific web hook. If something is wrong, you can tell by the output that the app will display.

Meanwhile, I've bee tweaking my setup. I now have several ways to detect presence, all based on the proximity of my iOS device. So it's the ping/mac one,the gps proximity and the proximity to any of my beacons. Each event sets a global variable for that specific situation (I'm inside my home GPS circle, my phone is pingable and so present, I'm near one of my beacons). I have a scene that monitors each of these global variables. It adds up all the values, and if it's greater than 0, I'm definitely at home. If it's 0, then I'm definitely not.

Ahh, interesting idea. But why do you check your presence within the house with ping, iBeacons, ... ? Wouldn't it be enough to set one variable "entering" and "leaving" the gps-location? In that case, you "are" at home, even the barry goes down at night...

Do you change the global variable directly from Geofency? I'm not able to call the fibaro API... I use as a workaround a php-page on my webserver, wich starts a scene (wich changes the variable). But if I try to start the scene with Geofency, it does not work - even with user/pw set

Please login or register to see this image.

/emoticons/default_icon_rolleyes.gif" alt=":roll:" />

Link to comment
Share on other sites

  • 0

Well, it seems to me that most of the methods used for detection are not reliable enough on their own. If you enter the gps range, Geofency sends out the HTTPS call, but I've seen them fail. Doesn't look like there's any kind of retry mechanism here. Sometimes beacons will fall of the radar for a short time as well. So combining methods is my way of adding reliability.

As for calling Fibaro directly, that's something I don't want to do, because this means exposing your HC to the Internet. I also use an intermediate PHP page. It's called using HTTPS, so stuff is encrypted, and it requires HTTP basic authentication. The page is served by a virtual host, so there's nothing else to find on there. I also setup source IP ranges that are allowed to connect.

I looked at the reverse proxy topic (

Please login or register to see this link.

) which lead to my current configuration. A real reverse proxy setup allows you to login to your HC remotely, so it should also be possible to set variables or start scenes from Geofency directly I imagine.

Finally, note that changing global variables through the API doesn't trigger scenes based on those variables.

Link to comment
Share on other sites

  • 0
HansS, great, many ghanks for your answer. One more: are you put to the scene - turn on or of lights" a reapeat which check every minute if the variable in hom or not ?

I don't. The scene with the code in an earlier topic decides if I'm home or not, based on several other variables. It then sets the 'ultimate' variable (Hans_Is_Home). I have a scene that turns on the living room lights. It monitors the lux value of my motion sensor, and keeps an eye on the sunset time. If the lux is 2 or less, and it's within an hour of sunset time, it checks if someone is at home using the global vars. If so, the light will turn on.

I've noticed there's a flaw in this setup. Using multiple factors to determine if someone is at home works. But if one of the methods fails (Geofency's call that you left the house cannot be sent for example), the sum of all methods will be wrong. So that's something I still need to look at.

[ Added: 2015-02-01, 17:49 ]

HansS, I like you estimote setup. Can you show your PHP code on your NAS?

The php page that Geofency calls looks like this:

Please login or register to see this code.

Geofency sends different information based on what triggered the event (so different fields and values for gps and beacons), that's why I test for a beacon event. So this script basically just enters information into the Log table of my database. For one thing, this adds security, but mainly this gives me a log of events. After the insert, the process.php script is called. It looks like this:

Please login or register to see this code.

So Geofency sends the deviceID that triggered the event. Process.php looks at this value, and decides what button number to push on the virtual device.

The button for my Iphone contains this code:

Please login or register to see this code.

I left out IP and beacon id's here and there, for obvious reasons, and stripped the code (I have more regions and beacons than are in the above code), but this should give you an idea of what I am doing.

So basically, the virtual device checks what happened, sets the related global variable, and sends me a push notification. The push notifications are enabled at the moment so I can monitor the system.

As you can see different global vars are set based on if I'm at home or not, and what beacons Geofency sees. I have a scene that monitors all these variables for one person, and then sets a global variable Hans_Is_Home. Some scenes check this final variable to determine if someone's in the house.

As I stated earlier (or in another topic) this doens't work flawlessly yet. If Geofency cannot send a HTTPS call, one of the variables will not be changed, and I might be seen at home while that's not really the case. So this is something I have to figure out still.

I would like to get the Estimote SDK to work in combination with Swift, so I can try to write my own app. I can then determine what beacon I am closest to in case I see more than one, and so maybe get indoor location to work (turn on the light in the computer room when I go there). Also, Geofency just sends one HTTPS put when entering or leaving a GPS area, or detecting a beacon. If I can make my own App, I can repeat POSTS to make this stuff more accurate, or even better make it two way communication, so a confirmation that the global variable related to the event has indeed been changed.

Link to comment
Share on other sites

  • 0

HansS, thanks, i just ordered the ibeacons so will do some testing later this week. in principle i get your code, just cannot figure out how you post the beaconUUID from geofency? Do you call your php with some ?parameters?

EDIT: I just got it - you send json from ibeacon event

Please login or register to see this image.

/emoticons/default_smile.png" alt=":)" srcset="https://forum.fibaro.com/uploads/emoticons/[email protected] 2x" width="20" height="20" /> Ok i may have more questions however later on when they arrive.

Link to comment
Share on other sites

  • 0

Geofency posts all the data by itself. You can setup different gps regions and beacons in the app, and then have webhooks for entry and exit events for each of the regions and beacons. I enabled "JSON-encoded" post format, which makes the app post all the data in JSON by itself. So all my events perform a HTTPS POST to the same page, and then use the JSON data to process the event and react.

Come to think of it, this might be a way to get around the database issue if you want. You can specify a different php page for every event, and then in each page decide what you want to do. You can activate the coming home scene when Geofency sees your near.

But again, I wanted to have multiple indicators, because I have a feeling that Geofency's calls might fail now and again (no cell reception and such). Ah well, something to think about. But the JSON data can be sent easily

Please login or register to see this image.

/emoticons/default_wink.png" alt=";)" srcset="https://forum.fibaro.com/uploads/emoticons/[email protected] 2x" width="20" height="20" />

Link to comment
Share on other sites

  • 0

HansS, just figured this out

Please login or register to see this image.

/emoticons/default_smile.png" alt=":)" srcset="https://forum.fibaro.com/uploads/emoticons/[email protected] 2x" width="20" height="20" /> This really look very very nice. One more thing (as I am not a php master myself). you seem to have getthedata.php to read from your db, would you mind sharing this as well? Brilliant stuff, will soon be in my home, as soon as the beacons arrive

Please login or register to see this image.

/emoticons/default_smile.png" alt=":)" srcset="https://forum.fibaro.com/uploads/emoticons/[email protected] 2x" width="20" height="20" /> I have Synology RS814 exposed to internet on some ports so this seems a perfect setup for me.

Link to comment
Share on other sites

  • 0

Here's the getthedata code. This is actually copied from someone else's code, probably the code for getting stats from Fibaro and creating Highstock charts from them. Anyway:

Please login or register to see this code.

This selects the most recent entry from the database with the given device ID, and outputs the result in JSON. This is what the virtual device can read.[/code]

Link to comment
Share on other sites

  • 0

hey do you have any problems on iphone in sleep etc with Geofency not reporting being away from the iBeacons?

I haven't been consciously testing that. My phone fell asleep quite a while ago, just brought it downstairs, and it did report losing 'sight' of the office beacon. There's a setting that you allow apps to do something in the background. This might also be for the sleep mode. As far as I know, this stuff works. After all, I get notifications when entering my home GPS region and when my phone detects beacons. This is all when the phone is locked while on my way home.

Link to comment
Share on other sites

  • 0

I use GEA and come up with this function.

Please login or register to see this code.

In a VD i check DD-WRT for mac adresses and set variables to 1 or 0.

If you want more info you are welcome to ask 

Please login or register to see this image.

/emoticons/default_icon_biggrin.gif" alt=":-D" />

Link to comment
Share on other sites

  • 0

You have Iphones? If so, do you never have the situation that your device is not detected because it fell asleep?

Link to comment
Share on other sites

  • 0

Yeah have iPhones, and i have à value that i set when they are active (lastseen) and if offline more then 10min we are not home. Now also Geofency so i think it will be à good rule in my home.

 

Before Geofency i did have 30min value for lastseen, but now after some test now i think 10 min will be more then enough. Geofency have not miss any location so far after 5 days.

Link to comment
Share on other sites

  • 0

Hello just wondering if you've tried using bluetooth instead of wifi or gps to detect presence? I always have my bluetooth on and gps and wifi off. I was thinking that there is no point running the script to detect presence if there is no motion in the house however when motion is detected the script then runs. I had reading elsewhere of using the kinect camera to detect who the person is who has entered the house,.

Link to comment
Share on other sites

  • 0
Am new to the forum and I am unable to create a new topic. Can anyone help me?

 

I'm trying to create the next scene

 

Room with AR, and SKY TV

 

When you have no movement in the room, turn off all devices

 

The problem is that if we are in the room without moving or not some movement detected by the sensor,it shuts down the devices.

 

Any idea for this scenario?

Link to comment
Share on other sites

  • 0

Dear Fibaro Experts,

 

Can you please help?

 

I am looking for a reliable way to check if my iPhone is home or not.
The ambition is to turn off lights, heating and so on once I left home.

The Fibaro GPS functionality does not work for me yet.
I created several scenes that would trigger by leaving a point or an area.
I set the GPS checking interval in the access control to 1 minute.
I left home several times for longer times with a distance larger than one kilometer.
Nothing happened. And there is not even a GPS log or info in the event panel.

 

First question: Any advice what I could try?

 

 

Can anybody recommend a reliable alternative that is simple? If I understand HansS solution above this requires an extra PC that I would not have. I am looking for a simple solution of a beginner J This is what I found so far …

 

HansS Solution: Sounds great, but a little too complicated for me

 

 

Alternative A: Ping iPhone but it turns WIFI off in standby
Crissxcross describes a solution by sending a ping to the IP address of the iPhone.
Great idea, but the WIFI turns off as soon as the iPhone goes into the log screen:

Please login or register to see this link.

 

 

Alternative B: via iOS Location + IFTTT
On the old Homeseer I am using the iOS location function and IFTTT. Once I leave home the iOS location functionality triggers a IFTTT recipe. This recipe is triggering the Homeseer IFTTT channel that turns a virtual devise on. Unfortunately the Fibaro Home Center 2 is not on IFTTT.

Second question: Is there a way I could trigger a virtual devise on HC2 by e.g. sending an email or any other IFTTT connection?

 

 

Alternative C: Bluetooth dongle
would it not be possible to use a USB Bluetooth dongle in the HC2. And check if the dongle found the before paired iPhone?

Third question: Any recommendation and simple step by step instructions how that could be done?

 

 

It would be great if you could help.

 

Best regards,
Alex

Link to comment
Share on other sites

  • 0

I've been looking at this, and it's not that easy it seems.

First of all, if you don't have any kind of webserver in between the trigger (for example the Geofency app) and the Fibaro HC, this means that your HC will have to be exposed to the Internet to be able to push virtual device buttons. I believe there's no native HTTPS support for this, other than using the Fibaro remote service. And I do not know if you can send https calls to directly push virtual buttons using the remote service?

Anyway, even if you can access your HC from the Internet, I cannot find a way to send the necessary Json data (needed to identify which button to push on a virtual device) without an intermediate web server or something. The Geofency app does not support custom Json data to be sent. If it did, that would be a very nice solution to your problem. Since it doesn't, you need a gateway to translate an HTTPS call to a an HTTP call to HC, with the correct json data to push a VD button.

The intermediate webserver takes care of the two issues. It adds security by using a reverse proxy kind of functionality, which prevents the need to expose the HC to the Internet directly. It also takes care of injecting the VD button number info into the call to HC (or in my case inserting it into the database).

I think the optimal solution would be to have custom JSon data configurable in an app like Geofency, and use HTTPS to make VD push calls using Fibaro remote.

I have written my own Geofency app, mainly because Geofency also doesn't support a retry mechanism. If an HTTPS call fails, it will report it, but not retry. Resulting in a popup on your phone, but also the lights not switching on when you get home. My app is far from finished however, and I doubt it would pass Apple's approval test to be placed in the store.

That's a lot of text with no easy solution I guess.

As for your other suggestions:

A: Pinging phones is just not reliable, no matter how you try to set it up. If you use phones, it has to be based on an App using it's location services

B: IFTTT would be nice indeed. It could act as the gateway and send the right HTTP post with JSON data. But that would indeed need Fibaro support, or some easy way of sending custom HTTP(S) posts, which is not the case as far as I can see (but I'm no IFTTT user)

C: No experience here, so no clue how that would work.

Link to comment
Share on other sites

  • 0

From the HC2 I log into my access points (3x Ubiquiti Unifi UAP-AC) and see if somebody is connected. So I can determine which light to turn on or not. Before I used the Enginius access points and used the same approach. It is quite reliable.

Link to comment
Share on other sites

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...