Best way to run an action for 20 seconds

Moderator: leecollings

Post Reply
Ewaldharmsen
Posts: 130
Joined: Tuesday 07 February 2017 15:00
Target OS: Linux
Domoticz version:
Contact:

Best way to run an action for 20 seconds

Post by Ewaldharmsen »

Hi all,

I currently have electrical sunscreens, but not they are not smart.
I am thinking about controlling them via Domoticz by just turning on a specific relay for 20 seconds, te time it takes to close the sunscreen.
An of course another relay for 20 seconds to open it again.

Does anybody know the best way to do that?

If I put a pause command in lua of 20 second I will end up with the warning that my script runs for longer than 10 seconds.
Working with timers is also not possible I believe.

So what I basically want is a switch which will stay on for 20 seconds, than turns off
User avatar
Egregius
Posts: 2592
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Best way to run an action for 20 seconds

Post by Egregius »

Why not use a zwave blind switch? Then you just have to send the open/close command and the switch does the rest.
Thomasdc
Posts: 133
Joined: Wednesday 11 March 2015 19:13
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: Best way to run an action for 20 seconds

Post by Thomasdc »

just add the switch in domoticz and in the 'off delay' field enter 20 'you can find this in the "edit" tab of the switch int the switch overview

then when its turned on after 20 seconds it will turn off
User avatar
EdddieN
Posts: 510
Joined: Wednesday 16 November 2016 11:31
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.9700
Location: Scotland
Contact:

Re: Best way to run an action for 20 seconds

Post by EdddieN »

Sorry, highjacking this a bit.

I'm trying to do something similar, but with a % slider. I have a RF motor with RFXComm but I'm only able to do natively Open, Close and Stop.
What I would like to do is to be able to have a % slider, or at least an approximation of it. Usually to fully open or close the roller blind takes about 12 seconds, so I created a virtual percentage blind control and the following LUA code:

Code: Select all

------------------------------------------------------------------------------
-- Status virtual slider
status_blinds = 'Virtual Blind'
 
-- Electric meter virtual sensor ID (from Setup —> Devices —> Idx number of the dumme device)
-- meter_id = 356 

------------------------------------------------------------------------------
commandArray = {}

if (devicechanged[status_blinds]) then
    
-- Retrieve the previous status
    prev_status = uservariables['varBlind']
-- Retrieve the current value
    read_status = otherdevices_svalues[status_blinds]
-- Difference to move between previous and new target value
    if (read_status > prev_status) then
        target_status = read_status - prev_status
        -- convert to seconds
        target_status = target_status * 0.12
        --- REALLY NEED HELP HERE
        commandArray[] = {[UpdateDevice'] = realWindow OPEN for target_status seconds
        commandArray[] = {[UpdateDevice'] = realWindow stop
        prev_status = target_status
    elseif
        target_status = prev_status - target_status
        -- convert to seconds
        target_status = target_status * 0.12
        commandArray[] = {[UpdateDevice'] = realWindow CLOSE for target_status seconds
        commandArray[] = {[UpdateDevice'] = realWindow stop
        prev_status = target_status
    end
end

return commandArray
------------------------------------------------------------------------------
It is not finished and it is only my 2nd program in LUA but hopefully it makes sense where I want to go.
How do I tell the realWindow to open (or ON/OFF) for X seconds, and then stop.
11101101 - www.machinon.com
zicht
Posts: 272
Joined: Sunday 11 May 2014 11:09
Target OS: Windows
Domoticz version: 2023.1+
Location: NL
Contact:

Re: Best way to run an action for 20 seconds

Post by zicht »

EdddieN wrote:Sorry, highjacking this a bit.

I'm trying to do something similar, but with a % slider. I have a RF motor with RFXComm but I'm only able to do natively Open, Close and Stop.
What I would like to do is to be able to have a % slider, or at least an approximation of it. Usually to fully open or close the roller blind takes about 12 seconds, so I created a virtual percentage blind control and the following LUA code:

It is not finished and it is only my 2nd program in LUA but hopefully it makes sense where I want to go.
How do I tell the realWindow to open (or ON/OFF) for X seconds, and then stop.

this is how i did the same trick http://www.domoticz.com/forum/viewtopic ... 65#p137111
You need just a stopwatch to record the timings, i just needed almost closed (look through), half closed and open or closed,
but you can add as many as you want.

As there is no way of knowing the physical status you need to start from a open or closed point.
note 1: it is possible somebody just has send another command from a remote, so you may want to wait to make sure this is not the case.
note 2: due to weight or other physical tolerance creaters there can be a slight difference to the same point depending if you come from open or closed.

It is pretty straight forward, so i assume it will work for you also :)
Rpi & Win x64. Using : cam's,RFXCom, LaCrosse, RFY, HuE, google, standard Lua, Tasker, Waze traveltime, NLAlert&grip2+,curtains, vacuum, audioreceiver, smart-heating&cooling + many more (= automate all repetitive simple tasks)
User avatar
EdddieN
Posts: 510
Joined: Wednesday 16 November 2016 11:31
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.9700
Location: Scotland
Contact:

Re: Best way to run an action for 20 seconds

Post by EdddieN »

zicht wrote: this is how i did the same trick http://www.domoticz.com/forum/viewtopic ... 65#p137111
You need just a stopwatch to record the timings, i just needed almost closed (look through), half closed and open or closed,
but you can add as many as you want.
Thanks a lot, exactly what I needed.
11101101 - www.machinon.com
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest