Page 1 of 1
Running time script every 30 secs
Posted: Monday 30 November 2015 20:50
by void
Hi,
Anyone knows if it is possible to run the time based scripts more often?
For instance, twice per minute instead of 'only' one time?
I noticed my presence detection isn't fast enough.
Cheers.
Re: Running time script every 30 secs
Posted: Monday 30 November 2015 22:19
by Egregius
Run it by cron.
* * * * * /path/script
* * * * * sleep 30 && /path/script
Re: Running time script every 30 secs
Posted: Tuesday 01 December 2015 8:53
by void
Oh can LUA scripts be started from the shell as well?
I thought it was an interal domoticz thingy.
Re: Running time script every 30 secs
Posted: Tuesday 01 December 2015 18:25
by Egregius
Don't know about lua, I don't use that
Php does everything I want

Re: Running time script every 30 secs
Posted: Tuesday 01 December 2015 19:07
by jvdz
void wrote:Oh can LUA scripts be started from the shell as well?
I thought it was an interal domoticz thingy.
Yes you can but won't have the event tables available so need to use JSON call to request information or send commands from/to Domoticz.
Jos
Re: Running time script every 30 secs
Posted: Wednesday 02 December 2015 10:21
by void
Do you have an example Jos?
I thought it would be easyer to call a second bash script in the LUA that slept for x-seconds, but LUA is screaming in the logs that the script is running longer then 10 seconds.
Apparently that's a bad thing...
Re: Running time script every 30 secs
Posted: Wednesday 02 December 2015 11:44
by ThinkPad
I don't know how your presence detection works, but maybe you can convert the script to a 'script_device_presence.lua' instead of a 'script_time_presence.lua' ?
A script_device is ran on EVERY device update, so much faster.
Then in the script, check for your device if it has changed:
if devicechanged(['switch1234']== 'On')
rest of your script...
Re: Running time script every 30 secs
Posted: Wednesday 02 December 2015 15:39
by rimram31
Perhaps both
Having a shell script checking presence every xx s and, when happened, only setting on a domoticz dummy device so a domoticz lua script later make the rest of the job.
Re: Running time script every 30 secs
Posted: Wednesday 02 December 2015 16:45
by jvdz
void wrote:Do you have an example Jos?
I thought it would be easyer to call a second bash script in the LUA that slept for x-seconds, but LUA is screaming in the logs that the script is running longer then 10 seconds.
Apparently that's a bad thing...
You could look at the scripts that simon (and me for the menu extension) build for DTGBOT. (
https://www.domoticz.com/wiki/Remote_Co ... legram_Bot)
There are several functions in there to retrieve device status and set devices.
Jos
Re: Running time script every 30 secs
Posted: Thursday 03 December 2015 8:44
by void
ThinkPad wrote:I don't know how your presence detection works, but maybe you can convert the script to a 'script_device_presence.lua' instead of a 'script_time_presence.lua' ?
A script_device is ran on EVERY device update, so much faster.
Then in the script, check for your device if it has changed:
if devicechanged(['switch1234']== 'On')
rest of your script...
It's this one
viewtopic.php?f=23&t=5256
Every <time based, so 1 minute> the LUA runs arp-scan and updates the dummy switches.
Perhaps changing to a device script might work, I'll check it out.
Thanks!
Re: Running time script every 30 secs
Posted: Thursday 03 December 2015 11:56
by void
It works in basic, but it's running multiple times simultainiously now.
Log:
2015-12-03 11:42:25.233 LUA: SGS6; now:2015-12-03 11:42:24; last seen: 2015-12-03 11:39:23
2015-12-03 11:42:25.235 EventSystem: Script event triggered: /home/pi/domoticz/scripts/lua/script_device_Presence.lua
2015-12-03 11:42:26.403 LUA: SGS6; now:2015-12-03 11:42:25; last seen: 2015-12-03 11:39:23
2015-12-03 11:42:26.405 EventSystem: Script event triggered: /home/pi/domoticz/scripts/lua/script_device_Presence.lua
2015-12-03 11:42:27.564 EventSystem: Script event triggered: /home/pi/domoticz/scripts/lua/script_device_Presence.lua
2015-12-03 11:42:27.572 LUA: *** No trusted phones connected to wireless, enabling alarm and turning off lights ***
2015-12-03 11:42:27.764 EventSystem: Script event triggered: /home/pi/domoticz/scripts/lua/script_device_Arm.lua
2015-12-03 11:42:26.414 (DUMMY) Lighting 1 (SGS6)
2015-12-03 11:42:28.934 EventSystem: Script event triggered: /home/pi/domoticz/scripts/lua/script_device_Presence.lua
2015-12-03 11:42:30.134 EventSystem: Script event triggered: /home/pi/domoticz/scripts/lua/script_device_Presence.lua
2015-12-03 11:42:30.142 LUA: *** No trusted phones connected to wireless, enabling alarm and turning off lights ***
2015-12-03 11:42:30.289 EventSystem: Script event triggered: /home/pi/domoticz/scripts/lua/script_device_Arm.lua
2015-12-03 11:42:28.942 (DUMMY) Lighting 1 (SGS6)
As you can see the detection of the phone (Device name is SGS6) gets triggered twice, with 200ms apart.
This results in a double notification from the Telegram bot and other triggers such as turning off all the lights being executed two times right after eachother.