make one script from two scripts  [Solved]

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

Moderator: leecollings

Post Reply
PatrickDV
Posts: 4
Joined: Sunday 05 July 2020 21:15
Target OS: OS X
Domoticz version:
Contact:

make one script from two scripts

Post 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
Attachments
Schermafbeelding 2020-07-05 om 21.18.52.png
Schermafbeelding 2020-07-05 om 21.18.52.png (30.08 KiB) Viewed 754 times
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: make one script from two scripts

Post 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
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
PatrickDV
Posts: 4
Joined: Sunday 05 July 2020 21:15
Target OS: OS X
Domoticz version:
Contact:

Re: make one script from two scripts  [Solved]

Post 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
}
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest