Add tag from script

Discussion in 'C-Bus Automation Controllers' started by Diggerz, Aug 7, 2025 at 11:47 AM.

  1. Diggerz

    Diggerz

    Joined:
    Jan 24, 2017
    Messages:
    75
    Likes Received:
    12
    Location:
    Australia, Vic, Melbourne
    Does anyone know how to add a tag to the tag map via script?

    A group can be created using grp.create() but Im finding the name doesn’t appear in the objects list, it ends up getting the group address number.

    the name seems to be taken from the tag map.

    I can call cbuslib and use cbuslib.Addtag() but it doesn’t seem to be passing the name correctly addtag takes 6 arguments where the second should be the name.
     
    Diggerz, Aug 7, 2025 at 11:47 AM
    #1
  2. Diggerz

    Weedo

    Joined:
    Mar 21, 2011
    Messages:
    38
    Likes Received:
    3
    Location:
    Toowoomba
    Hi Diggerz,

    Its been a while since I played with this function however I vaguely recall a cache clear was required to see the tag map update after running the script.
    If that doesn't work I can see if I can dig out my user function and see how I was actioning.

    BLW
     
    Weedo, Aug 8, 2025 at 4:40 AM
    #2
  3. Diggerz

    lcrowhurst

    Joined:
    Dec 2, 2004
    Messages:
    286
    Likes Received:
    100
    Location:
    Sydney, NSW, Australia
    function insertCbusTag(mytagid,mytagtype,mytag,mynet,myapp,mygrp,mysubgrp)
    res, err = db:insert('cbus_tag_map', {
    tagid = mytagid,
    tagtype = mytagtype,
    tag = mytag,
    net = mynet,
    app = myapp,
    grp = mygrp,
    subgrp = mysubgrp
    })
    end

    INFO

    mytagtype N = Network eg 0, A = Application, G = Group.,L = Level
    mytag = name
    mytagid = 0 if mytagtype = N
    mytagid = 56 if mytagtype = A

    To add a Cbus group in Lighting

    insertCbusTag(66,"G","Kitchen Lights",0,56,,)
     
    lcrowhurst, Aug 8, 2025 at 7:02 AM
    #3
  4. Diggerz

    SgrAystar

    Joined:
    Oct 4, 2018
    Messages:
    66
    Likes Received:
    5
    Location:
    Melbourne, Australia
    You could also now use webrequest?

    Code:
    webrequest = require('webrequest')
    
    data = {
      tagtype = 'L',
      net = 0,
      app = 56,
      objectType = '',
      grp = 8,
      tagid = 2,
      tag = 'LevelTwo',
      id = 0
    }
    
    res, err = webrequest('cbustagmap', 'save', { data = data })
    log(res, err)
     
    Last edited: Aug 8, 2025 at 8:19 AM
    SgrAystar, Aug 8, 2025 at 8:03 AM
    #4
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.