Insert delay option in script?
Moderator: leecollings
-
- Posts: 143
- Joined: Wednesday 12 August 2020 17:13
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2022.2
- Location: Fryslan
- Contact:
Insert delay option in script?
I have a bathroom with a door and a window. Both have a open/close detection switch.
I made a Blockly script with a dummy switch to heat (CV5=Zigbee Radiator Valve) the bathroom when door and window are closed. When one of them is open, the "Badkamer" button switches of after 0.5 sec. After enabling, the dummy switch lights up and goes off again if the closed door/room condition is not closed.
If I walk in/out the bathroom the heating is switched off, because of the switch rule.
Is there a way to build in a kind of delay that keeps this scene enabled if the open/close door is < 10sec, so I can walk in and out again to fetch something without the script to stop. If the door is left open for >10sec it means it is open permanently and script should turn off
I made a Blockly script with a dummy switch to heat (CV5=Zigbee Radiator Valve) the bathroom when door and window are closed. When one of them is open, the "Badkamer" button switches of after 0.5 sec. After enabling, the dummy switch lights up and goes off again if the closed door/room condition is not closed.
If I walk in/out the bathroom the heating is switched off, because of the switch rule.
Is there a way to build in a kind of delay that keeps this scene enabled if the open/close door is < 10sec, so I can walk in and out again to fetch something without the script to stop. If the door is left open for >10sec it means it is open permanently and script should turn off
Last edited by njlammerts on Sunday 13 March 2022 12:45, edited 1 time in total.
- madpatrick
- Posts: 659
- Joined: Monday 26 December 2016 12:17
- Target OS: Linux
- Domoticz version: 2024.7
- Location: Netherlands
- Contact:
Re: Insert delay option in script?
You can check this dzventz script. viewtopic.php?p=257729#p257729
I think this answers your question
For me it is working perfectly and you can customize it easily.
I think this answers your question
For me it is working perfectly and you can customize it easily.
-= HP server GEN11 =- OZW -=- Toon2 (rooted) -=- Domoticz v2024.7 -=- Dashticz v3.14b on Tab8" =-
-
- Posts: 143
- Joined: Wednesday 12 August 2020 17:13
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2022.2
- Location: Fryslan
- Contact:
Re: Insert delay option in script?
Thanks for the reply, but I I would like it implemented in Blockly
My Programm skills are not great and Blockly is for me an easy way to get things working
My Programm skills are not great and Blockly is for me an easy way to get things working
- madpatrick
- Posts: 659
- Joined: Monday 26 December 2016 12:17
- Target OS: Linux
- Domoticz version: 2024.7
- Location: Netherlands
- Contact:
Re: Insert delay option in script?
Blocky is user friendly, but limited in functionality
Dzvents is very powerful and once you tried it will get understandable.
Also there is some support on the forum to help
Post your complete Blocky and i’ll check if i can help
Dzvents is very powerful and once you tried it will get understandable.
Also there is some support on the forum to help
Post your complete Blocky and i’ll check if i can help
-= HP server GEN11 =- OZW -=- Toon2 (rooted) -=- Domoticz v2024.7 -=- Dashticz v3.14b on Tab8" =-
-
- Posts: 24
- Joined: Tuesday 27 February 2018 8:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Insert delay option in script?
With Blockly you have everything you need for most House Automation, except calculation...
I think you are looking for this?
I think you are looking for this?
- Attachments
-
- Badkammer.jpg (71.94 KiB) Viewed 2545 times
- madpatrick
- Posts: 659
- Joined: Monday 26 December 2016 12:17
- Target OS: Linux
- Domoticz version: 2024.7
- Location: Netherlands
- Contact:
Re: Insert delay option in script?
You could try this as an example
Check the variable (local) names if this matches your setting
Check the variable (local) names if this matches your setting
Code: Select all
local scriptVersion = 'Versie 1.00'
local scriptVar = '-=# Badkamer #=-'
local ContactDoor = 'Badkamer Door'
local ContactWindow = 'Badkamer Windows'
local Thermostat = 'Badkamer'
return
{
active = true,
on = {
devices = {ContactDoor,ContactWindow},
}
logging = {
level = domoticz.LOG_ERROR, -- change to LOG_ERROR when all OK
marker = scriptVar,
},
},
execute = function(dz, item)
local delay = 10
local temp = dz.devices(Thermostat)
local door = dz.devices(ContactDoor)
local windows = dz.devices(ContactWindow)
if temp.state == "On" and (door.state =="On" or window.state =="On") then
if window.lastUpdate.secondsAgo or door.lastUpdate.secondsAgo >= delay then
dz.log('Last update Sensors : ' .. door.lastUpdate.secondsAgo .. ' and ' .. window.lastUpdate.secondsAgo, dz.LOG_FORCE)
dz.log('Badkamer temperaure set to 5°C ', dz.LOG_FORCE)
temp.setpoint(5)
else
dz.log('Nothing to do' , dz.LOG_FORCE)
end
end
end
}
-= HP server GEN11 =- OZW -=- Toon2 (rooted) -=- Domoticz v2024.7 -=- Dashticz v3.14b on Tab8" =-
- kuifje
- Posts: 36
- Joined: Wednesday 25 October 2017 16:38
- Target OS: Raspberry Pi / ODroid
- Domoticz version: latest
- Location: Heemskerk
- Contact:
Re: Insert delay option in script?
njlammerts,
You can also use an user variable.
When the door and the window are closed then set the user variable to 1.
When one of them is open set user variable to 0.
When zero then badkamer is off.
Kuifje
You can also use an user variable.
When the door and the window are closed then set the user variable to 1.
When one of them is open set user variable to 0.
When zero then badkamer is off.
Kuifje
-
- Posts: 143
- Joined: Wednesday 12 August 2020 17:13
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2022.2
- Location: Fryslan
- Contact:
- jvdz
- Posts: 2269
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: Insert delay option in script?
Guess you mean Nested IF commands as the shown blockly doesn't have any nested commands and only a one level If- ELSEIF.

