How create scripts and trends by script ? - 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: How create scripts and trends by script ? (/showthread.php?tid=138) |
How create scripts and trends by script ? - Val - 17.11.2015 Hello, I would like to make a script that creates a new trend and a new script automatically on an event. Is there some solution with LM functions or lua to make this ? RE: How create scripts and trends by script ? - admin - 19.11.2015 Right now there's no Lua API for creating scripts and trends. Can you describe what kind of task do you have which requires this functionality? RE: How create scripts and trends by script ? - Val - 19.11.2015 (19.11.2015, 07:25)admin Wrote: Right now there's no Lua API for creating scripts and trends. Can you describe what kind of task do you have which requires this functionality? I would like to be able to select some move sensor in user interface. If a sensor is selected, a script create : > an event script that sum move's events of the sensor > a trend to give an historic of the activity I was thinking about calling the function that create the trend / script in LM interface but call it by script. But I don't know if it could be called by lua. RE: How create scripts and trends by script ? - admin - 19.11.2015 I suggest using a single script attached to object tag, this way you can dynamically add/remove objects. See this doc: http://openrb.com/docs/lua.htm#grp.addtags You can use LuaSocket http request to create new trend by sending a POST request. I'll provide an example later. RE: How create scripts and trends by script ? - Val - 20.11.2015 (19.11.2015, 13:36)admin Wrote: I suggest using a single script attached to object tag, this way you can dynamically add/remove objects. See this doc: http://openrb.com/docs/lua.htm#grp.addtags Thank you for your answer, I think I will use the POST request solution. RE: How create scripts and trends by script ? - admin - 20.11.2015 Here's an example for creating trends, don't forget to set admin password in socket.http.request: Code: require('json') RE: How create scripts and trends by script ? - Val - 22.11.2015 It works fine, Thank you RE: How create scripts and trends by script ? - buuuudzik - 28.02.2018 How to change it to other values? I want create trend with below parameters: Trend resolution: 5 minutes Resolution data: 1 year Daily data: 2 years This is the part of my script which has error 302: Code: trend = { And this is what I've logged by log(trend, res, err): Code: * arg: 1 Code: require('json') RE: How create scripts and trends by script ? - buuuudzik - 28.02.2018 First 6 trends are successfully created but another not and there is such res: Code: * arg: 2 What means "size": true? I have enought space on LM and also RAM is ~50%. I've tried also to add trend via Editor and there is such error. I didn't know that there is a limit in trends? I have only 24 trends on this LM. RE: How create scripts and trends by script ? - Daniel - 28.02.2018 Hi Trends do have a limit to make sure you will not eat whole ram. It is around 30MB or something like that. Use lower resolution or shorter period. BR RE: How create scripts and trends by script ? - buuuudzik - 28.02.2018 But it is variable because on LM-LB it is ~limitless and I also remember another LM4 and probably I had there much more than here. What is the limit or dependancy(e.g. 50% of RAM)? I will consider it on planning RE: How create scripts and trends by script ? - Daniel - 28.02.2018 This limit was implemented in latest fw I think. In the past there was no limit and we had cases when whole ram was used and device was rebooting all the times. It is around 30MB. RE: How create scripts and trends by script ? - buuuudzik - 28.02.2018 (28.02.2018, 12:03)Daniel. Wrote: This limit was implemented in latest fw I think. In the past there was no limit and we had cases when whole ram was used and device was rebooting all the times. It is around 30MB. But this is same on every LM or e.g. power version and Load Balancer has more. Could you check this? I understand that there was such need. RE: How create scripts and trends by script ? - Daniel - 28.02.2018 All devices have the same CPU now, in other words all of them are power now. Old and new devices have the same firmware. We phased out LM BL and you can't buy it anymore. We can generate new fw for them on request. In some time from now we will have new HW with even faster CPU and double the RAM. This will be nearly the same as LM BL. We could increase limit for trends then. |