set device "Off Delay" value with DzVents

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
ravaoo
Posts: 39
Joined: Friday 14 October 2022 10:46
Target OS: NAS (Synology & others)
Domoticz version: 2024-7
Location: Nederland
Contact:

set device "Off Delay" value with DzVents

Post by ravaoo »

I would like to set device "Off Delay" value with DzVents script
Why?

Normaly we want the lights go off automaticly after 20 min (if there is no movement). Sometimes we want this only after 2 hours of no movement. It is nice weather, we are in the garden and we don't want come in in a dark house. :)

I made a dummy switch "stay longer on" and i want to set the vallue of some lights to 7200 delay when turned on and to 1200 when turned off.

Is it posible, and if so, how?

Thanks for helping
Running latest BETA on on Docker (Container Manager) in Synology NAS using zwave_js_ui with mqtt. Getting started with homebridge.

Living in an automated house is a survival but it is worth it
User avatar
waltervl
Posts: 5148
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: set device "Off Delay" value with DzVents

Post by waltervl »

You have to script this totally with dzvents. You cannot override the default switch off setting with dzVents.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
ravaoo
Posts: 39
Joined: Friday 14 October 2022 10:46
Target OS: NAS (Synology & others)
Domoticz version: 2024-7
Location: Nederland
Contact:

Re: set device "Off Delay" value with DzVents

Post by ravaoo »

Thanks Waltervl, again :)

So i have to switch off the device in dzvents and not by device settings. There is no way te set the default switch off settings with script?
Running latest BETA on on Docker (Container Manager) in Synology NAS using zwave_js_ui with mqtt. Getting started with homebridge.

Living in an automated house is a survival but it is worth it
User avatar
waltervl
Posts: 5148
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: set device "Off Delay" value with DzVents

Post by waltervl »

No, there is also no documented option to set the off delay with Domoticz API. You can try to find it through the browser session with developer help F12
Then you could also switch this directly as http action commands on your dummy switch "stay longer on". No need to do it through dzvents.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
lost
Posts: 616
Joined: Thursday 10 November 2016 9:30
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: set device "Off Delay" value with DzVents

Post by lost »

ravaoo wrote: Tuesday 23 July 2024 10:59 Normaly we want the lights go off automaticly after 20 min (if there is no movement). Sometimes we want this only after 2 hours of no movement. It is nice weather, we are in the garden and we don't want come in in a dark house. :)
For this, I would just add another motion sensor close to the home/garden door (if there is no good old physical switch light at the right place) able to catch me when I come in? IMO better that keeping light on for hours and bugs would not be attracted inside (or ready to enter as soon I open the bay window!).

When I have very specific needs for a SW that have many years of development, I always think "there may be a better idea?"! :)
BartSr
Posts: 347
Joined: Sunday 03 July 2016 16:16
Target OS: Raspberry Pi / ODroid
Domoticz version: V2024.3
Location: Netherlands
Contact:

Re: set device "Off Delay" value with DzVents

Post by BartSr »

just a brainwave
there is a generic example in Lua for turning of the light xx sec. after movement.
Create a uservar which override the delay-time of the script.
A normal dummyswitch might set/reset the uservar so changing to extended delay.
Raspberry pi 3b
Arduino
KAKU
RfxCom
Zwave
OTGW
Chinese sensors temp (Dallas),movement
Tasmota
Esp8266 espeasy
MQTT
User avatar
waltervl
Posts: 5148
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: set device "Off Delay" value with DzVents

Post by waltervl »

Did some testing and found the API call. It are the values for a switch (could have different meanings for other type of devices) in below mention API call:
addjvalue=ONDELAY
addjvalue2=OFFDELAY

Code: Select all

http://IP:Port/json.htm?type=command&param=setused&used=true&addjvalue=ONDELAY&addjvalue2=OFFDELAY&idx=IDX
So in your dummy switch you can set the On and Off (change all values) to the correct ones so it changes the delay values for the wanted light device (IDX)
API_OFFDELAY.png
API_OFFDELAY.png (18.75 KiB) Viewed 945 times
a real link would look like below to set off delay to 300 seconds and on delay is 0 for device 84

Code: Select all

http://192.165.2.35:8080/json.htm?type=command&param=setused&used=true&addjvalue=0&addjvalue2=300&idx=84
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
madpatrick
Posts: 636
Joined: Monday 26 December 2016 12:17
Target OS: Linux
Domoticz version: 2024.7
Location: Netherlands
Contact:

Re: set device "Off Delay" value with DzVents

Post by madpatrick »

it is not that difficult to do this with Dzvents
I've something similar.

Maybe this helps as a start

Code: Select all

       if PIR.lastUpdate.secondsAgo > 1800 and (Party_Switch.state == 'Off') then
                light.switchOff().afterMin(10)
                dz.log(PIR.name .. ' update : ' .. PIR.lastUpdate.secondsAgo .. ' seconden geleden',dz.LOG_STATUS)
                dz.log(light.name .. ' schakelt UIT of is al UIT en ' .. Party_Switch.name .. ' is ' .. Party_Switch.state ,dz.LOG_STATUS)
                elseif  PIR.lastUpdate.secondsAgo > 1800 and (Party_Switch.state == 'On')
                light.switchOff().afterMin(120)
                dz.log(light.name .. ' schakelt UIT of is al UIT en ' .. Party_Switch.name .. ' is ' .. Party_Switch.state ,dz.LOG_STATUS)
                end
                
-= HP server GEN8 Xeon(R) E3-1220L_V2 -=- OZW -=- Toon2 (rooted) -=- Domoticz v2024.7 -=- Dashticz v3.12b on Tab8" =-
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest