script time triggering frequency

Moderator: leecollings

Post Reply
User avatar
knasson
Posts: 32
Joined: Sunday 02 May 2021 22:53
Target OS: Raspberry Pi / ODroid
Domoticz version: 2026-3
Location: France
Contact:

script time triggering frequency

Post by knasson »

hi,
I try to use a script time in the 2026-1 version.
as nothing happens in my script i try to look a log
to check that i use the script provided when you add a new script time.
I observe that the frequency is close to 4 minutes instead of the forecasted 1 minute.
on a raspi 4
log script time.jpg
log script time.jpg (67.93 KiB) Viewed 14382 times
the script:
commandArray = {}

print ("Time based event fired");
-- loop through all the devices
for deviceName,deviceValue in pairs(otherdevices) do
-- if (deviceName=='myDevice') then
-- if deviceValue == "On" then
-- print("Device is On")
-- elseif deviceValue == "Off" then
-- commandArray['a device name'] = "On"
-- commandArray['Scene:MyScene'] = "Off"
-- end
-- end
end

-- loop through all the variables
for variableName,variableValue in pairs(uservariables) do
-- if (variableName=='myVariable') then
-- if variableValue == 1 then
-- commandArray['a device name'] = "On"
-- commandArray['Group:My Group'] = "Off AFTER 30"
-- end
-- end
end

return commandArray
uname -a
Linux kan 6.12.75+rpt-rpi-v8 #1 SMP PREEMPT Debian 1:6.12.75-1+rpt1~bookworm (20 26-03-11) aarch64 GNU/Linux

top command

top - 16:28:13 up 7 days, 9:17, 4 users, load average: 0.31, 0.47, 0.46
Tasks: 184 total, 3 running, 181 sleeping, 0 stopped, 0 zombie
%Cpu(s): 2.2 us, 0.5 sy, 0.0 ni, 97.2 id, 0.1 wa, 0.0 hi, 0.0 si, 0.0 st
MiB Mem : 3795.8 total, 906.4 free, 591.3 used, 2388.9 buff/cache
MiB Swap: 512.0 total, 512.0 free, 0.0 used. 3204.5 avail Mem

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
241724 root 20 0 2601100 385972 23620 S 6.3 9.9 16,11 domoticz
2733480 root 20 0 36140 26112 9620 S 2.3 0.7 0:03.91 python3
2735129 root 20 0 11732 5052 2880 R 0.7 0.1 0:00.06 top
90 root 0 -20 0 0 0 I 0.3 0.0 40:23.39 kworker/u21:0-brcmf_wq/mmc1:0001:1
2728275 root 20 0 0 0 0 I 0.3 0.0 0:00.21 kworker/3:1-events_freezable
2728460 root 20 0 0 0 0 R 0.3 0.0 0:01.20 kworker/u17:0-events_unbound

what do you think?
do you use this kind of script in this version?
what i is my mistake?
User avatar
gizmocuz
Posts: 3026
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: script time triggering frequency

Post by gizmocuz »

I think you should first convert it to dzVents, even better upgrade to the latest beta and use the dzVents wizard in the Events editor to get you started
Quality outlives Quantity!
User avatar
jvdz
Posts: 2479
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: script time triggering frequency

Post by jvdz »

knasson wrote: Saturday 02 May 2026 16:34 hi,
I try to use a script time in the 2026-1 version.
-snip-
what i is my mistake?
The name of the script has to be wrong! what did name the script file?
User avatar
psubiaco
Posts: 245
Joined: Monday 20 August 2018 9:38
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Italy
Contact:

Re: script time triggering frequency

Post by psubiaco »

As "--" is used to specify a comment, you have two loops doing nothing, because you have inside the loop every line is commented.
Remove "--" or add a line like
print(deviceName .. " = " .. deviceValue)
to print name and value of each device.
Paolo
--
I use DomBus modules to charge EV car, get a full alarm system, control heat pump, fire alarm detection, lights and much more. Video
Facebook page - Youtube channel
lost
Posts: 716
Joined: Thursday 10 November 2016 9:30
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: script time triggering frequency

Post by lost »

The loops are useless, as an empty minimal framework, but the message should anyway be printed every minute... I don't know how many devices/user var could make the loops take so much time but script time period would not be the 1st issue to notice IMO!

If I run hereunder script in ~/domoticz/scripts/lua path, named (important is the script_time_XXX.lua):
script_time_test.lua

Code: Select all

commandArray = {}

print(os.date("Test Time Script at : %x - %X"))

return commandArray
I get this kind of output every mn at matching log/script exec time:

Code: Select all

$ grep "Test Time Script" /tmp/domoticz.txt 
2026-05-03 08:33:00.462  Status: LUA: Test Time Script at : 05/03/26 - 08:33:00
2026-05-03 08:34:00.462  Status: LUA: Test Time Script at : 05/03/26 - 08:34:00
2026-05-03 08:35:01.484  Status: LUA: Test Time Script at : 05/03/26 - 08:35:01
2026-05-03 08:36:00.511  Status: LUA: Test Time Script at : 05/03/26 - 08:36:00
2026-05-03 08:37:00.522  Status: LUA: Test Time Script at : 05/03/26 - 08:37:00
=> Can be a few hundred ms to ~1s late vs trigger, but that's OK.
User avatar
knasson
Posts: 32
Joined: Sunday 02 May 2021 22:53
Target OS: Raspberry Pi / ODroid
Domoticz version: 2026-3
Location: France
Contact:

Re: script time triggering frequency

Post by knasson »

Once followed the gizmocuz recommandations (update domoticz to beta version ) i found back the minute triggering...there was probably a bug in the plain version.
User avatar
knasson
Posts: 32
Joined: Sunday 02 May 2021 22:53
Target OS: Raspberry Pi / ODroid
Domoticz version: 2026-3
Location: France
Contact:

Re: script time triggering frequency

Post by knasson »

gizmocuz wrote: Saturday 02 May 2026 17:40 I think you should first convert it to dzVents, even better upgrade to the latest beta and use the dzVents wizard in the Events editor to get you started
Seem the update to beta+dzVents conversion fixes the concern.Thank you
Post Reply