Insert delay option in script?

Moderator: leecollings

Post Reply
njlammerts
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?

Post by njlammerts »

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.

Schermafbeelding 2021-12-23 om 10.37.17.png
Schermafbeelding 2021-12-23 om 10.37.17.png (100.62 KiB) Viewed 2625 times

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.
User avatar
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?

Post by madpatrick »

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.
-= HP server GEN11 =- OZW -=- Toon2 (rooted) -=- Domoticz v2024.7 -=- Dashticz v3.14b on Tab8" =-
njlammerts
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?

Post by njlammerts »

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
User avatar
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?

Post by madpatrick »

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
-= HP server GEN11 =- OZW -=- Toon2 (rooted) -=- Domoticz v2024.7 -=- Dashticz v3.14b on Tab8" =-
BennY
Posts: 24
Joined: Tuesday 27 February 2018 8:25
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Insert delay option in script?

Post by BennY »

With Blockly you have everything you need for most House Automation, except calculation...

I think you are looking for this?
Attachments
Badkammer.jpg
Badkammer.jpg (71.94 KiB) Viewed 2545 times
User avatar
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?

Post by madpatrick »

You could try this as an example

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" =-
User avatar
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?

Post by kuifje »

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
Badkamer.JPG
Badkamer.JPG (56.69 KiB) Viewed 2499 times
njlammerts
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?

Post by njlammerts »

BennY wrote: Saturday 25 December 2021 21:36 With Blockly you have everything you need for most House Automation, except calculation...

I think you are looking for this?
Im am told that "Nested Commands". can not be used?
Schermafbeelding 2022-01-28 om 17.04.11.png
Schermafbeelding 2022-01-28 om 17.04.11.png (257.3 KiB) Viewed 2328 times
User avatar
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?

Post by jvdz »

njlammerts wrote: Friday 28 January 2022 17:05 Im am told that "Nested Commands". can not be used?
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
njlammerts
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?

Post by njlammerts »

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
njlammerts
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?

Post by njlammerts »

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
BennY
Posts: 24
Joined: Tuesday 27 February 2018 8:25
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Insert delay option in script?

Post by BennY »

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
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.

Benny
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest