Use a wildcard search on altid to only pull back required devices

Hi

The DSC plugin adds a ‘zone’ value to the altid variable in Vera e.g ‘zone-3’ , ‘zone-11’ etc. I’ve been looking at various guides but have not been able to successfully limit the results.

Does anyone know how I can only select those devices that have ‘zone’ in the altid field?

Doing it by d-category works, but that returns quite a few more, yet I only want the dsc ones.

local tt = {}
for n,d in pairs(luup.devices) do
if d.category_num == 4 then

But when I try to do a wildcard it finds nothing…

local tt = {}
for n,d in pairs(luup.devices) do
if d.altid = string.match(d.altid, 'Zone.*’) then

Any ideas ?

The field names aren’t consistent in luup.devices with the attribute names. You need to use d.id in your code for the altid attribute.

Your test is then simply if d.id:lower():match( "^zone%-" ) then ...

Note that the - is escaped with a % before, because - is a special character to Lua patterns and will mean something else if you don’t escape it.

Thanks @rigpapa !!