Get User Object Name via Script

Discussion in 'C-Bus Automation Controllers' started by sjfp, Apr 25, 2022.

  1. sjfp

    sjfp

    Joined:
    Oct 31, 2004
    Messages:
    145
    Likes Received:
    1
    Location:
    UK
    Looking how to get the object name from a user parameter, was looking at something like.
    get_event_data = grp.find(event.dst)
    if get_event_data.value > 50 then
    alert("The temperature level in room " .. get_event_data.name .. " is too high: " .. get_event_data.value)
    end
    now the get_event_data.value works fine, but there is no name field in table brought back from grp.find(event.dst)

    Any advise on how to get the name.
     
    sjfp, Apr 25, 2022
    #1
  2. sjfp

    Pie Boy

    Joined:
    Nov 21, 2012
    Messages:
    249
    Likes Received:
    31
    Location:
    New Zealand
    Yeah it’s stupid aye….
    the cbus tag map is disassociated from the object name, you would think that this would not be the case but it is…

    objects and cbus tag is 2 different things internally in the database,

    I am unsure on what condition any name is written to the object name parameter, i have had various different things happen across a number on nac installs… so terribly inconsistent results.
    this is my work around, to manually write the name to
    The object database, use at your own risk and definitely take a backup before fiddling the database…

    id = CBusGetLightingID(0, 250, 50)

    db:update('objects', { name = 'Dining light' }, { id = id })

    I think you could also use
    grptag = GetCBusGroupTag(0, 250, 2)
    log(grptag)

    not as elegant as having one Lua call return all data from the function though…

    but ultimately the ga tag name and the object name should have the same value...
     
    Last edited: Apr 26, 2022
    Pie Boy, Apr 26, 2022
    #2
    Damaxx likes this.
  3. sjfp

    sjfp

    Joined:
    Oct 31, 2004
    Messages:
    145
    Likes Received:
    1
    Location:
    UK
    many thanks, will give it a try tomorrow.
     
    sjfp, Apr 26, 2022
    #3
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.