Page 1 of 1
My very first Dzventz "script" please help
Posted: Tuesday 05 June 2018 16:29
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
}
Re: My very first Dzventz "script" please help
Posted: Tuesday 05 June 2018 18:25
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
}
Re: My very first Dzventz "script" please help
Posted: Tuesday 05 June 2018 18:55
by bozidar
thx very appreciated.
But there seems to be a litle bug in it.
Light turn on 2 sec and then turns of.
Re: My very first Dzventz "script" please help
Posted: Tuesday 05 June 2018 19:11
by bozidar
Hold on.
I believe that nothing is wrong with you script.
Re: My very first Dzventz "script" please help
Posted: Tuesday 05 June 2018 20:54
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 ?
Re: My very first Dzventz "script" please help
Posted: Tuesday 05 June 2018 22:43
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
}
Re: My very first Dzventz "script" please help
Posted: Wednesday 06 June 2018 9:27
by McMelloW
Perhaps this video might be some help
viewtopic.php?f=59&t=18143
Re: My very first Dzventz "script" please help
Posted: Wednesday 06 June 2018 17:58
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.
Re: My very first Dzventz "script" please help
Posted: Wednesday 06 June 2018 20:28
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
Re: My very first Dzventz "script" please help
Posted: Wednesday 06 June 2018 22:55
by waaren
syntax is domoticz.groups ; You forgot the s
Re: My very first Dzventz "script" please help
Posted: Thursday 07 June 2018 16:59
by bozidar
Exelent
thank you Waaren. Help is really much apreciated.