The AND OR logic could be a little bit tricky though.
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
-
- Posts: 143
- Joined: Wednesday 12 August 2020 17:13
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2022.2
- Location: Fryslan
- Contact:
Re: Insert delay option in script?
I mean
....................AF-badkamer
........and
...............or. AF badkamer door
....................AF Badkamer window
I am repeating the command for AF badkamer door and AF badkamer windows
....................AF-badkamer
........and
...............or. AF badkamer door
....................AF Badkamer window
I am repeating the command for AF badkamer door and AF badkamer windows
-
- Posts: 143
- Joined: Wednesday 12 August 2020 17:13
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2022.2
- Location: Fryslan
- Contact:
Re: Insert delay option in script?
Sorry for the late reply, but the suggestions displayed above is not what I mean/want.
I have a window and door switch in the bathroom. When they both are open, I want the radiator valve in the bathroom to be closed, even if the temperature sensor "says" heat the bathroom. Only when window and door are closed and temperature sensor is below the set value, I want the radiator valve to open, so the bathroom can be heated with a script.
In my script the bathroom is heated when both window and door are closed. But when the bathroom door is opened, the script is set to "close valve" , even when you only walk in and out within 10-20 sec. I would like a delay in the door sensor, that leaves the script "running" when the door is opened for less the 10-20 sec (so the valve/script won't close). When the door is opened longer then I assume the door is "normal" open and should the valve close/script end
I have a window and door switch in the bathroom. When they both are open, I want the radiator valve in the bathroom to be closed, even if the temperature sensor "says" heat the bathroom. Only when window and door are closed and temperature sensor is below the set value, I want the radiator valve to open, so the bathroom can be heated with a script.
In my script the bathroom is heated when both window and door are closed. But when the bathroom door is opened, the script is set to "close valve" , even when you only walk in and out within 10-20 sec. I would like a delay in the door sensor, that leaves the script "running" when the door is opened for less the 10-20 sec (so the valve/script won't close). When the door is opened longer then I assume the door is "normal" open and should the valve close/script end
-
- Posts: 24
- Joined: Tuesday 27 February 2018 8:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Insert delay option in script?
That is what the blockly do, i Made for you on 25.12. You need a Dummy Switch for your delayed door. Then you use the Dummy instead your door Switch.njlammerts wrote: ↑Saturday 05 February 2022 11:47 In my script the bathroom is heated when both window and door are closed. But when the bathroom door is opened, the script is set to "close valve" , even when you only walk in and out within 10-20 sec. I would like a delay in the door sensor, that leaves the script "running" when the door is opened for less the 10-20 sec (so the valve/script won't close). When the door is opened longer then I assume the door is "normal" open and should the valve close/script end
Benny
Who is online
Users browsing this forum: No registered users and 1 guest