os.execute.aftersec

Post Reply
markjgabb
Posts: 127
Joined: Wednesday 25 January 2017 0:00
Target OS: Raspberry Pi
Domoticz version: 3.8153
Location: Australia
Contact:

os.execute.aftersec

Post by markjgabb » Tuesday 21 November 2017 8:35

is there a way to get a delayed os.execute working in dzvents atm i have the following

os.execute('espeak welcome-home').afterSec(20)
but it seems to ifnore the aftersec and just runs it instantly.....
also not sure how to make longer that one word arguments os the os.execute as it will only take one word at the moment
V 3.8153 RPI 3
RFlink 334 mhz
mysensors
broadlink
wemo

dannybloe
Posts: 1088
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi
Domoticz version:
Location: Ermelo
Contact:

Re: os.execute.aftersec

Post by dannybloe » Tuesday 21 November 2017 9:11

os.execute is an os function that is not managed at all by dzVents. So no, that's not working unfortunately. Maybe you can create some bash function with an internal delay and execute that instead from your script.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.

markjgabb
Posts: 127
Joined: Wednesday 25 January 2017 0:00
Target OS: Raspberry Pi
Domoticz version: 3.8153
Location: Australia
Contact:

Re: os.execute.aftersec

Post by markjgabb » Tuesday 21 November 2017 9:12

that sounds like a likely way to do it...simple and it works :D
V 3.8153 RPI 3
RFlink 334 mhz
mysensors
broadlink
wemo

User avatar
BakSeeDaa
Posts: 514
Joined: Thursday 17 September 2015 10:13
Target OS: Raspberry Pi
Domoticz version: beta
Contact:

Re: os.execute.aftersec

Post by BakSeeDaa » Tuesday 21 November 2017 9:28

Below is an example how it can be done. This specific example calls an url using curl on a linux platform. The important thing is to release the control back to Domoticz immediately.

Code: Select all

local delay = 5
local url = 'http://somwebsite.com'
os.execute('(sleep '..delay..';curl -s "'..url..'" > /dev/null)&')
Best wishes

// บักสีดา

markjgabb
Posts: 127
Joined: Wednesday 25 January 2017 0:00
Target OS: Raspberry Pi
Domoticz version: 3.8153
Location: Australia
Contact:

Re: os.execute.aftersec

Post by markjgabb » Tuesday 21 November 2017 9:49

have used this method and its works wonderfully thanks guys for the advice......now to laugh at wifes reaction when house welcomes her home later on
V 3.8153 RPI 3
RFlink 334 mhz
mysensors
broadlink
wemo

User avatar
BakSeeDaa
Posts: 514
Joined: Thursday 17 September 2015 10:13
Target OS: Raspberry Pi
Domoticz version: beta
Contact:

Re: os.execute.aftersec

Post by BakSeeDaa » Tuesday 21 November 2017 11:51

markjgabb wrote:
Tuesday 21 November 2017 9:49
have used this method and its works wonderfully thanks guys for the advice......now to laugh at wifes reaction when house welcomes her home later on
We should not underestimate the importance of WAF for the future of home automation. ;)
Best wishes

// บักสีดา

poudenes
Posts: 279
Joined: Wednesday 08 March 2017 10:42
Target OS: Linux
Domoticz version: 3.7392
Location: Amsterdam
Contact:

Re: os.execute.aftersec

Post by poudenes » Tuesday 21 November 2017 14:49

BakSeeDaa wrote:
Tuesday 21 November 2017 9:28
Below is an example how it can be done. This specific example calls an url using curl on a linux platform. The important thing is to release the control back to Domoticz immediately.

Code: Select all

local delay = 5
local url = 'http://somwebsite.com'
os.execute('(sleep '..delay..';curl -s "'..url..'" > /dev/null)&')
What is the reason you put this a the end: > /dev/null)&
I use os.execute as well but then just the URL :

Code: Select all

