Switch off delay not working

Moderator: leecollings

Post Reply
27fb
Posts: 6
Joined: Tuesday 13 April 2021 9:16
Target OS: Linux
Domoticz version: 2020.2
Contact:

Switch off delay not working

Post by 27fb »

Hello,

The switch off delay does not seem to be working. Whatever the delay value, the switch turns off immediately.
The on delay however works just as expected.

1) Could anyone confirm the bug ? Is there a fix ?
2) Does the off delay normally apply to a script attached the off event ?

Thanks for your help


I am using :
Version: 2020.2
Build Hash: b63341bc0
Compile Date: 2020-04-26 13:47:55
dzVents Version: 3.0.2
Python Version: 3.7.3 (default, Jan 22 2021, 20:04:44) [GCC 8.3.0]
Domoticz on a Debian Buster VM (Proxmox).
Devices: controls: Zwave (mostly Fibaro), mesures: Zigate (Xiaomi, Aqara).
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Switch off delay not working

Post by waaren »

27fb wrote: Tuesday 13 April 2021 9:22 The switch off delay does not seem to be working. Whatever the delay value, the switch turns off immediately.
The on delay however works just as expected.
Standard behavior for these delays is:

The On delay causes a device to switch On with a delay of the set amount of seconds after the switchOn command is given.
The Off delay causes a device to switch Off with a delay of the set amount of seconds after the device switched to On.

Does your device react different?
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
27fb
Posts: 6
Joined: Tuesday 13 April 2021 9:16
Target OS: Linux
Domoticz version: 2020.2
Contact:

Re: Switch off delay not working

Post by 27fb »

Thank you for your quick reply. You are right I was confused about the meaning of "Off delay".

Is there a way to delay extinction (i.e. to postpone SwitchOff command) ? To be more precise I would like to shutdown my mediacenter « gracefully » before turning off the power switch.
Domoticz on a Debian Buster VM (Proxmox).
Devices: controls: Zwave (mostly Fibaro), mesures: Zigate (Xiaomi, Aqara).
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Switch off delay not working

Post by waaren »

27fb wrote: Tuesday 13 April 2021 19:40 Thank you for your quick reply. You are right I was confused about the meaning of "Off delay".

Is there a way to delay extinction (i.e. to postpone SwitchOff command) ? To be more precise I would like to shutdown my mediacenter « gracefully » before turning off the power switch.
You can do this with scripting. How do you shutdown your mediacenter ?
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
waltervl
Posts: 5859
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Switch off delay not working

Post by waltervl »

If you have group for example media center with 2 devices (media center and power plug) when you switch off the group you can set a delay of x seconds on the off action of the plug. So the 2 devices get the switch off action on the same time but the plug will switch off x seconds later than the media center.
Forget this... I also understood this switch off delay completely different. It is switch off delay after switch on......

Edit: Switching on off delay behavior is as described.
Last edited by waltervl on Thursday 15 April 2021 11:58, edited 1 time in total.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
27fb
Posts: 6
Joined: Tuesday 13 April 2021 9:16
Target OS: Linux
Domoticz version: 2020.2
Contact:

Re: Switch off delay not working

Post by 27fb »

waltervl wrote: Tuesday 13 April 2021 21:09 If you have group for example media center with 2 devices (media center and power plug) when you switch off the group you can set a delay of x seconds on the off action of the plug. So the 2 devices get the switch off action on the same time but the plug will switch off x seconds later than the media center.
Forget this... I also understood this switch off delay completely different. It is switch off delay after switch on......
Yes I got confused too...
Domoticz on a Debian Buster VM (Proxmox).
Devices: controls: Zwave (mostly Fibaro), mesures: Zigate (Xiaomi, Aqara).
27fb
Posts: 6
Joined: Tuesday 13 April 2021 9:16
Target OS: Linux
Domoticz version: 2020.2
Contact:

Re: Switch off delay not working

Post by 27fb »

waaren wrote: Tuesday 13 April 2021 20:58
27fb wrote: Tuesday 13 April 2021 19:40 Thank you for your quick reply. You are right I was confused about the meaning of "Off delay".

