NAC - Using Custom Level Tags

Discussion in 'C-Bus Automation Controllers' started by sjfp, Jan 13, 2026.

  1. sjfp

    sjfp

    Joined:
    Oct 31, 2004
    Messages:
    149
    Likes Received:
    1
    Location:
    UK
    I look for a method to use the Custom Level Tags rather than the actual object level.
    We are using an MQTT to send messages.
    But need to send on or off rather than 255 or 0. we could use
    if value == 1 or value == 255 then
    send_val = "on"
    elseif value == 0 then
    send_val = "off"
    end

    But also want to be able to send dimming command so still need the 0-255 as a value.
    Thought if using the Custom level Tag we could mark object we want with Custom Levels Tags 0=off and 255=on and if there is no Custom Level Tag we can simply use the object value.

    Any suggestions would be gratefully appreciated
     
    sjfp, Jan 13, 2026
    #1
  2. sjfp

    Pie Boy

    Joined:
    Nov 21, 2012
    Messages:
    255
    Likes Received:
    31
    Location:
    New Zealand
    Can you explain a bit more, do you mean when value is 0, it would send only “OFF” or 0 as well, initially I’m thinking you can’t combine the off and on and also have the 0-255. do you mean the sent message range would be “OFF 1….254 ON” ? Is this an obj to one MQTT topic, or could you possibly have 2 topics one for the on/off state and one for the dinning level?
     
    Pie Boy, Jan 13, 2026
    #2
  3. sjfp

    sjfp

    Joined:
    Oct 31, 2004
    Messages:
    149
    Likes Received:
    1
    Location:
    UK
    for example
    object 0/56/93 has custom level tags set with 0=off and 255=on
    object 0/56/94 has NO custom level tags set.

    if 0/56/93 is triggered by vis or wall switch to 255 then mqtt payload would be "on" if switch is toggled to 0 then payload would be "off"
    if 0/56/94 is set by a slider to a certain level like 127 then the payload would be 127 because there is NO custom level tags set
     
    sjfp, Jan 13, 2026
    #3
  4. sjfp

    Pie Boy

    Joined:
    Nov 21, 2012
    Messages:
    255
    Likes Received:
    31
    Location:
    New Zealand
    Ahh I see so you want the custom tag to be the payload and if there’s no tag to send the value?
    You would probably need to use a db:() function for that…
     
    Last edited: Jan 13, 2026
    Pie Boy, Jan 13, 2026
    #4
  5. sjfp

    sjfp

    Joined:
    Oct 31, 2004
    Messages:
    149
    Likes Received:
    1
    Location:
    UK
    Has anyone got info, where custom level tags are located in the db, browsed the database, but have seen where they are or how they are associated with the object name.
     
    sjfp, Jan 19, 2026
    #5
  6. sjfp

    Pie Boy

    Joined:
    Nov 21, 2012
    Messages:
    255
    Likes Received:
    31
    Location:
    New Zealand
    Something like this might get you close, I would suggest it would be a grand idea to always take a backup before fiddling the database…


    local json = require('json')


    -- Example: get objects (use grp.find if you already have an address/name)

    local objs = grp.tag('my_tag_name')


    for _, obj in ipairs(objs) do

    -- enums contains the UI "custom values" mapping

    local enums_json = db:getone('SELECT enums FROM objects WHERE id=?', obj.id)


    if enums_json and enums_json ~= '' then

    local enums = json.decode(enums_json)

    log(enums) -- inspect structure


    -- then decide what to publish:

    -- if you want "custom text for current value", you match obj.value to enums entries

    else

    -- no custom values set -> fall back to raw value

    log('No enums for object id', obj.id, 'value=', obj.value)

    end

    end
     
    Pie Boy, Jan 19, 2026
    #6
  7. sjfp

    sjfp

    Joined:
    Oct 31, 2004
    Messages:
    149
    Likes Received:
    1
    Location:
    UK
    Thanks for your help, I will have a look at this further, in the mean time I have used Keyword Tag ("tagcache")
    as the filter.
     
    sjfp, Jan 21, 2026
    #7
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.