2

Presence recognition in Fibaro Home Center via Mother Sense Cookie

by crissxcross7. July 2015

A short while ago, I presented to you Mother Sense. Now I will show you, how to connect Mother Sense with your Fibaro, to use the cookies on your key ring for presence control.

This tutorial is about to get a credible presence variable in Fibaro System, to control scenes with it. So you can switch off all lights automatically, or let the vacuum do the cleaning by default, as soon as you left the house. We want to realize that by using Mother Sense and the cookies. Why not by the Fibaro App? As far as I’m concerned, I think the Geo-Feature of the Fibaro App is not useable. The iPhone battery itself is not really a runtime-hero and when the Fibaro GPS-Function is activated, the battery will empty out very fast. I already described Presence recognition via Ping at siio.com. It works. But I’m confident, that it works much better with cookies by Mother Sense.

Not long ago I detailed presented you Mother Sense, the sensorsystem for fitness, health and security, here at siio.com including a Video At that Mother (the matroschka-like figure) is the hub, which has to be connected to your router by LAN-wire, so it’s able to communicate to your Mother Sense online account. Via 868MHz band Mother communicates with its cookies. These are the sensors, which can measure temperature and movement. In the case, that they can’t establish connection to Mother, they save their data up to ten days. Therefore perfect sensors at home and on the go.

mother-8-von-15Now it gets exciting: How I explained in the conclusion of my Mother Sense article it’s a very nice toy, but it’s purely sensor technology. In this tutorial I will show you, how quickly you can connect Mother Sense via API with your Fibaro (or any other smart home system)to use Mother’s sensor data for your smart home.
For example you can create a presence/absence recognition that way and everything will be deactivated automatically, when you’re leaving.
How it works:

1. Register Mother Sense API key

First you need an API access token. This is the key to grab your Mother Sense data via API interface later. This access point is independent from your Mother Sense online account password. The script which I’ll show you, is still working, even if you change your password someday.

Initially visit the website https://sen.se/developers an click “Become a developer”. Complete the online form. Preferably use the same email adress as for your existing Mother Sense account. For “Usage” state “Personal”. The programming language is “LUA”. For reason I simply stated, that I wanted to connect Mother Sense with my smart home system.

Within 24 to 48 hours your developer account should be activated. After that I could log in to my Mother sense online account and navigate to the menu item “Developers” at the top. Instead of the menu point “Become a developer” you’ll now find the point “API key”. After clicking it, you can see your API token. It’s an incredibly long combination of numbers and letters.

Mother Sense API Access Token

Mother Sense API Access Token

2. Install Mother App “Presence”

Of course we need one cookie, that tells Mother if you’re at home or not. You can fix this cookie on your key ring, put it in your bag, tape it on your sneaker, or whatever. Main point is, the cookie leaves your home with you.

Mother-schluesselbund-cookieFor that log in to your Mother Sense online account. Navigate to “MORE” – Add Apps & Devices at the bottom and choose the application “Presence” here. In the installation routine state now, whose presence you want to track. If you live together with your girlfriend, it would be stupid, if all the lights and the heating shuts down, when she’s already at home. Although…
:-D

So, if you didn’t create a “Person” in Mother for your girlfriend yet: Do it! (Menu: My Account > My Family)

Back to installation of the “Presence” app. Choose the related cookies for the particular persons in the drop down menu. These are the personal companions, that will report the presence/absence of the persons until now. In the last step you can choose, if you want to be informed by push or email, when one of the persons is coming home. It’s very convenient, when you’re in the office and want to be informed by push, when junior has arrived from school.

That’s it. Next step.

3. Create Fibaro HC2 Variable

In step 5 we will ask API every 30 seconds about the state of our cookie, which is related to the “Presence” application, via LUA scene. “Presence” is the Mother app that detects, if the cookie is at home or not. We want to write the state into a global variable, to use it in other scenes later.

To create a variable in Fibaro Home Center, use the websurface of your Fibaro and than Steuerungen > Variablen Steuerungen (???). Now add a new variable. You can choose the name at will. I named the variable „Cookie_Chris“ for example.

When you have employed more than one user in step 2, you have to create another related variable here.

Fibaro HC2 -Create variables

Fibaro HC2 -Create variables

4. Find out cookie ID from XML

With Mother you get 4 cookies. Because we want to ask the right cookie via API later, we first need the UID. This is a definite ID, that every cookie, application, or smartphone gets with the Mother app in your online account.

For this purpose visit: https://apis.sen.se/v2/

Here you will be asked for a username and your password. You need the username (not the email adress) of your Mother online account. You can find out the username at https://sen.se/profile (Menu item: My Account).

