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


[TUTORIAL] Presence detector - iNode LAN + any BLE gadget (and no more devices)


macjoker

Recommended Posts

 

Please login or register to see this attachment.

Please login or register to see this attachment.

 

I recently came up with an idea to keep track of each resident presence with Bluetooth devices they keep taking with them. To achieve that I bought iNode LAN device, which can bring BLE devices into existence in Ethernet network. The idea was not really that... fresh as I thought. Just see

Please login or register to see this link.

. But I definitely didn't want to use any other pieces of equipment. And this post is about how to get all these things work together (HC2 + iNode LAN) with full source code attached.

 

What you need (except your HC2):

  1. Please login or register to see this link.

     - it can detect any Bluetooth 4.0/4.1 device (Bluetooth Low Energy = BLE)
  2. BLE tag (

    Please login or register to see this link.

    ,

    Please login or register to see this link.

    Please login or register to see this link.

    , etc.)

 

Remarks about the list above:


Instead of iNode LAN, you could buy an extended version iNode LAN Duos, but I don't recommend that. Why? The "Duos" version has equipment for both BLE and Bluetooth 2.1 so that you could detect older devices too. But these devices most probably will not be proper for the goal we want to achieve. Bluetooth 2.1 devices have shorter range and drain the battery much more quickly. If we use them for identifying persons we can experience more "flickering" about someone's presence (range issues). Moreover, changing the battery of a small device attached to a bunch of keys every few days or weeks (not months!) would make the solution too hard for maintenance. If we are going to stick to BLE devices, the "non-Duos" version is good enough.


Instead of iNode Beacon you can use any device that you can carry with you. The device has to communicate via BLE, that's all. That might be your smartphone as long as you keep your Bluetooth ON all the time.

 

What should you do:

  1. Configure your iNode LAN to use unicast or broadcast for sending datagrams (UDP packets)
    • Go to the Setup page.
    • For "BLE IP address" put your HC2 IP address (unicast) or broadcast address (192.168.1.255 e.g.)
    • For "BLE IP port" you may leave the default value (20000).
  2. Create a new virtual device (BLE Detector).
  3. Update IP Address and TCP Port (use the same values as for iNode LAN in step 1).
  4. Create a new scene (BLE Users).
  5. Update config values in the scene (provide names and MAC addresses of persons and their belongings).

 

That's all to make it work!
Now you can use global variables you have defined in step "2-second-dot" to check if a person is away or home.
 

Want to tweak it? Sure!

There are more options. Please read all the comments in the source code.

 

You may try to:

  • define MACs of devices to ignore in discovery (your iNode LAN itself),
  • define signal values for IN/OUT events (separately for each user),
  • define the timeout value for each device (this also makes user away),
  • turn on/off debug messages.

 

What are these scripts missing?

Only basic information is decoded from BLE datagrams (counter, MAC address, and signal strength). If you use iNode Sensors you will not get additional values (like temperature, pressure, magnetic or movement changes).

 

Why is it better than other solution (x) of presence detection?

  • It does not depend on any movement in your house,  which can make many false positives - a running dog e.g. (x = motion sensors)
  • It is independent of other devices. HC2 communicates directly with iNode LAN. (x = RaspberryPi to read iNode and press some virtual buttons in HC2)
  • More stable results (x = python script from iNode website; explained below). 

 

The Python script published by iNode manufacturer for presence detection uses only signal strength. That means to detect that someone is leaving we need to use some (lower part) signal range to have the record of going away. This additionally reduces the signal range for detecting "being home" (higher part of the signal range) and can give effect to the person appearing and disappearing all the time.

To avoid that we also check the latest timestamp of the device activity. Owing to this feature we may extend range signal for "being home" to all possible values, and use only timeout to decide whether a person is home or not (set "-100" to both signalIn and signalOut in users config to achieve that).

 

 

A few more details. Here are some logs of the working device...

Please login or register to see this code.

and the scene:

Please login or register to see this code.

 

For my configuration, I am using two pieces of notiOne. They are really tiny, the batteries are supposed to stay alive for about a year. Additionally, you can track them whenever someone with BLE and their App is near. 


The results I get in my flat, where walls are made of silicate blocks, are quite stable. iNode LAN can detect these notiOnes with the weakest signal (-90 to -88 dBm) from a distance of 7-8 meters even through two silicate walls (24cm + 12cm thick). So placing iNode LAN in the middle of the flat covers the whole area.
 

 