os.execute('curl "http://127.0.0.1:8081/json.htm?type=command&param=setcolbrightnessvalue&idx=3&hue=18&brightness=50&iswhite=false"')
RPi3 with OSMC - RPi3 with Domoticz - Dashticz - MiLight - Nanolead Aurora - KaKu - Logitech Hamony - Nest - RFLink

User avatar
BakSeeDaa
Posts: 514
Joined: Thursday 17 September 2015 10:13
Target OS: Raspberry Pi
Domoticz version: beta
Contact:

Re: os.execute.aftersec

Post by BakSeeDaa » Tuesday 21 November 2017 15:59

poudenes wrote:
Tuesday 21 November 2017 14:49

What is the reason you put this a the end: > /dev/null)&
I use os.execute as well but then just the URL :

Code: Select all

os.execute('curl "http://127.0.0.1:8081/json.htm?type=command&param=setcolbrightnessvalue&idx=3&hue=18&brightness=50&iswhite=false"')
It's a redirection (discard) of the command output (not necessary) followed by the ampersand sign that will cause the command to run in the background. (prevents delays caused by waiting for the command to finish)
Best wishes

// บักสีดา

poudenes
Posts: 279
Joined: Wednesday 08 March 2017 10:42
Target OS: Linux
Domoticz version: 3.7392
Location: Amsterdam
Contact:

Re: os.execute.aftersec

Post by poudenes » Tuesday 21 November 2017 16:01

BakSeeDaa wrote:
Tuesday 21 November 2017 15:59
poudenes wrote:
Tuesday 21 November 2017 14:49

What is the reason you put this a the end: > /dev/null)&
I use os.execute as well but then just the URL :

Code: Select all

os.execute('curl "http://127.0.0.1:8081/json.htm?type=command&param=setcolbrightnessvalue&idx=3&hue=18&brightness=50&iswhite=false"')
It's a redirection (discard) of the command output (not necessary) followed by the ampersand sign that will cause the command to run in the background. (prevents delays caused by waiting for the command to finish)
Thanks for the "always" great help!!!. I will add them as well then :)
RPi3 with OSMC - RPi3 with Domoticz - Dashticz - MiLight - Nanolead Aurora - KaKu - Logitech Hamony - Nest - RFLink

User avatar
BakSeeDaa
Posts: 514
Joined: Thursday 17 September 2015 10:13
Target OS: Raspberry Pi
Domoticz version: beta
Contact:

Re: os.execute.aftersec

Post by BakSeeDaa » Tuesday 21 November 2017 16:44

poudenes wrote:
Tuesday 21 November 2017 16:01
Thanks for the "always" great help!!!. I will add them as well then :)
Your'e welcome. Don't forget the inner parenthesis which is crucial for it to work.
Best wishes

// บักสีดา

poudenes
Posts: 279
Joined: Wednesday 08 March 2017 10:42
Target OS: Linux
Domoticz version: 3.7392
Location: Amsterdam
Contact:

Re: os.execute.aftersec

Post by poudenes » Wednesday 22 November 2017 10:47

BakSeeDaa wrote:
Tuesday 21 November 2017 16:44
poudenes wrote:
Tuesday 21 November 2017 16:01
Thanks for the "always" great help!!!. I will add them as well then :)
Your'e welcome. Don't forget the inner parenthesis which is crucial for it to work.
So it will look like this then :)

Code: Select all

os.execute('(curl -s  "http://127.0.0.1:8081/........iswhite=false" > /dev/null)&')
RPi3 with OSMC - RPi3 with Domoticz - Dashticz - MiLight - Nanolead Aurora - KaKu - Logitech Hamony - Nest - RFLink

Nautilus
Posts: 681
Joined: Friday 02 October 2015 12:12
Target OS: Raspberry Pi
Domoticz version: beta
Location: Finland
Contact:

Re: os.execute.aftersec

Post by Nautilus » Wednesday 22 November 2017 11:48

This should be enough when you don't need the separate sleep command:

Code: Select all

os.execute('curl -s "http://127.0.0.1:8081/json.htm?type=command&param=setcolbrightnessvalue&idx=3&hue=18&brightness=50&iswhite=false" &')

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest