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

  • Topic Author
  • It's been a while since my last visit here. Thank you for all the information and comments. I've read that all and have made all the improvements that could be done quickly to this code.

     

    So the current version is updated thanks to:

    W dniu 13.03.2018 o 18:58, FSE napisał:

    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)

     

    The error occurs when you start the Lua scene before having the VD working properly with BleDevices global variable. Maybe my previous description was not stressing that enough that the device should be done right first. Now such a situation is detected and reported properly.

     

    W dniu 28.03.2018 o 09:36, Sirhideo napisał:

    @korniza so what type of global variable for both VD and Scene to make everything works?

    I made now that all global variables are created automatically. No need for manual steps of this kind anymore.

     

    W dniu 18.04.2018 o 18:50, Sirhideo napisał:
    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?

    You got the right answer already, but I also included an extended example in the current source code.

     

    And more answers...

    W dniu 2.08.2018 o 07:47, FSE napisał:

    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?

    My iNode LAN works with firmware version published in December 2017 ("FW date: Dec 14 2017/09:10:32"). I had no issues about it for more than 18 months right now. It is stable. I even use it as a power failure indicator: it is not plugged to UPS (whereas HC2 and NAS are), so when the device disappears from my LAN, I know there is something wrong with the power line.

     

    W dniu 20.01.2018 o 10:55, jack.daniels napisał:

    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.

     

    W dniu 18.03.2018 o 01:27, FSE napisał:

    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. 

    Well, the device range is connected to Bluetooth limitations. If you need a larger area to be covered with BLE devices detection you could use more then one iNode LAN device. Each device should use a different global variable for storing detected BLE events (BleDevicesA, BleDevicesB, ...). The best way to merge these results would be an updated Lua scene, which could analyze more variables and properly select best data (i.e. select stronger signal if the same BLE tag is seen in many iNode LAN devices). This is not supported with the current version of Lua scene.

    Another (not so nice, but quicker to achieve) workaround for that could be duplicating not only the BLE Detector VD but also the BLE Users scene. Each scene copy should have different global variables for users (like: isZenekHomeA, isZenekHomeB, ...) and additional code can interpret these variables to get final detection value (local isZenekHome = isZenekHomeA or isZenekHomeB or ...).

     

    W dniu 20.01.2018 o 10:55, jack.daniels napisał:

    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

    AFAIK, you cannot use ping command directly within Lua (and os.execute is disabled in HC2). Ping uses ICMP Echo which is another network layer than ones available in Lua (simplifying: you must tell the port to connect in Lua - i.e. use connection protocol), thus such HomeKit exact port (based on ping) could not exist. A similar solution for HC2 (but using TCP, so it needs an open port to work) is implemented with 

    Network Device Monitor. See the link below.

     

     

    The choice to use WiFi for presence detection is not an option for me. The range would obviously be better, but (because of the same "better range" reason) devices using WiFi need much more power to work. I could not depend on my mobile phone, because I use some battery optimizations and scheduling to switch WiFi or even the whole device. BLE Tag is much more reliable in my case because it has no simple option to turn it off :).


    Edited by macjoker
    • Like 1
    • Thanks 1
    Link to comment
    Share on other sites

  • Topic Author
  • I rearranged the description of the VD and added all files to the Downloads section, but it is right now shown as pending...

     

    Link to comment
    Share on other sites

    I would recommend upgrade your inode beacon to ER14250 battery version.  The signal is much more stronger than CR battery version :) 

    Link to comment
    Share on other sites

    @macjoker

     

    Hello, I am using your VD and Scene since released.  Thank you very much indeed.  I am using the default setting all the time and it has been working perfectly.

     

    Now, I have installed danalock and added into HC2.  I would like to use iNode ibeacon to detect my presence so that the Danalock scene can be triggered fast enough to unlock the door for me.  Therefore, I would like to make the VD for device detection more frequent.  Can you please tell me which parameters I should change in order to make the detection like every 1 second? Because unfortunately I do not really understand the meaning of each parameter..

     

    READ_TIMEOUT = 10000

    SECONDS_TO_FORGET = 300

    SECONDS_BETWEEN_STORAGE = 5

    INITIAL_DEAF_SECONDS = 10

     

    Thank you!

    Edited by Sirhideo
    Link to comment
    Share on other sites

  • Topic Author
  • @Sirhideo

    Try

    SECONDS_BETWEEN_STORAGE = 1

    This will save all detected BLE devices to a global variable every second. Please mind that making this value even smaller (0) may work if you have only a few devices nearby, but most probably that could freeze your HC2 (many devices will cause continuous processing and saving changes).

    Link to comment
    Share on other sites

    • 3 months later...

    hello, i have error 

     

    [DEBUG] 20:40:02: 2019-10-24 20:40:02.611260 [ fatal] Unknown exception: /opt/fibaro/scenes/392.lua:107: attempt to index local 'timeString' (a nil value)

     

     

    thx for your help ,and great work

    Link to comment
    Share on other sites

    • 2 weeks later...

    @macjoker Hello,  Every time I restart HC2 your scene update random users variable.  I set the scene to run every second .let me tell you the scenario.

     

    1) Current user status : all members are present (i.e. all isXXXhome variable == "true")

    2) I reboot HC2

    3) When reboot finishes, one random variable, ie, sometimes isMomHome.. sometimes isDadHome.. etc,  changes to "false" by your scene, and after 1 second it changes back to "true". (on your VD: SECONDS_BETWEEN_STORAGE = 1)

     

    This sudden false to true change would trigger my door lock scene to unlock the door.

     

    if fibaro:getGlobalVariable('isXXXhome') == "true" then

      fibaro:call('doorlockID', unsecure')

    end

     

    Is there anyway to fix this? very dangerous if no one home and HC reboots

     

    I found this error by setting your ble scene temporarily to manual and reboot HC2, and then all isXXXhome global variable are stable.

     

    Thanks!

     

    Edited by Sirhideo
    Link to comment
    Share on other sites

  • Topic Author
  • W dniu 24.10.2019 o 20:46, Thomas Cardif napisał:

    hello, i have error 

     

    [DEBUG] 20:40:02: 2019-10-24 20:40:02.611260 [ fatal] Unknown exception: /opt/fibaro/scenes/392.lua:107: attempt to index local 'timeString' (a nil value)

     

     

    thx for your help ,and great work

     

    I'm sorry but your description does not give enough information. I do not know what steps you have made before the error happened.

    My guess is that the problem is not within a scene, but it's connected to the VD.

    Please make sure first, that the VD is working properly and indicating expected devices presence (as stated in FAQ).

    Link to comment
    Share on other sites

  • Topic Author
  • 11 godzin temu, Sirhideo napisał:

    @macjoker Hello,  Every time I restart HC2 your scene update random users variable.  I set the scene to run every second .let me tell you the scenario.

     

    1) Current user status : all members are present (i.e. all isXXXhome variable == "true")

    2) I reboot HC2

    3) When reboot finishes, one random variable, ie, sometimes isMomHome.. sometimes isDadHome.. etc,  changes to "false" by your scene, and after 1 second it changes back to "true". (on your VD: SECONDS_BETWEEN_STORAGE = 1)

     

    This sudden false to true change would trigger my door lock scene to unlock the door.

     

    if fibaro:getGlobalVariable('isXXXhome') == "true" then

      fibaro:call('doorlockID', unsecure')

    end

     

    Is there anyway to fix this? very dangerous if no one home and HC reboots

     

    I found this error by setting your ble scene temporarily to manual and reboot HC2, and then all isXXXhome global variable are stable.

     

    Thanks!

     

     

    I believe I have solved similar issue before. Could you confirm using the latest version (1.2) of VD?
    (There should be INITIAL_DEAF_SECONDS variable set to 10 secs to workaround such flickering as you describe).

     

    As stated in changelog for 1.2:

     

    Cytat

    Fix for initializing issue, improvements:

    • Saving global variable is enabled after X seconds from start.
    • Global variables are created automatically.
    • More debug information.

     

    Link to comment
    Share on other sites

  • Topic Author
  • 5 godzin temu, Sirhideo napisał:

    @macjoker Hi, I am on v1.2, INITIAL_DEAF_SECONDS is 10.

     

    Ok, so I'll double check that, but definitely not this week or even fortnight. I'm really swamped these days.

    Thx for the report.

    Link to comment
    Share on other sites

    • 2 weeks later...
    On 11/4/2019 at 4:01 PM, macjoker said:

     

    I'm sorry but your description does not give enough information. I do not know what steps you have made before the error happened.

    My guess is that the problem is not within a scene, but it's connected to the VD.

    Please make sure first, that the VD is working properly and indicating expected devices presence (as stated in FAQ).

    sorry for the late report.
    It was a mistake when copying the "" were wrong

     

    Link to comment
    Share on other sites

    • 1 month later...
  • Topic Author
  • Hi @Sirhideo ,

     

    I tried to reproduce the reboot problem you have described. Unfortunately, that was not successful. I have set SECONDS_BETWEEN_STORAGE = 1 and rebooted my HC2 many times but could not observe user variables "flickering" in the log.

     

    My only guess is that probably your tag devices report their presence sometimes exceeding 10 seconds interval (which is assumed by default with INITIAL_DEAF_SECONDS = 10). That would made some of them not available within "BleDevices" global variable for the first few reads (and based on that global value user variables are evaluated and saved). That could result the behavior you describe.

     

    Could you please try increasing the value of INITIAL_DEAF_SECONDS to 30 seconds? And please let me know if that helps.
     

    Link to comment
    Share on other sites

    • 2 months later...

    Hi@macjoker.

     

    I am using the Inode lan solution now for a few months and it is working great. Let we say i is working for 99% so that is good.

    using Tile BLE tags and in a range of ca 15 mtrs from my home Inode detects my presents.

    Now I have bought the Fibaro HC3 and want to migrate from HC2 to HC3. My question is do you have a migration from HC2 to HC3 for the VD and the scene.

    I have not yet the skills to make the translations for the Lua scene and VD.

    Is there someone to help me.

     

    thanks

    Link to comment
    Share on other sites

    • 3 weeks later...
  • Topic Author
  • W dniu 29.02.2020 o 11:22, RobS napisał:

    Now I have bought the Fibaro HC3 and want to migrate from HC2 to HC3. My question is do you have a migration from HC2 to HC3 for the VD and the scene.

     

    @RobS

     

    Well, I still keep using HC2. I believe I will upgrade to HC3, but definitely not this year (I am not an "early adapter"). Although the conversion should be fairly easy (there is not much fibro-specific code; LUA generic parsers do most of the job) without the new unit testing might be difficult. So... sorry, but I cannot help you right now.

    Link to comment
    Share on other sites

    • 1 year later...
    • 1 month later...

    Hi guys, you think this will also work with Apple Airtag? :) As I have 4 of them, I would love to use them as presence detectors for my HC3 scenes. I really don´t want to buy another locator for this purpose :(

     

    Thanks a lot. 

    Link to comment
    Share on other sites

    • 5 months later...

    Hi there, would it be possible to redo it for HC3? I have the iNode device, but can´t configure HC3 with the presented details here. Thanks a lot

    Link to comment
    Share on other sites

    • 3 weeks later...

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