Page 1 of 1

DzVents hide/unhide method request

Posted: Wednesday 18 December 2019 12:22
by funnybu
It will be very useful for me to have hide/unhide method for deices in dzVents.

For example: if i turn off my heating system (by dummy switch), i want hide my boiler devices, pumps, boiler temp and pressure control, etc from control panel. And when i switch it on - unhide.

I can do it now via string parsing and $ symbol, but it is a lot of code.

Re: DzVents hide/unhide method request  [Solved]

Posted: Wednesday 18 December 2019 17:08
by waaren
funnybu wrote: Wednesday 18 December 2019 12:22 It will be very useful for me to have hide/unhide method for deices in dzVents.
You can do this by adding all heating related devices to group heating and use this script.

Code: Select all

return 
{
    on =
    {
        devices = { "dummy switch" },    
    },

    logging =
    {   
        level = domoticz.LOG_DEBUG,  -- set to Error when script executes without problems
    },

    execute = function(dz,item)
        _G.logMarker =  _G.moduleLabel
        heatingGroup = dz.groups('heating')

        local function hideGroupDevices(group)
            group.devices().forEach(function(dv)
                if dv.name:sub(1,1) ~= '$' then
                    dv.rename('$' .. dv.name)  -- rename method available in dzVents >= 2.4.24 (domoticz >= V4.10927)
                end
            end)
        end

        local function unHideGroupDevices(group)
            group.devices().forEach(function(dv)
                if dv.name:sub(1,1) == '$' then
                    dv.rename(dv.name:sub(2))
                end
            end)
        
        end

        if item.active then 
            unHideGroupDevices(heatingGroup)
        else
            hideGroupDevices(heatingGroup)
        end
    end
}