Is there a way to delay extinction (i.e. to postpone SwitchOff command) ? To be more precise I would like to shutdown my mediacenter « gracefully » before turning off the power switch.
You can do this with scripting. How do you shutdown your mediacenter ?
I intended to run a bash script triggered when turning off the switch (the script:/// is declared in the Action off field of the switch). The script itself triggers a JSON rpc on the mediacenter (vero4k). The switch is a fibaro wall plug. It controls other peripherals such as an audio amplifier, tv...
Domoticz on a Debian Buster VM (Proxmox).
Devices: controls: Zwave (mostly Fibaro), mesures: Zigate (Xiaomi, Aqara).
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Switch off delay not working

Post by waaren »

27fb wrote: Wednesday 14 April 2021 23:06 I intended to run a bash script triggered when turning off the switch (the script:/// is declared in the Action off field of the switch). The script itself triggers a JSON rpc on the mediacenter (vero4k). The switch is a fibaro wall plug. It controls other peripherals such as an audio amplifier, tv...
A dzVents approach could look like below

__________________________________________________________________________________________________________________________
When not yet familiar with dzVents please start with reading Get started Before implementing (~ 5 minutes). Special attention please for "In Domoticz go to Setup > Settings > Other and in the section EventSystem make sure the checkbox 'dzVents enabled' is checked. Also make sure that in the Security section in the settings you allow 127.0.0.1 to not need a password. dzVents uses that port to send certain commands to Domoticz. Finally make sure you have set your current location in Setup > Settings > System > Location, otherwise there is no way to determine nighttime/daytime state."
___________________________________________________________________________________________________________________________


Code: Select all

local scriptVar = 'mediacenter Control'

return
{
    on =
    {
        devices =
        {
            'stop mediacenter', -- define as virtual push off button
        },

        httpResponses =
        {
            scriptVar,
        },
    },

    logging = {
        level = domoticz.LOG_DEBUG, -- change to domoticz.LOG_ERROR when all ok
        marker = 'mediacenter control',
    },

    execute = function(dz, item)
        local delay = 5

        if item.isDevice and item.state == 'Off' then
            dz.openURL(
            {
                url = 'http://mediacenter_JSON_rpc', -- change to JSON call
                callback = scriptVar,
            })
        elseif item.isHTTPResponse then
            dz.devices('Fibaro plug').switchOff().silent().afterSec(delay)
        end
    end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
27fb
Posts: 6
Joined: Tuesday 13 April 2021 9:16
Target OS: Linux
Domoticz version: 2020.2
Contact:

Re: Switch off delay not working

Post by 27fb »

Thank you very much ! I added a condition to switch power on whenever the virtual switch is turned on. Even though it's working, could you please have a look and tell me if the conditional construct is correct (should item.state == 'On' be a subbranch of item.IsDevice) ?

Code: Select all

local scriptVar = 'mediacenter control'

return
{
    on =
    {
        devices =
        {
            'mediacenter.switch', -- define as virtual push off button
        },

        httpResponses =
        {
		scriptVar,	
        },
    },

    logging = {
        level = domoticz.LOG_ERROR, -- change to domoticz.LOG_DEBUG when testing
        marker = 'mediacenter control',
    },

    execute = function(dz, item)
        local delay = 30

        if item.isDevice and item.state == 'On' then
            dz.devices('television.switch').switchOn().silent()
	end
        
	if item.isDevice and item.state == 'Off' then
            dz.openURL(
            {
                url = 'http://<mediacenterip:port>/jsonrpc', -- change to JSON call
		method= 'POST',
		postData= {['jsonrpc']= "2.0", ["method"]= "System.Shutdown", ["id"]= "domoticz"},
                callback = scriptVar,
            })
        elseif item.isHTTPResponse then
            dz.devices('television.switch').switchOff().silent().afterSec(delay)
        end
    end
}
Domoticz on a Debian Buster VM (Proxmox).
Devices: controls: Zwave (mostly Fibaro), mesures: Zigate (Xiaomi, Aqara).
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Switch off delay not working

Post by waaren »

27fb wrote: Thursday 15 April 2021 1:00 Thank you very much ! I added a condition to switch power on whenever the virtual switch is turned on. Even though it's working, could you please have a look and tell me if the conditional construct is correct (should item.state == 'On' be a subbranch of item.IsDevice) ?
Good to hear it's working for you.
No sure I understand your question about subbranch.
item.isDevice and item.state are both attributes of the item object. item.isDevice is a boolean (true or false/nil) and item.state is a string (if item (= mediacenter.switch) is an On/Off switch: 'On' or 'Off').

The script could then also look like below

Code: Select all

local scriptVar = 'mediacenter control'

return
{
    on =
    {
        devices =
        {
            'mediacenter.switch', -- define as virtual switch
        },

        httpResponses =
        {
        scriptVar,
        },
    },

    logging = {
        level = domoticz.LOG_ERROR, -- change to domoticz.LOG_DEBUG when testing
        marker = 'mediacenter control',
    },

    execute = function(dz, item)
        local delay = 30
        local tv = dz.devices('television.switch')

        if item.isDevice and item.state == 'On' then
            tv.switchOn().silent()
        elseif item.isDevice and item.state == 'Off' then
            dz.openURL(
            {
                url = 'http://<mediacenterip:port>/jsonrpc', 
                method= 'POST',
                postData= {['jsonrpc']= "2.0", ["method"]= "System.Shutdown", ["id"]= "domoticz"},
                callback = scriptVar,
            })
        elseif item.isHTTPResponse then
            tv.switchOff().silent().afterSec(delay)
        end
    end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
27fb
Posts: 6
Joined: Tuesday 13 April 2021 9:16
Target OS: Linux
Domoticz version: 2020.2
Contact:

Re: Switch off delay not working

Post by 27fb »

That's exactly what i expected.

Still I find it complicated. Wouldn't it be easier to have a "Switch off delay " field directly at the switch level that does that. This would also imply renaming the present feature to "Switch off delay after switch on" because current labeling is pretty confusing.

Anyway thank you again !
Domoticz on a Debian Buster VM (Proxmox).
Devices: controls: Zwave (mostly Fibaro), mesures: Zigate (Xiaomi, Aqara).
User avatar
waltervl
Posts: 5859
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Switch off delay not working

Post by waltervl »

Well I Just tested it.
It is what we both thought and not according the description @waaren gave:
Switch on delay is delay after switching on device command.
Switch off delay is delay after switching off device command.

So my proposal for a Group in your case is feasible.
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
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Switch off delay not working

Post by waaren »

waltervl wrote: Thursday 15 April 2021 11:57 It is what we both thought and not according the description @waaren gave:
My post was not about the On / Off delay feature in Scenes / Groups. It was about On/ Off delay in Switch settings.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
waltervl
Posts: 5859
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Switch off delay not working

Post by waltervl »

waaren wrote: Thursday 15 April 2021 12:50
waltervl wrote: Thursday 15 April 2021 11:57 It is what we both thought and not according the description @waaren gave:
My post was not about the On / Off delay feature in Scenes / Groups. It was about On/ Off delay in Switch settings.
Oh man, things can be made complicated here.... Why have 2 settings that have a different meaning on different locations?
Just tested it and that is correct.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
jannl
Posts: 673
Joined: Thursday 02 October 2014 6:36
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Location: Geleen
Contact:

Re: Switch off delay not working

Post by jannl »

Why not check the power consumption before switching off?

I switch off my desktop 5 minutes afterr the power consumption drops below a certain value. If for some reason the shutdown takes longer than expected you could have a problem.....
HM31
Posts: 56
Joined: Friday 04 August 2017 16:13
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Switch off delay not working

Post by HM31 »

It seems that the switch Off delay does not work for Python managed switch, specifically for TPLink hardware switchs (https://github.com/J0hnMatrix/domoticz- ... 0-hs110-v2)

My switch is configured to automatically come "Off" after 20 seconds :
Off Delay: 20 (Seconds) 0 = Disabled
But it seems that it does nothing (it works perfectly with a RF433 switch with RFXCom.

There is no action to switch it off after the 20s in log file.
User avatar
waltervl
Posts: 5859
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Switch off delay not working

Post by waltervl »

I am almost sure I tested it on Python Plugin controlled switches (Zigate Zigbee) and for me it worked.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
HM31
Posts: 56
Joined: Friday 04 August 2017 16:13
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Switch off delay not working

Post by HM31 »

Thanks for this answer.
May be it's something with this specific plugin ?!
I used a workaround adding a "FOR 20 SECONDS" in my lua script that put my switch On and this works.
I opened an issue on github, but this plugin has some forks and seems not to be updated frequently.
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 1 guest