Posts: 303
Threads: 87
Joined: May 2017
Reputation:
2
I am looking for a script that i can use to send a value every xx minutes.
Found this that could work. But this is once, and i need it to resend for example every 30 minutes to pulse an output.
Could anyone help me with such a script.
Code: -- group address or name
addr = '1/1/1'
-- find required object
obj = grp.find(addr)
-- object exists and current state is "on"
if obj and obj.data then
-- delta is in seconds
delta = os.time() - obj.updatetime
-- switch off when timer expires
if delta >= 50 * 60 then
grp.write(addr, false)
end
end
Posts: 1764
Threads: 6
Joined: Jul 2015
Reputation:
117
Hi,
Just create a resident script at 0 and insert this:
Code: grp.write('1/1/1', true)
os.sleep(1800)
BR,
Erwin
Posts: 303
Threads: 87
Joined: May 2017
Reputation:
2
(06.04.2020, 21:34)Erwin van der Zwart Wrote: Hi,
Just create a resident script at 0 and insert this:
Code: grp.write('1/1/1', true)
os.sleep(1800)
BR,
Erwin
That simple..
I need a 0 in between, so i duplicated the scripts. But after testing, i guess this is not the correct way.
Code: grp.write('32/1/1', true)
os.sleep(65)
grp.write('32/1/1', false)
os.sleep(70)
Posts: 265
Threads: 37
Joined: Apr 2019
Reputation:
4
Code: --Set temperature
Tc = '11/0/5' -- 09.001 Temperature (2Bytes)
--Reference Temperature
TRef = '11/0/20' -- 09.001 Temperature (2Bytes)
--Output object that enables resident script
addr = '11/0/32' --01. 1 bit (boolean)
--Countdown in days
RstDays = '11/0/31' --1 Bytes unsigned integer
--Countdown in hours
RstHours = '11/0/30' --1 Bytes unsigned integer
----------------------------------------------------------------------
-- find required object
obj = grp.find(addr)
-- object exists and current state is "on"
if obj and obj.data then
-- delta is in seconds
delta = os.time() - obj.updatetime
-- switch off when timer expires
if delta >= (((grp.getvalue(RstDays)*60)*24) + (grp.getvalue(RstHours)*60)) * 60 then
grp.write(addr, false)
grp.write(Tc, grp.getvalue(TRef))
end
end
Hello, I modified this script to reset the temperature of a pool. How can I embed a 250 Byte String object for the remaining time state?
Posts: 7758
Threads: 42
Joined: Jun 2015
Reputation:
447
This will send a string like 1d 4h 3m to 1/1/1:
Code: delta = os.time() - obj.updatetime
timeout = ((RstDays) * 24 + (RstHours)) * 60 * 60
remaining = math.max(0, delta - timeout)
days = math.floor(remaining / 86400)
hours = math.floor((remaining % 86400) / 3600)
minutes = math.floor((remaining % 3600) / 60)
txtremaining = days .. 'd ' .. hours .. 'h ' .. minutes .. 'm'
grp.update('1/1/1', txtremaining)
-- switch off when timer expires
if remaining == 0 then
grp.write(addr, false)
grp.write(Tc, grp.getvalue(TRef))
end
Posts: 265
Threads: 37
Joined: Apr 2019
Reputation:
4
(25.01.2021, 09:08)admin Wrote: This will send a string like 1d 4h 3m to 1/1/1:
Code: delta = os.time() - obj.updatetime
timeout = ((RstDays) * 24 + (RstHours)) * 60 * 60
remaining = math.max(0, delta - timeout)
days = math.floor(remaining / 86400)
hours = math.floor((remaining % 86400) / 3600)
minutes = math.floor((remaining % 3600) / 60)
txtremaining = days .. 'd ' .. hours .. 'h ' .. minutes .. 'm'
grp.update('1/1/1', txtremaining)
-- switch off when timer expires
if remaining == 0 then
grp.write(addr, false)
grp.write(Tc, grp.getvalue(TRef))
end
Hello Admin, something is not right since the account is ascending.
Posts: 7758
Threads: 42
Joined: Jun 2015
Reputation:
447
Try changing "delta - timeout" calculation in line 3 to "timeout - delta"
Posts: 265
Threads: 37
Joined: Apr 2019
Reputation:
4
26.01.2021, 10:54
(This post was last modified: 27.01.2021, 07:36 by davidchispas.)
(25.01.2021, 17:04)admin Wrote: Try changing "delta - timeout" calculation in line 3 to "timeout - delta"
Code: --Set temperature
Tc = '11/0/5' -- 09.001 Temperature (2Bytes)
--Reference Temperature
TRef = '11/0/20' -- 09.001 Temperature (2Bytes)
--Output object that enables resident script
addr = '11/0/32' --01. 1 bit (boolean)
--Countdown in days
RstDays = '11/0/31' --1 Bytes unsigned integer
--Countdown in hours
RstHours = '11/0/30' --1 Bytes unsigned integer
----------------------------------------------------------------------
obj = grp.find(addr)
if obj and obj.data then
delta = os.time() - obj.updatetime
timeout = (grp.getvalue(RstDays) * 24 + grp.getvalue(RstHours)) * 60 * 60
remaining = math.max(0, timeout - delta)
days = math.floor(remaining / 86400)
hours = math.floor((remaining % 86400) / 3600)
minutes = math.floor((remaining % 3600) / 60)
txtremaining = days .. 'd ' .. hours .. 'h ' .. minutes .. 'm '
grp.checkupdate('11/0/33', txtremaining)
-- switch off when timer expires
if remaining == 0 then
grp.write(addr, false)
grp.write(Tc, grp.getvalue(TRef))
end
end
Ok thanks, that's how it works. I want to get the counter reset to 0 when 'Tc' == 'TRef'. What can I add to the script?
This script runs every 1 second to be immediate, but the timer status sends it every second, I changed it to check.uptade to correct that. My question is if it is better like this or run it every 60 seconds ....?
To take advantage of this script to other functions, can I add seconds? I have tried but without positive result.
Posts: 265
Threads: 37
Joined: Apr 2019
Reputation:
4
27.01.2021, 08:47
(This post was last modified: 27.01.2021, 08:50 by davidchispas.)
Hello, a very strange thing happens to me and I cannot find an explanation.
With this script I send the time status of the countdown (I had to change the data type to '14 bytes ASCII string 'to be able to view it on a KNX screen.
The rest of the objects work perfectly and are displayed on the KNX bus, but the 14-byte object, when updated (it is perfectly green) in LM, is not sent to the bus and is not reflected on my screen. But if I send the value manually from the LM configuration panel, it is sent, also if I make a status request.
Where can the error be?
Posts: 7758
Threads: 42
Joined: Jun 2015
Reputation:
447
Change checkupdate to checkwrite, update does not send to the TP bus.
For seconds use this:
Code: seconds = remaining % 60
txtremaining = days .. 'd ' .. hours .. 'h ' .. minutes .. 'm ' .. seconds .. 's'
Posts: 265
Threads: 37
Joined: Apr 2019
Reputation:
4
(27.01.2021, 08:50)admin Wrote: Change checkupdate to checkwrite, update does not send to the TP bus.
For seconds use this:
Code: seconds = remaining % 60
txtremaining = days .. 'd ' .. hours .. 'h ' .. minutes .. 'm ' .. seconds .. 's'
Ah okay, I did not know this information. Thank you very much for your help!
|