I am trying to develop a script in which when the switchSelector ('On') is "Campainha", then the alarm sounds in the melody, etc! But the problem is that the Script does not put the switchSelector ('Off') and stop the alarm! The script is always looped!
There is some other simpler method to do, I've tried it in many ways, but I'm not able to stop the script loop! In the log does not give errors.
Nefsolive wrote: Thursday 18 February 2021 17:08
I am trying to develop a script in which when the switchSelector ('On') is "Campainha", then the alarm sounds in the melody, etc! But the problem is that the Script does not put the switchSelector ('Off') and stop the alarm! The script is always looped!
There is some other simpler method to do, I've tried it in many ways, but I'm not able to stop the script loop! In the log does not give errors.
Nefsolive wrote: Thursday 18 February 2021 17:08
I am trying to develop a script in which when the switchSelector ('On') is "Campainha", then the alarm sounds in the melody, etc! But the problem is that the Script does not put the switchSelector ('Off') and stop the alarm! The script is always looped!
There is some other simpler method to do, I've tried it in many ways, but I'm not able to stop the script loop! In the log does not give errors.
return {
on = {
devices = {'Campainha', 'Alarme',}
},
logging = {
level = domoticz.LOG_DEBUG,
marker = 'Toca Campainha',
},
execute = function(dz)
if dz.devices('Campainha').switchSelector('On') then
dz.devices('Alarme Volume').dimTo(0)
dz.devices('Alarme Melodia').dimTo(20)
dz.devices('Alarme').switchOn().silent()
dz.devices('Alarme').switchOff().aftersec(5).silent()
elseif dz.devices('Alarme').state == 'Off' then
dz.devices('Campainha').dimTo(0).silent()
end
end
}
Hello waaren,
Thanks for reply.
I try with .silent(), and still looping, "dz.devices('Campainha').switchSelector('On')", and just take me off the selector on switches page, wen i put Off the script!
Iff i dont take Off the script, is always loop On!
Strange!
Nefsolive wrote: Thursday 18 February 2021 17:42
I try with .silent(), and still looping, "dz.devices('Campainha').switchSelector('On')", and just take me off the selector on switches page, wen i put Off the script!
You are using switchSelector in an if statement but switchSelector is an action and not a state.
Please try again with below version and include the log if it does not work as expected.
Nefsolive wrote: Thursday 18 February 2021 17:42
I try with .silent(), and still looping, "dz.devices('Campainha').switchSelector('On')", and just take me off the selector on switches page, wen i put Off the script!
You are using switchSelector in an if statement but switchSelector is an action and not a state.
Please try again with below version and include the log if it does not work as expected.
Nefsolive wrote: Thursday 18 February 2021 19:07
2021-02-18 18:03:31.425 Error: dzVents: Error: (3.0.2) Toca Campainha: ...domoticz/scripts/dzVents/generated_scripts/Script #1.lua:17: attempt to call a nil value (field 'aftersec')[/code]
aftersec does not exist.
the method is afterSec
Yes! You right my mistake! passed me.
Now no error on log!
i Take out the lines "elseif dz.devices('Alarme').state == 'Off'" and "dz.devices('Alarme').switchOff().afterSec(5).silent()", and now works great!