Edited by macjoker
Version update 1.2 -> 2.0
  • Like 2
  • Thanks 2
Link to comment
Share on other sites

Hi, thanks for you great work!

 

The presense detection is very convinient for home automation. But BLE is small range cover, somtimes my BLE smartwatches disconnecting from mobile when i go other room.

So, this is definatley NOT suitable for a big house.

 

I guess, the WiFi is better for this. But I have not seen ready solution for Fibaro. There is homebridge-people plugin I have tested for the Apple HomeKit and it works fine (for me)

It works this way: there is an array of people (actually host ip addresses) preconfigured, each host shows as presense sensor inside HomeKit.

It starts ping loop for every host and breach the sensor when it cross detection threshold.

 

If someone knows equal solution for the Fibaro, let me know, please

 

BR

Link to comment
Share on other sites

  • 1 month later...

I have an issue with the scense. When I try to run it I get an error. I have set BleDevices as Predefined Variable as Table (I will get the following error if I just put it as a regular variable [ fatal] Unknown exception: /opt/fibaro/scenes/41.lua:93: bad argument #1 to 'pairs' (table expected, got number)

 

 

Please login or register to see this code.

What else I miss?

The other variables (for example isZenekHome) what type they have to be? Do I need to insert the ip address/port of the inode device on the VD? Does it work on different subnets?

Please Help!

 

Link to comment
Share on other sites

it worked! it seems that there is another "hardware" limitation. iNode LAN has limited coverage on a house so it is not good for everyone. I wonder if we can increase coverage adding multiple iNode devices or even better hack the antenna. 

Link to comment
Share on other sites

  • 2 weeks later...
  • 2 weeks later...
On 3/28/2018 at 5:26 PM, korniza said:

BleDevices -> Table

all the other -> common variables

 

hi @korniza,

 

Table..........common....?

 

Do you mean

 

Table: upper part of global variable screen

common: lower part, i.e. predefined variable?

 

Thanks

Edited by Sirhideo
Link to comment
Share on other sites

  • 2 weeks later...

Hello, @macjoker,

 

is this solution still working? I have purchased TrackR pixels and inode LAN.   On HC2 I have below issues.

 

SCENE:

[DEBUG] 00:43:28: [1,31m2018-04-19 00:43:28.2888709 [fatal] Unknown exception:

/opt/fibaro/scene/260.lua:100 bad argument #1 to 'pairs' (table expected, got number)

 

VIRTUAL DEVICE:

 

IGNORED_DEVICES = { ["11:22:33:44:55:66"] = true }

For those mac addresses I would like to ignore, what is the correct syntax to put them in?

 

Update IP Address and TCP Port. Use the same values as for iNode LAN.

What is the port of iNode LAN, 80?

 

iNODE LAN SETUP PAGE:

What is the port of BLE IP Port, default 20000?

 

Thanks

Link to comment
Share on other sites

On 4/6/2018 at 5:33 PM, Sirhideo said:

 

hi @korniza,

 

Table..........common....?

 

Do you mean

 

Table: upper part of global variable screen

common: lower part, i.e. predefined variable?

 

Thanks

 

Hi @korniza

 

Ok so after an hour of trial and error I understand that BleDevices is a predefined global variable and its value is "table" ..

After this is done I get the exactly same error message as you got...

Please, may I know how do you fix it?

Link to comment
Share on other sites

3 hours ago, Sirhideo said:

 

Hi @korniza

 

Ok so after an hour of trial and error I understand that BleDevices is a predefined global variable and its value is "table" ..

After this is done I get the exactly same error message as you got...

Please, may I know how do you fix it?

1st on iNode you need to configure port 20000 and ip address that broadcast to be on the BROADCAST IP of the NETWORK that both devices are placed.

I assume you use a 255.255.255.0 mask and lets say that both devices are registered with ip 192.168.1.xx . 

On i-Node you need to set on ip field the ip 192.168.1.255 and port 20000. On the VD on fibaro you need to set ip address of VD on 192.168.1.255 and port 20000.

Another trick is to delete and create back again the variables with tables.

It did worked for me.

hoped I helped a bit.

Link to comment
Share on other sites

nice to hear! Still if you use BLE tags for presence detection, you need to find reliable one because most of them have small wireless range.

Link to comment
Share on other sites

@korniza, you are right, gonna test the trackr pixel. By the way how about ignore device, do you know how to set this up?

 

IGNORED_DEVICES = { ["11:22:33:44:55:66"] = true }

 

comma seperated? my inode lan can scans through my neigbhour...

Link to comment
Share on other sites

it looks like this...

IGNORED_DEVICES = { ["08:EF:3B:1F:DC:BE"] = true, 
                    ["56:48:47:A5:13:F5"] = true,
                    ["C6:89:74:94:E2:09"] = true }

Link to comment
Share on other sites

it is a very early version of a device that uses the previous sence/vd for iNode. I build it to check the presence of family members. If you like, you can build an avatar of person from 

Please login or register to see this link.

The key is that a user may have more that one BLE device to track, so I wanted to check if one of the tags/mobiles/etc is missing. In my case my children do not have any keys, so I use BLE tags on their bags. The problem is that they use different bags for school, after school activitis.

So you need to add as many tags on the BlueUserTable. As it is a very basic version you need to search from the variable table.

for example 

Please login or register to see this code.

Also if user is a real Fibaro User (my pet cat does not have access ;D) you need to enter the id on FibaroUser. Else (if it a cat with BLE collar) you leave it empty.

The reason that I want to use UserID is to get coordinates of the user when they are away and display a AWAY message with a url to google maps with log/lat of user.

 

If someone like this, I like to get help to make it compatible with HomeTable, SMsgH, Home Status from @Sankotronic and others.

Please login or register to see this attachment.

Link to comment
Share on other sites

@korniza Hi, is this VD running on top of original author's VD and Scene?  Right now I am having hard time to determine the suitable in/out signal for 5 beacons due to the original BLE users scene debug windows shows way too many dummy BT devices. I have exclude as many devices as possible in VD but not much use since new strange devices keep coming from iNode LAN... (if original author see my post could you make the VD include devices instead of exclude?)

 

I cannot rely on the scene debug log to see dbm for each device when I am outside main door and try to remote control my PC browser (with BLE users scene debug screen) because the log keep scrolling..

 

Can you please elaborate more about your VD/solution? or maybe some screen shot would help me understand more.

Edited by Sirhideo
Link to comment
Share on other sites

1 hour ago, Sirhideo said:

@korniza Hi, is this VD running on top of original author's VD and Scene?  Right now I am having hard time to determine the suitable in/out signal for 5 beacons due to the original BLE users scene debug windows shows way too many dummy BT devices. I have exclude as many devices as possible in VD but not much use since new strange devices keep coming from iNode LAN... (if original author see my post could you make the VD include devices instead of exclude?)

 

I cannot rely on the scene debug log to see dbm for each device when I am outside main door and try to remote control my PC browser (with BLE users scene debug screen) because the log keep scrolling..

 

Can you please elaborate more about your VD/solution? or maybe some screen shot would help me understand more.

I used @macjoker VD and Sence. I suppose that you have already set a number of variables that respond to the names of your ble tags on Sence "BLE Users". Even without my VD, you can use the variables to any sence to trigger actions.

 

Please login or register to see this attachment.

Please login or register to see this attachment.

Please login or register to see this attachment.

Link to comment
Share on other sites

I have talked to iNode support and he is willing to update the firmware approximately next week, to implement whitelist function, not sure how, maybe on LOCK page.

 

This will enable iNode Lan to detect only specific devices, in terms of mac, instead of scanning everything.  this decreases the udp packet size received by hc2.

Edited by Sirhideo
Link to comment
Share on other sites

  • 3 months later...

hello!

I face issues with stability of inode. After a week it seems that it crashing (no web gui) and there is no active connection with HC2.

Did you get any firmware that is stable?

Link to comment
Share on other sites

52 minutes ago, korniza said:

hello!

I face issues with stability of inode. After a week it seems that it crashing (no web gui) and there is no active connection with HC2.

Did you get any firmware that is stable?

 

@korniza I am using

Please login or register to see this link.

from "iNode - Firmware" which introduced Mac address whitelist like I mentioned on previous post.  So far it is perfectly stable for me.

 

If you decide to give it a go please remember to update

Please login or register to see this link.

  as well from "iNode LAN - HTML" directory

 

Maybe this helps filter out meaningless BLE devices which reduces udp packet size send to your HC2.

Edited by Sirhideo
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
Reply to this topic...

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