Switch on for 1 minute and off for 10 minutes
Moderator: leecollings
-
- Posts: 7
- Joined: Thursday 15 August 2019 1:21
- Target OS: Linux
- Domoticz version: 2021.1
- Contact:
Switch on for 1 minute and off for 10 minutes
Hello everyone,
how can I realise it in dzvents that a switch, which when a temperature of a sensor has < 20 degrees, is switched on via dzvents for one minute, then is switched off but only checks again in 10 minutes what the temperature is and then switches the switch on again for one minute and then again from the beginning?
All my attempts showed that either the switch was permanently switched on, or it was switched on and then switched off again after 2 seconds.
I would be pleased if someone could give me a tip.
Thank you very much!
Peter
how can I realise it in dzvents that a switch, which when a temperature of a sensor has < 20 degrees, is switched on via dzvents for one minute, then is switched off but only checks again in 10 minutes what the temperature is and then switches the switch on again for one minute and then again from the beginning?
All my attempts showed that either the switch was permanently switched on, or it was switched on and then switched off again after 2 seconds.
I would be pleased if someone could give me a tip.
Thank you very much!
Peter
- waltervl
- Posts: 5153
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: Switch on for 1 minute and off for 10 minutes
Run the dZvents script every 10 minutes (using timer) and use switchOn().forMin(1) to switch on for 1 minute
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: 7
- Joined: Thursday 15 August 2019 1:21
- Target OS: Linux
- Domoticz version: 2021.1
- Contact:
Re: Switch on for 1 minute and off for 10 minutes
Thanks a lot!
I thougt, that 'every ten Minutes' set in quotes was a synonyme for an function, i have to write by myself...
got it work now..
Thanks!
Peter
I thougt, that 'every ten Minutes' set in quotes was a synonyme for an function, i have to write by myself...
Code: Select all
timer =
{
'every 10 minutes',
},
Thanks!
Peter
-
- Posts: 49
- Joined: Wednesday 03 May 2023 10:12
- Target OS: NAS (Synology & others)
- Domoticz version:
- Contact:
Re: Switch on for 1 minute and off for 10 minutes
Why use a dzVents script for that? You can set this behaviour (on/off after X seconds) on the switch property page.
- jvdz
- Posts: 2189
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: Switch on for 1 minute and off for 10 minutes
You would have to change that to 'every 11 minutes' to make it go On for 1 and Off for 10 minutes!
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
- habahabahaba
- Posts: 192
- Joined: Saturday 18 March 2023 14:44
- Target OS: Windows
- Domoticz version: 2024.4
- Contact:
Re: Switch on for 1 minute and off for 10 minutes
You can not set timer for 11 minutes
-
- Posts: 537
- Joined: Monday 20 March 2023 14:41
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Somewhere in NL
- Contact:
Re: Switch on for 1 minute and off for 10 minutes
Yes, you can.
In dzVents set the timer to every minute and do calculation of the number of minutes from midnight, and then do a mod 11 on that number.
In dzVents set the timer to every minute and do calculation of the number of minutes from midnight, and then do a mod 11 on that number.
Logic will get you from A to B. Imagination will take you everywhere.
- habahabahaba
- Posts: 192
- Joined: Saturday 18 March 2023 14:44
- Target OS: Windows
- Domoticz version: 2024.4
- Contact:
- madpatrick
- Posts: 639
- Joined: Monday 26 December 2016 12:17
- Target OS: Linux
- Domoticz version: 2024.7
- Location: Netherlands
- Contact:
Re: Switch on for 1 minute and off for 10 minutes
You can maybe use the "retrigger" function in dzventz
this is an part of a script i use and you can customize
this is an part of a script i use and you can customize
Code: Select all
local scriptVar = '-=# PIR Woonkamer #=-'
local light = 'Woonkamer' -- change to name of your light/group
local Screens = 'Screens'
local retrigger = 'Retrigger using customEvent'
local minutesBeforeSunset = 120 -- xxx min before sunset
return
{
on =
{
timer =
{
function(domoticz)
return
domoticz.time.matchesRule('at ' .. domoticz.variables('UV_Sleep').value) or
domoticz.time.matchesRule('at ' .. minutesBeforeSunset .. ' minutes before sunset')
end,
},
--devices = { Test, },
customEvents =
{
retrigger,
}
},
logging = { level = domoticz.LOG_ERROR, -- change to domoticz.LOG_ERROR when all OK
marker = scriptVar
},
execute = function(dz)
local Sleep = dz.variables('UV_Sleep').value
local light = dz.groups(light) -- groups instead of device
local Screens_WNK = dz.devices(492)
local Screens_BLOK1 = dz.devices(493)
local Erker_gr = dz.devices(603)
local Erker_kl = dz.devices(612)
local Screens_Deur = dz.devices(605)
local PIR = dz.devices(451)
local lux = dz.devices(454).lux
dz.log('LUX = ' .. lux .. ' en verlichting ' .. light.name .. ' is ' .. light.state,dz.LOG_FORCE)
if dz.time.matchesRule('between ' .. minutesBeforeSunset .. ' minutes before sunset and ' .. Sleep) and not(dz.time.matchesRule('at ' .. Sleep)) then
if lux <= 10 and (Erker_gr.level < 50 or Erker_kl.level < 50 ) and Screens_BLOK1.state ~= "Open" and Screens_BLOK2.state ~= "Open" then
Screens_BLOK1.switchSelector('Open')
dz.log('Screens Blok 1 OPEN voor lichtsensor Lux <10',dz.LOG_FORCE)
dz.log('Script wordt opnieuw gestart in 5 minuten (regel 60)',dz.LOG_FORCE)
dz.emitEvent(retrigger).afterSec(300) -- try again
elseif light.state ~= 'On' then
dz.log('Script wordt opnieuw gestart in 3 minuten (regel 90)',dz.LOG_FORCE)
dz.emitEvent(retrigger).afterSec(180) -- try again
end
end
}
-= HP server GEN8 Xeon(R) E3-1220L_V2 -=- OZW -=- Toon2 (rooted) -=- Domoticz v2024.7 -=- Dashticz v3.12b on Tab8" =-
-
- Posts: 33
- Joined: Tuesday 18 April 2023 8:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2023.2
- Contact:
Re: Switch on for 1 minute and off for 10 minutes
did u solve your problem? if u use a 10 min trigger u will miss every 1 min that the switch is on, like previously said, so the time between On cycles will only be 9 min. if u necessarily need a 10 min cycle, here's the simplest idea i can came up with:
this script trigger every 1 minute and check the temperature and if 10 min have passed since the switch was last time actioned. if the temperature is strictly under 20 degrees and the time last update is 10 minutes then the switch is turned on for 1 minute.
u can also use as the trigger for the script the temperature sensor not the time trigger. but if u need the exact time between on state and the pause then u will need to think about how often the sensore is read and how is this affecting the time u check for the switch being off.
u should probably be a little more specific and clear with what u wanna accomplish. from how u formulated the problem in the first post, i kinda doubt that this is really what u want.
keep in mind that i'm just a beginner in this just like u so maybe a second opinion on this is a good idea
Code: Select all
return {
on = {
timer = { 'every 1 minutes' },
},
execute = function(dz, devices)
local mySwitch = dz.devices('yourSwitch') -- replace yourSwitch with the name of your switch
local temp = dz.devices('tempSensor').temperature -- replace tempSensor with your temperature sensore.
local time = os.time() -- the time when the script is triggered
local switchOffTime = 600 -- the time that switch need to be off in seconds (600 seconds = 10 min)
local desiredTemp = 20 -- the desired temperature
local lastSeen = mySwitch.lastUpdate.secondsAgo --time the switch was operated last time
local checkTime = time - (time - lastSeen) -- calculate when the switch was last operated
if (temp < desiredTemp and checkTime >= switchOffTime ) then --check if the temperature is under 20 and if 10 min have passed since the switch is last operated
mySwitch.switchOn().forSec(60).checkFirst() -- switch is On for 60 seconds
end
end
}
u can also use as the trigger for the script the temperature sensor not the time trigger. but if u need the exact time between on state and the pause then u will need to think about how often the sensore is read and how is this affecting the time u check for the switch being off.
u should probably be a little more specific and clear with what u wanna accomplish. from how u formulated the problem in the first post, i kinda doubt that this is really what u want.
keep in mind that i'm just a beginner in this just like u so maybe a second opinion on this is a good idea
Who is online
Users browsing this forum: No registered users and 1 guest