This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Local bus and sending to MQtt
#3
Thanks, this is making sense,  i will run a function when the script starts to cache the objects in a table as described how am i best to achieve this?
my first thoughts,
call group.all() then loop through tagcache and validate the tag with prefix 'MQ' is there, then extract all elements as reqired and insert into cached obj table 
or  maybe i can use  myobjects = grp.tag({'tag name 1', 'tag name 2'}, 'any')  problem is for this one i dont want to list all the avalible tagsas i may have many different ones the only consistant thing in the tag is the 'MQ' prefix

whats the simplist way to recieve all tags with  the 'MQ' prefix or perhaps i should change my naming method to better.

this is wher i am at so far, thoughts?  then i can look up the table with th eabove function.
Code:
local cached_objects = {}

all_obj = grp.all()

for _, obj in pairs(all_obj) do
    local tag_is_MQ

    if obj.tagcache then
        tag_is_MQ = obj.tagcache:match('(MQ%s+[^,]+)')                    
    end
 
    if tag_is_MQ then

      cached_objects[obj.address] = {['address'] =obj.address, ['name'] = obj.name, ['data type'] = obj.datatype, ['tag'] = tag_is_MQ, ['updatetime'] = obj.updatetime}

    end
end

log(cached_objects)
Reply


Messages In This Thread
RE: Local bus and sending to MQtt - by admin - 03.01.2024, 07:31
RE: Local bus and sending to MQtt - by benanderson_475 - 03.01.2024, 10:53
RE: Local bus and sending to MQtt - by admin - 03.01.2024, 10:57
RE: Local bus and sending to MQtt - by admin - 03.01.2024, 11:13

Forum Jump: