04.03.2020, 14:59
Hi!
I am new to Lua and Logic Machine 4 (I do not have LM5), but trying to learn.
I have a question I hope someone can help me with.
I want to controll heating loads in my house, by turning these on and off to reduce peak power.
I therefore need to define constants and variables that all scripts (resident, event and in user library) can find, I belive these are called "global".
I belive the declaration of the constants and variables can be written like this:
------------------Constants in the system (temperatures) ---------------------
T_s={
comfort={kitchen=22, bathroom=24, hall=20},
save={kitchen=18, bathroom=20, hall=18}
}
--------Declaration of the variables in the system -----------
loads={
vb={k=5, room='bathroom', ad='2/0/5', B=0, P=3000},
vk={k=4, room='bathroom', ad='11/0/0' ,B=1, P=60, T=T_test.bathroom},
po={k=3, room='kitchen', ad='11/0/4', B=0, P=800, T=T_test.kitchen},
vf_gang={k=2, room='hall', ad='2/0/6', B=0, P=860, T=T_test.hall},
vf_kj={k=1, room='kitchen', ad='11/0/2', B=0, P=15, T=T_test.kitchen}
}
I have read something about storage.set(), but is this the only way to do it? If so, in what script? And I am going to use these values a lot, will I always have to write storage.get()?
Or can I make a library in User Library and just define all constants and variables like above, and then they are "global"?
Thank you for all help!
I am new to Lua and Logic Machine 4 (I do not have LM5), but trying to learn.
I have a question I hope someone can help me with.
I want to controll heating loads in my house, by turning these on and off to reduce peak power.
I therefore need to define constants and variables that all scripts (resident, event and in user library) can find, I belive these are called "global".
I belive the declaration of the constants and variables can be written like this:
------------------Constants in the system (temperatures) ---------------------
T_s={
comfort={kitchen=22, bathroom=24, hall=20},
save={kitchen=18, bathroom=20, hall=18}
}
--------Declaration of the variables in the system -----------
loads={
vb={k=5, room='bathroom', ad='2/0/5', B=0, P=3000},
vk={k=4, room='bathroom', ad='11/0/0' ,B=1, P=60, T=T_test.bathroom},
po={k=3, room='kitchen', ad='11/0/4', B=0, P=800, T=T_test.kitchen},
vf_gang={k=2, room='hall', ad='2/0/6', B=0, P=860, T=T_test.hall},
vf_kj={k=1, room='kitchen', ad='11/0/2', B=0, P=15, T=T_test.kitchen}
}
I have read something about storage.set(), but is this the only way to do it? If so, in what script? And I am going to use these values a lot, will I always have to write storage.get()?
Or can I make a library in User Library and just define all constants and variables like above, and then they are "global"?
Thank you for all help!