My very first Dzventz "script" please help

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

Moderator: leecollings

Post Reply
bozidar
Posts: 19
Joined: Saturday 09 September 2017 16:17
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

My very first Dzventz "script" please help

Post by bozidar »

Hi all

I am trying to make a very simple "script"

I want a specific wallswitch to turn on/off a light.

1436 is wallswitch idx and 1424 is light idx.

What have i done wrong ?

return {
on = {
devices = {
'1436'
}
},
execute = function(domoticz,'1424')
local Living room = domoticz.devices('1424')
domoticz.ToggleSwitch ()
end

end
}
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: My very first Dzventz "script" please help

Post by waaren »

Something with quotes and syntax. Try it like this

Code: Select all

--[[ toggler.lua
]]--

return { 
    on = { devices = { 1436 }},                          -- Trigger = Switch device IDX 

    execute = function(domoticz,trigger)
        local livingRoom = domoticz.devices(1424)       -- Light IDX
        livingRoom.toggleSwitch()
    end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
bozidar
Posts: 19
Joined: Saturday 09 September 2017 16:17
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: My very first Dzventz "script" please help

Post by bozidar »

thx very appreciated.

But there seems to be a litle bug in it.

Light turn on 2 sec and then turns of.
bozidar
Posts: 19
Joined: Saturday 09 September 2017 16:17
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: My very first Dzventz "script" please help

Post by bozidar »

Hold on.
I believe that nothing is wrong with you script.
bozidar
Posts: 19
Joined: Saturday 09 September 2017 16:17
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: My very first Dzventz "script" please help

Post by bozidar »

Thx again waaren

But realized that my actual lightswitch is not a on/off switch.

It is a "digital switch" sending a ON signal when pressed ,and is in "off" state when not pressed.
which makes using the toggle function a bad idea.

So i guess it needs to be done in a complete different way.

Any ideas ?
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: My very first Dzventz "script" please help

Post by waaren »

bozidar wrote: Tuesday 05 June 2018 20:54 Realized that my actual lightswitch is not a on/off switch.
It is a "digital switch" sending a ON signal when pressed ,and is in "off" state when not pressed.
So i guess it needs to be done in a complete different way.
Not a COMPLETE different way. Just a check on the state of the "trigger state" should do it.

Code: Select all

--[[ Toggler.lua
]]--

return { 
    on = { devices = {  1436  }},                          -- Trigger = Switch device IDX 
    
    logging =   {   level     =   domoticz.LOG_DEBUG,
                    marker    =   "Toggler" },
    
    execute = function(domoticz,trigger)
        local livingRoom = domoticz.devices(1424)       -- Light IDX

        if trigger.state == "On" then
            livingRoom.toggleSwitch()
        end 
        
        domoticz.log("Trigger state ==>> " .. trigger.state .. "; Light state ==>> " .. livingRoom.state ,domoticz.LOG_DEBUG)
    end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
McMelloW
Posts: 434
Joined: Monday 20 November 2017 17:01
Target OS: Raspberry Pi / ODroid
Domoticz version: V2024.1
Location: Harderwijk, NL
Contact:

Re: My very first Dzventz "script" please help

Post by McMelloW »

Perhaps this video might be some help
viewtopic.php?f=59&t=18143
Greetings McMelloW
bozidar
Posts: 19
Joined: Saturday 09 September 2017 16:17
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: My very first Dzventz "script" please help

Post by bozidar »

Thank you Mcmellow

Belive it or not ,but have seen that video at least 5 times.and read the manual ..

But with no coding experience ,and limited Domoticz skilled ,the first steps are just so much harder.

I have learned so much over the last year ,but are also spending much more time than ,the more experience person.

But thx for the help and hints...

Moving forward ,but very slowly.
bozidar
Posts: 19
Joined: Saturday 09 September 2017 16:17
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: My very first Dzventz "script" please help

Post by bozidar »

hi again

Shouldn't this work then : just turning on a gruop of lights instead of 1 light.

--[[ Toggler.lua
]]--

return {
on = { devices = { 1439 }}, -- Trigger = Switch device IDX

logging = { level = domoticz.LOG_DEBUG,
marker = "Toggler" },

execute = function(domoticz,trigger)
local livingRoom = domoticz.group(1) -- Light IDX

if trigger.state == "On" then
livingRoom.toggleGroup()
end

domoticz.log("Trigger state ==>> " .. trigger.state .. "; Light state ==>> " .. livingRoom.state ,domoticz.LOG_DEBUG)
end
}

Hopefully last ??

Thxalot for the help
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: My very first Dzventz "script" please help

Post by waaren »

syntax is domoticz.groups ; You forgot the s
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
bozidar
Posts: 19
Joined: Saturday 09 September 2017 16:17
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: My very first Dzventz "script" please help

Post by bozidar »

Exelent
thank you Waaren. Help is really much apreciated.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest