DzVents hide/unhide method request  [Solved]

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
funnybu
Posts: 10
Joined: Monday 07 May 2018 14:48
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.9272
Location: Russia, Novosibirsk
Contact:

DzVents hide/unhide method request

Post 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.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: DzVents hide/unhide method request  [Solved]

Post 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
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest