Logic Machine Forum
Dim up /down on a specifik time - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: Dim up /down on a specifik time (/showthread.php?tid=5198)



Dim up /down on a specifik time - TimmiA - 11.01.2024

Hello everyone.
I have searched the library and cant seem to find the matching script needed.

I need af script for controlling some lights over some fish tanks.
I am thinking that E.G. at 7 am i have scheduled script wich will write a 1% into a gr.add (1/1/1) 
and then after 3 seconds it will raise my gr.addr (1/1/1) with 1% again and so on until til hits my wished end point at 80% 

I also need the opposite script at E.G. 10 am the lights will shut down again.
Starting from former 80% end point and dimming down 1% every 3 seconds til we hit the big zero.

anyone who is up for the task of helping me?
Thank you in advance

Timmi Andersen
Denmark


RE: Dim up /down on a specifik time - Erwin van der Zwart - 11.01.2024

Just create 2 scheduled script at the desired times and use this:
Code:
-- UP
output = '1/1/1'
for i = grp.getvalue(output) + 1, 80, 1 do
  grp.write(output, i)
  os.sleep(3)
end
 
 
-- DOWN
output = '1/1/1'
for i = grp.getvalue(output) - 1, 0, -1 do
  grp.write(output, i)
  os.sleep(3)
end



RE: Dim up /down on a specifik time - RomansP - 11.01.2024

Hello Timmi !

You will need two scheduled scripts - one for turning ON , second for turning OFF

For turning on
Minute 0
Hour 7
Day of the month *
Month of the year - every month
Day of the week - every day
active (should be checked)

And here is a script for turning ON
Code:
local light_tank_addr = '1/1/1' -- should be scale object

local value = grp.getvalue(light_tank_addr)

while value < 80 do
  grp.write(light_tank_addr, value + 1)
  os.sleep(3)
  value = grp.getvalue(light_tank_addr)
end

For turning off
Minute 0
Hour 10
Day of the month *
Month of the year - every month
Day of the week - every day
active (should be checked)

And here is a script for turning OFF
Code:
local light_tank_addr = '1/1/1' -- should be scale object

local value = grp.getvalue(light_tank_addr)

while value > 0 do
  grp.write(light_tank_addr, value - 1)
  os.sleep(3)
  value = grp.getvalue(light_tank_addr)
end



RE: Dim up /down on a specifik time - Erwin van der Zwart - 11.01.2024

Also possible but then i would change 
Code:
value = grp.getvalue(light_tank_addr)

into

value = value + 1 and value = value - 1
This way you don't execute grp.getvalue() every step


RE: Dim up /down on a specifik time - TimmiA - 12.01.2024

(11.01.2024, 15:47)Erwin van der Zwart Wrote: Just create 2 scheduled script at the desired times and use this:
Code:
-- UP
output = '1/1/1'
for i = grp.getvalue(output) + 1, 80, 1 do
  grp.write(output, i)
  os.sleep(3)
end
 
 
-- DOWN
output = '1/1/1'
for i = grp.getvalue(output) - 1, 0, -1 do
  grp.write(output, i)
  os.sleep(3)
end

Hi Erwin. 
That worked wonders. Thank You.  Big Grin

(12.01.2024, 08:47)TimmiA Wrote:
(11.01.2024, 15:47)Erwin van der Zwart Wrote: Just create 2 scheduled script at the desired times and use this:
Code:
-- UP
output = '1/1/1'
for i = grp.getvalue(output) + 1, 80, 1 do
  grp.write(output, i)
  os.sleep(3)
end
 
 
-- DOWN
output = '1/1/1'
for i = grp.getvalue(output) - 1, 0, -1 do
  grp.write(output, i)
  os.sleep(3)
end

Hi Erwin. 
That worked wonders. Thank You.  Big Grin
OK so i wanted to make it a bit more usable with changeable inputs.
Can i get a rewrite on this?

-- get value of object with group address 1/1/1
value_sek = grp.getvalue('32/1/4')
value_niv = grp.getvalue('32/1/5')
value_end = grp.getvalue('32/1/3')
start = grp.getvalue('32/1/1')

if start == true then
 
-- UP
output = '32/1/2'
for i = grp.getvalue(output) 'value_niv', 'value_end', 1 do
  grp.write(output, i)
  os.sleep('value_sek')
end

Thank You in advance