Jump to content
Guides for the Forum Read more... ×
Poradniki na Forum Read more... ×
AutoFrank

Tutorial - Using a Hometable to store device and scene ID's

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)

Share this post


Link to post
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?

Share this post


Link to post
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. 

Share this post


Link to post
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 - 

    Share this post


    Link to post
    Share on other sites

    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

    Share this post


    Link to post
    Share on other sites

    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

    Share this post


    Link to post
    Share on other sites

    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

    Share this post


    Link to post
    Share on other sites

    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

    Share this post


    Link to post
    Share on other sites

    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.

    ".

    Share this post


    Link to post
    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.

      

    Share this post


    Link to post
    Share on other sites

    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,

    Share this post


    Link to post
    Share on other sites
    Posted (edited)

    @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

    Share this post


    Link to post
    Share on other sites
    Posted (edited)

    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

    Share this post


    Link to post
    Share on other sites
    Posted (edited)

    Ive had those errors before and they were caused by a typo.

    Edited by Jamie mccrostie

    Share this post


    Link to post
    Share on other sites

    Try 

    Please login or register to see this code.

    instead of:

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

     

     

    Share this post


    Link to post
    Share on other sites
    Posted (edited)

    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

    Share this post


    Link to post
    Share on other sites

    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  

    Share this post


    Link to post
    Share on other sites

    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

     

    Share this post


    Link to post
    Share on other sites

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now

    ×