Page 1 of 1

make one script from two scripts

Posted: Sunday 05 July 2020 21:27
by PatrickDV
Hello,

I have two Qubino smart dimmers, type ZMNHDD1
This is connected to an double pulse Botton
How it works is when I pushed the second button, there will be an defined group switch on
when I pushed again it switch off.

To let this work I have one dzVents script and one Blockley.

the first script is an toggle script to switch on and off an dummy switch
The second is an blocky that when de dummy switch is on the group wil go on.

It would be nice to get one script that can switch on and off an group.

I tried something, but it won't work.

see the script en blocky below.

I hope someone can help me with this.

Code: Select all

return {
    on = { 
        devices = { 3722, 3736 }
        },
    
    execute = function(dz, item)
        if item.active then
	    dz.devices('DM Thuiskomen').toggleSwitch()
        end
    end
}/code]

[attachment=0]Schermafbeelding 2020-07-05 om 21.18.52.png[/attachment]

Beste regards,

Patrick

Re: make one script from two scripts

Posted: Sunday 05 July 2020 22:44
by waaren
PatrickDV wrote: Sunday 05 July 2020 21:27 It would be nice to get one script that can switch on and off an group.
can you try this?

Code: Select all

return
{
    on =
    {
        devices = { 3722, 3736 },
    },

    execute = function(dz, item)

        if item.active then

            thuiskomDevice = dz.devices('DM Thuiskomen')
            thuiskomGroup = dz.groups('Thuiskomen')

            if thuiskomDevice.state == 'On' then
                thuiskomGroup.switchOff()
            else
                thuiskomGroup.switchOn()
            end
            thuiskomDevice.toggleSwitch()
        end
    end
}

Re: make one script from two scripts  [Solved]

Posted: Monday 06 July 2020 19:10
by PatrickDV
Hello Waaren,

it is working, I changed it a little bit so I can remove the dummy switch DM Thuiskomen
Thanks for the help!

Code: Select all

return
{
    on =
    {
        devices = { 3722, 3736 },
    },

    execute = function(dz, item)

        if item.active then

            thuiskomGroup = dz.groups('Thuiskomen')

            if thuiskomGroup.state == 'On' then
                thuiskomGroup.switchOff()
            else
                thuiskomGroup.switchOn()
            end
            thuiskomGroup.toggleSwitch()
        end
    end
}