SpaceLogic KNX Forum
Schneider Electric SpaceLogic KNX forum to get support and share knowledge including selection, installation and troubleshooting for spaceLYnk, Wiser for KNX, eConfigure KNX, SpaceLogic KNX Hybrid module and other topics.
Link copied. Please paste this link to share this article on your social media post.
Dear all,
I am playing a bit with HomeLYnk and have a question about scripting.
I have a resident event script getting values from iem3150. When total power reach an upper limit I want to deactivate loads in different steps. flow would be as follow:
Power limit reached
Deactivate Load 1
Wait some seconds
Refresh Power value
If power still over limit deactivate Load 2
Wait some seconds
Refresh power value
If power still over limit deactivate Load N
My question is what happens to the complete system during this wait time... are the other event scripts still running?
Other option would be to use global internal variable (that can be used in different scritps) as gate. Is it possible?
Other option then (worst one) would be to use a group address as this global variable... terrible but functional.
Thanks for hints!
Link copied. Please paste this link to share this article on your social media post.
Hello Jorge,
>> I have a resident event script getting values from iem3150:
in homeLYnk, you have 2 types of scripts:
* Resident script is cyclic script with a timer you can set: 0 to 60s
* Event script is triggerred by a value change of one or more KNX objects
According what you want I think you use a resident script (=to read IEM3150)
To build the algorithm you want to carry out I advise you to use a resident script with a timer = the minimum granularity of your algoritm (for instance 10 seconds)
and to use for your different load deactivation: a counter + a condition : if (myCounter > n) { n =0 deactivation } else { n = n + 1} => n= 5 => you go through deactivation each 50 seconds.
but if you want to use sleep(), you can; other scripts (resident or event ones) are not interrupted, still running when an other script uses sleep().
If you want to share data between 2 scripts use storage.set() in script 1 and storage.get() in script 2 => you retrieve the data in script 2 from script 1
Regards
Lionel
Link copied. Please paste this link to share this article on your social media post.
Thanks for the hint. The counter is good solution, but I still need then to wait some time as I assume code execution is much faster than the power meter to refresh the value.
Link copied. Please paste this link to share this article on your social media post.
You are right code execution may be instantaneous for instance if you have a homeLYnk only with your script.
The power meter you choose may be also 'instantaneous" (= update measurement each 1 ms).
The reason to wait in homeLYnk is the interface with the power meter you use: with IEM 3150 it is Modbus, so to avoid overloading homeLYnk Modbus stack (and you may have others Modbus slaves too), better is to read IEM 3150 each 5 seconds.
Link copied. Please paste this link to share this article on your social media post.
You can use event-script controlled by the grp.address of the power value,which is read from modbus.
When the value is updated the script is executed and you can perform your conditional actions.
Link copied. Please paste this link to share this article on your social media post.
Jorge,
if you want to use global variable, which can be used in all the scripts, you can use storage function.
--Sets new value for the given key. Old value is overwritten. Returns Boolean as the result and an optional error string.
storage.set(key, value)
--Gets value for the given key or returns default value (nilif not specified) if key is not found in the data storage.
storage.get(key, default)
There is quite detailed description of this function in the User Guide.
Create your free account or log in to subscribe to the board - and gain access to more than 10,000+ support articles along with insights from experts and peers.