Adding LUA library to SHAC/NAC

Discussion in 'C-Bus Automation Controllers' started by Damaxx, Apr 4, 2019.

  1. Damaxx

    pspeirs

    Joined:
    Nov 23, 2013
    Messages:
    185
    Likes Received:
    10
    Location:
    Sydney
    Ummm, embarrasing as I realized current is spelt with 2 R's not 1 . . . So all good.

    I've used that function many time, actually forgot it wasn't inbuilt :)
    I wrote it for some reason, at the time I think it was because I didn't think the "GetCBusByKW" worked on UserParams.

    Code:
    function SetObjectByTag(tagname, value)
    
        if (GetObjectByTag(tagname).data[1].value ~= value) then
           
            -- Save Object By Tagname
            obj = grp.tag(tagname)
       
            if (table.maxn(obj) == 0) then
                log(string.format('Could not set tagname: %s to value: %s', tagname, value))
            end
       
            obj:write(value)
       
            return 0
       
        else
           
            return 0
        end
       
    end
    
     
    pspeirs, Oct 8, 2021
    #21
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.