This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Dim up /down on a specifik time
#1
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
Reply
#2
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
Reply
#3
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
Reply
#4
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
Reply
#5
(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
Reply


Forum Jump: