Christmas light by program
Moderator: leecollings
-
- Posts: 112
- Joined: Thursday 08 December 2022 22:15
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2023.2
- Location: ROMANIA
- Contact:
Christmas light by program
I keep trying to make a script even with the help of chat-open-ai, but without success.
my script must turn on a switch, with idx=x, in the period 01.12 - 05.01, for a period of 8 hours, IF another switch with idx=y, is ON.
it is about Christmas lights, and idx=y is a switch that is ON when the sun goes down.
Does anyone have something like this already done and working?
Thank you
my script must turn on a switch, with idx=x, in the period 01.12 - 05.01, for a period of 8 hours, IF another switch with idx=y, is ON.
it is about Christmas lights, and idx=y is a switch that is ON when the sun goes down.
Does anyone have something like this already done and working?
Thank you
-
- Posts: 650
- Joined: Saturday 21 September 2019 17:55
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024.1
- Location: The Netherlands
- Contact:
Re: Christmas light by program
Not sure if this timer works, please go ahead and test it.
Alternatively you just could use the "at sunrise" or "at sunset" trigger, then you don't need to check the y switch.
Alternatively you just could use the "at sunrise" or "at sunset" trigger, then you don't need to check the y switch.
Code: Select all
local idxSunDownSwitch=y
local idxLightsSwitch=x
return {
on = {
timer {
'every minute on 01/12-05/01',
}
},
logging = {
level = domoticz.LOG_INFO,
marker = 'christmas light',
},
execute = function(domoticz, timer)
domoticz.log('Timer event was triggered by ' .. timer.trigger, domoticz.LOG_INFO)
if domoticz.devices(idxSunDownSwitch).state=='ON' then
if domoticz.devices(idxLightsSwitch).state=='OFF' then
domoticz.devices(idxLightsSwitch).switchOn()
end
else
if domoticz.devices(idxLightsSwitch).state=='ON' then
domoticz.devices(idxLightsSwitch).switchOff()
end
end
end
}
- gizmocuz
- Posts: 2548
- Joined: Thursday 11 July 2013 18:59
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: Top of the world
- Contact:
Re: Christmas light by program
Indded, why not add a timer to your Cristmas light to go on 30 minutes before sunset ?
Quality outlives Quantity!
-
- Posts: 112
- Joined: Thursday 08 December 2022 22:15
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2023.2
- Location: ROMANIA
- Contact:
Re: Christmas light by program
gone testwillemd wrote: ↑Tuesday 02 January 2024 19:09 Not sure if this timer works, please go ahead and test it.
Alternatively you just could use the "at sunrise" or "at sunset" trigger, then you don't need to check the y switch.
Code: Select all
local idxSunDownSwitch=y local idxLightsSwitch=x return { on = { timer { 'every minute on 01/12-05/01', } }, logging = { level = domoticz.LOG_INFO, marker = 'christmas light', }, execute = function(domoticz, timer) domoticz.log('Timer event was triggered by ' .. timer.trigger, domoticz.LOG_INFO) if domoticz.devices(idxSunDownSwitch).state=='ON' then if domoticz.devices(idxLightsSwitch).state=='OFF' then domoticz.devices(idxLightsSwitch).switchOn() end else if domoticz.devices(idxLightsSwitch).state=='ON' then domoticz.devices(idxLightsSwitch).switchOff() end end end }

thx
-
- Posts: 112
- Joined: Thursday 08 December 2022 22:15
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2023.2
- Location: ROMANIA
- Contact:
-
- Posts: 650
- Joined: Saturday 21 September 2019 17:55
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024.1
- Location: The Netherlands
- Contact:
Re: Christmas light by program
Exactly, that's what he meant: go ON xx minutes before or after sunset, go OFF xx minutes before or after sunrise.
Reading the dzVents documentation will help
Reading the dzVents documentation will help
- waltervl
- Posts: 5859
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: Christmas light by program
You can do this with the normal timer function/button too, no need to program something.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
-
- Posts: 112
- Joined: Thursday 08 December 2022 22:15
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2023.2
- Location: ROMANIA
- Contact:
Re: Christmas light by program
Code: Select all
local idxSunDownSwitch = 267 --indicate the sunrise and sunset /apus (ON/OFF)
local idxLightsSwitch = 23 -- the switch that i want to control (ON/OFF)
return {
on = {
timer = {
'every minute on 12/01-01/05',
}
},
logging = {
level = domoticz.LOG_INFO,
marker = 'christmas light',
},
execute = function(domoticz, timer)
domoticz.log('Timer event was triggered by ' .. timer.trigger, domoticz.LOG_INFO)
local sunDownSwitch = domoticz.devices(idxSunDownSwitch)
local lightsSwitch = domoticz.devices(idxLightsSwitch)
if sunDownSwitch.state == 'ON' then
if lightsSwitch.state == 'OFF' then
lightsSwitch.switchOn()
end
else
if lightsSwitch.state == 'ON' then
lightsSwitch.switchOff()
end
end
end
}
-
- Posts: 650
- Joined: Saturday 21 September 2019 17:55
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024.1
- Location: The Netherlands
- Contact:
Re: Christmas light by program
If you want help you need to provide some more feedback and info.
I tested the timer trigger and see my script is launched every minute, so that is not the problem.
Is yours launched as well? Is it activated?
Any error messages?
Any info in the log file?
Did you add debug info so that it is shown in the logfile?
I tested the timer trigger and see my script is launched every minute, so that is not the problem.
Is yours launched as well? Is it activated?
Any error messages?
Any info in the log file?
Did you add debug info so that it is shown in the logfile?
-
- Posts: 112
- Joined: Thursday 08 December 2022 22:15
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2023.2
- Location: ROMANIA
- Contact:
Re: Christmas light by program
it's working in this form.
I have to change the interval now.
1 Dec - 10 January
I have to change the interval now.
1 Dec - 10 January
Code: Select all
return {
on = {
timer = { 'daily' },
devices = { 267 } -- Se activează și la schimbările de stare ale switch-ului cu idx-ul 267
},
execute = function(dz)
local currentDate = os.date('*t')
local switchIdxToControl = 23
local requiredSwitchIdx = 267
-- Verificăm dacă switch-ul cu idx-ul 267 este ON
local requiredSwitchState = dz.devices(requiredSwitchIdx).state
if requiredSwitchState == 'On' then
-- Dacă suntem în decembrie sau ianuarie, pornim switch-ul cu idx-ul 23
if currentDate.month == 12 or currentDate.month == 1 then
dz.devices(switchIdxToControl).switchOn()
else
-- În orice altă lună, oprim switch-ul cu idx-ul 23
dz.devices(switchIdxToControl).switchOff()
end
else
-- Dacă switch-ul cu idx-ul 267 nu este ON, asigurăm că switch-ul cu idx-ul 23 este oprit
dz.devices(switchIdxToControl).switchOff()
end
end
}
Who is online
Users browsing this forum: No registered users and 1 guest