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 - Using a Hometable to store device and scene ID's


AutoFrank

Recommended Posts

Thanks. This doesn't seem to be the issue, but it made me think about the references.

I excluded the references one by one and I found that it is the erroneous referral to my own phone, which is named iErnst.

How should I refer to that? Obviously jT.iErnst is wrong....

(still don't understand how the line number is so different)

Link to comment
Share on other sites

Sorry, of course, that should be jT.iOS.iErnst

Then another questions about referencing the HomeTable.

In the definitions statement at the start of a scene, is it possible to refer to the hometabel too?

For example:

 

local jT = json.decode(fibaro:getGlobalValue("HomeTable"))

--[[
%% autostart
%% properties
120 value
%% events
%% globals
--]]

 

Instead of 120 I would like to refer to jT.kitchen.window.

But replacing 120 with that doesn't work, starting with local jT = ... doesn't help either.

Any suggestions?

Link to comment
Share on other sites

10 hours ago, ErnstH said:

Sorry, of course, that should be jT.iOS.iErnst

Then another questions about referencing the HomeTable.

In the definitions statement at the start of a scene, is it possible to refer to the hometabel too?

For example:

 

local jT = json.decode(fibaro:getGlobalValue("HomeTable"))

--[[
%% autostart
%% properties
120 value
%% events
%% globals
--]]

 

Instead of 120 I would like to refer to jT.kitchen.window.

But replacing 120 with that doesn't work, starting with local jT = ... doesn't help either.

Any suggestions?

 

Hi @ErnstH,

 

It is not possible to replace device ID's in scene header with HomeTable references. In scene header you have to keep ID numbers of the triggering devices and yes, you will have to edit header of all scenes that uses ID of device that changed its ID due to hard reconfiguration or exclusion/inclusion process. 

Link to comment
Share on other sites

  • Topic Author
  • HI @ErnstH

    Sorry for the late reply

     

    The hometable references need to be exact and ARE case sensitive. It has zero flexibility.

    I have seen an Error referenced at line 334 that is really an issue like the one above


    Sometimes the exception notification for the HC2 is sometimes a bit off a doesn't always flag the correct line.

    Line 74 in a scene almost always points to an issue with a global; variable (empty, nill or does not exist)

     

    I have also seen Errors referencing getselfId in a scene that is flagging a syntax error 

    There is a post here that talks to his - 

    Link to comment
    Share on other sites

    • 1 month later...

    Please login or register to see this code.

    Hello
    Have once again a question.
    I know the what I have shown below did not work, but how can I read the value from the json list.

    How can I sit down please can give me an example?

     

    Many Thanks.

     

    Edited by parip69
    Link to comment
    Share on other sites

    • 2 months later...

    hi @AutoFrank,

    thanks for another awesome tutorial!

    I started playing around with it today. Everything works as expected.

     

    I wanted a more readable output of the HomeTable in the Debug window.

    So I found a LUA script in the internet and adapted it for Fibaro Debug.

    Please login or register to see this attachment.

     

    For this screenshot I used a simple nested hometable:

    Please login or register to see this code.

    I have a standard function to write to the debug window which i use in every scene:

    Please login or register to see this code.

    The function for the output of the HomeTable in JSON Format is:

    Please login or register to see this code.

    To output the Json you can now use:

    Please login or register to see this code.

    maybe someone finds this usefull as well.

     

    keep up the goood work.

    kro

     

     

     

    Edited by kroeatschge
    Link to comment
    Share on other sites

    • 2 months later...

    Hi all,

     

    on the weekend I found some time and worked through the tut, and everything is really working great from the beginning.

    However, I found one thing that I could not figure out. There are iOS devices missing in my Table, but I do not have a clue why?

    I checked

    Please login or register to see this link.

     and all my devices are listed there...

     

    Hints?

    Cheers

    joystick

    Edited by Joystick
    Link to comment
    Share on other sites

    • 3 months later...

    Hi,

     

    not sure if this is mentioned elsewhere, so just in case.... there is no need to manually add scenes and users, as suggested in the script on page 1.

     

    - Scenes can be added automatically with this snippet:

    Please login or register to see this code.

    - There is actually a type for users. Just add this to the main for-do-block:

    Please login or register to see this code.

    Cheers,

    jayrock

    Link to comment
    Share on other sites

    • 1 month later...

    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.

    ".

    Link to comment
    Share on other sites

    this code create and complete HomeTable variable if not exit or update it if exit, adding all users, scenes, devices, VD and iOS.
     

    Please login or register to see this code.

      

    Link to comment
    Share on other sites

    • 5 weeks later...

    I'm getting the following error when running the below test Scene to to display some values extracted from my Home Table: 

    Please login or register to see this image.

    /monthly_2018_05/image.png.ab3b0c68de439fd624b4ad5757167e93.png" alt="image.png.ab3b0c68de439fd624b4ad5757167e93.png" />

     

    Please login or register to see this code.

     

    Herewith the data from my Home Table:

    Please login or register to see this code.

     

    I'm clearly missing something, but cannot find the problem. Any suggestions?

     

    Thank you,

    Link to comment
    Share on other sites

    @nicopretYou have spelt user name differently  or with a capital or user does not exist in system.

    Scene can't find jT.users.resia in HomeTable

     

    Edited by Jamie mccrostie
    Link to comment
    Share on other sites

    Spelling and case is correct and user is in HomeTable. See debug output which pints contents of entire HomeTable. Below the relevant section.

    Please login or register to see this code.

    Herewith the top section of my HomeTable:

    Please login or register to see this code.

    I get the same problem for all users and also the scenes
     

    Edited by nicopret
    Link to comment
    Share on other sites

    Try 

    Please login or register to see this code.

    instead of:

      local user = fibaro:getValue(jT.users.resia, "value")

     

     

    Link to comment
    Share on other sites

    Thank you @

    Please login or register to see this link.

     that solved it. The same format should be used for Scenes, Users, iOS and VD, i.e. basically anything other than physical devices. Below a small test scene that helped me to test that I retrieve the correct values from my HomeTable

    Please login or register to see this code.

     

    Edited by nicopret
    Link to comment
    Share on other sites

    • 2 months later...

    hi,

    i read this topic more then 3 hours tried every code here ...

    can anyone please post final version of this code ( with sence, user....) 

    also can anyone post a code for plot - if i want to see the table and everything in it

     

    thanks a lot of your help  

    Link to comment
    Share on other sites

    • 1 month later...

    hi all,

     

    I am using Homtable for some time now and its working as it should except one thing:

    I have never managed to get the iOS devices working in my code. When I try to reference my device with "jT.iOS.MyDeviceName" I always get the error "

    [DEBUG] 12:18:18: [1;31m2018-09-23 12:18:18.002027 [ fatal] Unknown exception: /opt/fibaro/FibaroSceneAPI.lua:115: attempt to concatenate local 'deviceId' (a nil value)

     

    However, the device shows correctly in the log etc...

    The spelling is correct, I also tried to change the "special characters"  code in the HomeTable code, however I always get this.

     

    Can someone help me here?

     

    cheers

     

    Link to comment
    Share on other sites

    • 1 month later...
    Guest andyhud

    Great tutorial @AutoFrankand others.. so many different versions reading through all 6 pages! :)

     

    I have it working, basic, but working but couple of questions on the Scene itself

     

    1. It has "%% autostart" at the top, so should the Scene be set to "Manual" in the General Tab?

    2. Should the number of Max. Running Instances be set to 1 or leave on Default as 2?

    3. How often should the Table be generated in people's opinion? I was thinking to add the Scene to be scheduled by @Sankotronic's Scene for Time Based Events to run once a day (say 2:00am each morning)

    4. Could you somehow take the output in "Pretty Json" format and have it emailed to you each time it ran, maybe by @AutoFrank's Smart Message Hub 1.2?

     

    Cheers

     

    Andy

     

     

    Edited by andyhud
    Link to comment
    Share on other sites

    18 hours ago, andyhud said:

    1. It has "%% autostart" at the top, so should the Scene be set to "Manual" in the General Tab?

    2. Should the number of Max. Running Instances be set to 1 or leave on Default as 2?

    3. How often should the Table be generated in people's opinion? I was thinking to add the Scene to be scheduled by @Sankotronic's Scene for Time Based Events to run once a day (say 2:00am each morning)

    4. Could you somehow take the output in "Pretty Json" format and have it emailed to you each time it ran, maybe by @AutoFrank's Smart Message Hub 1.2?

     

    Hi @andyhud ,

     

    1. Scene should be set to "Automatic"
    2. Default setting for instances is OK
    3. Table should be generated only if some changes where made with devices (added, deleted or reconfigured), best time is after reboot.
    4. That is possible to achieve, but why you need that?

     

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