I need a script to turn on a solenoid valve to water some decorative plants, for 1 hour, 2 times/week, from April 1st to November 1st. I keep trying with AI but without success. can someone help me ?
return {
on = {
timer = {
'at 10:00 on Mon,Thu in April-September'
}
},
execute = function(domoticz, device)
-- Verificați dacă este între 1 aprilie și 20 septembrie
local currentDate = domoticz.time
if (currentDate.month == 4 and currentDate.day < 1) or
(currentDate.month == 9 and currentDate.day > 20) or
(currentDate.month < 4 or currentDate.month > 9) then
return
end
-- Verificați dacă este luni sau joi
if currentDate.dayOfWeek == domoticz.Sunday or currentDate.dayOfWeek == domoticz.Wednesday then
-- Verificați dacă este ora 10:00 dimineața
if currentDate.hour == 10 and currentDate.min == 0 then
-- Porniți dispozitivul cu ID-ul 47
domoticz.devices[47].switchOn()
-- Oprește dispozitivul după 1 oră (3600 secunde)
domoticz.devices[47].switchOff().afterSec(3600)
end
end
end
}
return {
on = {
timer = {
'at 10:00 on Mon,Thu on 3/1-10/31'
}
},
execute = function(domoticz, device)
-- Start the device with ID 47 for 3600 seconds
domoticz.devices[47].switchOn().forSec(3600)
end
}
return {
on = {
timer = {
'at 10:00 on Wed,Thu on 1/3-31/10'
}
},
execute = function(domoticz, device)
-- Porniți dispozitivul cu ID-ul 47 pentru 3600 de secunde (o oră)
domoticz.devices[47].switchOn().forSec(3600)
end
}
It should work, perhaps add a log statement to be sure.
Also make sure you have some time left (min 2 minutes) to have Domoticz setup the triggers. So save the script latest at 9:58 to have th trigger action on 10:00.
return {
on = {
timer = {
'at 21:58 on Sat,Thu on 1/4-31/10'
}
},
execute = function(domoticz, device)
-- Start the device with ID 47 for 3600 seconds
print("test 2")
end
}
I have no idea
I simply want to be able to turn on a switch twice a week between April 1st and October 1st.
only the starting part interests me, the time does not matter, etc
return {
on = {
timer = {
'every minute on Tue,Sat,Thu on 1/4-31/10'
}
},
execute = function(domoticz, device)
-- Start the device with ID 47 for 3600 seconds
print("test 2")
end
}
Every minute now the text "test 2' should be printed in the log.
Is that working? If not are other scripts working?
Logic will get you from A to B. Imagination will take you everywhere.
ssk17051980 wrote: ↑Tuesday 09 April 2024 10:05
Out of ideea.
I have no idea
I simply want to be able to turn on a switch twice a week between April 1st and October 1st.
only the starting part interests me, the time does not matter, etc
You still are not explaining "What" is not working ! Just telling us that it isn't working doesn't tell us much!
Help us to help you. The simple example I gave should show a message in the domoticz log when the condition is met. Did you try that and what was the result!
the swith that i want to control is not starting in the program. from april to november, 2 day/wek.
i try a lot of version whit chat gpt whit no luck.
this is the last try whit dzvents from chat gpt.
return {
on = {
timer = { 'daily' }
},
execute = function(dz)
local currentDate = os.date('*t')
local switchIdxToControl = 305
-- Verificăm dacă suntem în aprilie - octombrie și este una din zilele de miercuri sau vineri
if (currentDate.month >= 4 and currentDate.month <= 10) and (currentDate.wday == 3 or currentDate.wday == 5) then
dz.devices(switchIdxToControl).switchOn() -- Pornim switch-ul cu idx-ul 305
else
dz.devices(switchIdxToControl).switchOff() -- Oprim switch-ul cu idx-ul 305
end
end
}
important it's to start in that interval. the stop part it's easy whit blockly.
return {
on = {
timer = {
'every minute on Mon,Sat,Thu on 1/4-31/10'
}
},
execute = function(domoticz, device)
-- Start the device with ID 47 for 3600 seconds
domoticz.devices(47).switchOn().forSec(3600)
print("Device with idx 47 started for 3600 seconds")
end
}
Kedi wrote: ↑Monday 15 April 2024 14:52
I think you should change the timer part, because now the device is switched on for 1 hour every minut.
yes, you right =))
i see that after i start to test.
i did not find a solution until now.
AI is not so smart on dzvents =))). we are at the same level .