After you logged in and called up API, you see 5 more feeds. Including the feed Users (https://apis.sen.se/v2/user“) Call it up now. Here you will find a list of all your devices like your Mother hub, all smartphones with Mother app and all cookies.

Now look for the cookie, which you assigned in the “Presence” application. In my example these were the cookies “Brisk Ahead” and “adored blackberry”. Click the link after “url:” at the corresponding cookie. Here you will find all applications, that you have installed to mother. The respective array “used” elaborates, if the cookie is used in it, with the values “true” or “false”. Look for the “Presence” app. At “used” should be given “true”. Important for us is now the value behind “uid”. This cryptic sequence of numbers and letters will be needed in the next step.

Now click the link at “url:” in the block labeled “Presence”. After that use the link at “eventsURL”. Here you can check, what the Fibaro scene will read later. There should be displayed “present” in the body, if you are at home and “absent”, when you are not. Furthermore we need the value, that is displayed at “Profile”. In my example it’s “WalkStandard”.


So, this was the catchiest part. Not it will be just copy & paste.

5. LUA Scene populates the presence variable

LUA Scene

LUA Scene

First here is the completed LUA script, that you copy into a LUA scene in the Fibaro HC2. Following this, I will explain you the most important lines.

Following lines you have to adjust:
Let’s begin with line 26.

mother-presense-zeile26

As “Cookie Presence” you register the UI of your cookie, which we found out in step 4.

The URL for the API invocation will be created by this UID. Is the state of invocation =200, everything is okay. After that the script reads the XML answer data, jumps in the block “Objects” and seeks for the profile. This we discovered in step 4 too. Change this respective, appropriate for you in line 37. In my example the profile is “WalkStandard”.

mother-presense-zeile37

After that, it reads out the state of “Presence”. Is it “present”, he will display the global variable (which you created in step 3) in line 46 as 1 for “present”. If the value is absent, it will be displayed in line 48 with 0 for “absent”. You have to enter the name of the global variable here, that you created in step 3:

mother-presense-zeile47

Finally we define the access token at “Options”. For authorization enter the access token (which you created in step 1) at line 56.

mother-presense-zeile56

Save and done. API will be requested every 30 seconds now and your global variable (that you can use in all scenes) will be displayed as 1 or 0 for present/absent

For additional cookies, that can be used for presence control of your family members, simply create another global variable. Also a LUA scene with script and adapt the UID of the cookie and the standard profile.

The cookies reports to Mother now in a 15 minute interval. That means, the state doesn’t switch to “present” (1) immediately, when you open the door.

Examples for scenes

Now I use the scene, to switch off all the lights and electric devices like coffee machine, water boiler, TV, HiFi receiver, subwoofer… via adapter plug/socket.

Moreover my vacuum robot starts and begins to clean up my house. Side note: For that reason I ask for further variables. For example, whether it’s day (Set daytime variable per scene), or not, because I don’t want Roomba to start, when I walk off at night again. Furthermore I check if the battery is charged to 50% minimum – I can figure it out via RooWifi API . (Roomba cleans up your Smart Home). Additionally I created a global variable: “Roomba_schon_geputzt”, which I set to 1 with the starting scene of Roomba. Same night at 00:01 I use another scene to reset it. So I prevent the vacuum to start again, when I leave my house more often.

Roomba clean up the room, when leaving the house

Roomba clean up the room, when leaving the house

What do you do with the presence variable? Respectively: What would you do with the presence variable? Please leave a comment below.

Newsletter lesen überall

translated by Paul

This text was translated by [Paul]. You can read the [original] in German on siio.de

About The Author
crissxcross
Hi, I'm crissxcross, qualified IT system electronics. Professionally, I work as a product marketing manager in the Smart Home. And private I am self a Smart Homie :-) If I do not sit in front of the monitor like I photograph and am a big fan of Apple. I am the founder of the SiiO.de blog.
  • PG
    18. May 2016 at 21:56

    Are you still using this with success?
    I see that their feed layout has changed, and now fibaro says present eventhough its absent?
    “profile”: “WalkStandard”,
    “feedUid”: “CBOrGsaGCowTQWaTSbFvxJak4MrJott1”,
    “gatewayNodeUid”: “5fVQ00yS76AdXxsWmOX8wD2UrmW7ER4k”,
    “dateServer”: “2016-05-18T19:21:01.483”,
    “geometry”: {
    “type”: “Point”,
    “coordinates”: [
    55.971500396728516,
    9.611300468444824
    ]
    },
    “data”: {
    “body”: “Absent”,
    “code”: 404

  • Mert
    3. November 2016 at 15:36

    Is Fibaro stable? Are you happy with Home Center 2?

Leave a Response