Store a Value and use it for a calc - 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: Store a Value and use it for a calc (/showthread.php?tid=5707) |
Store a Value and use it for a calc - Tuwat47 - 25.10.2024 Hello Community, I'm writing for asking help about how to store a value inside a GA and use it as reference for a calculation. To be more clear I expose my real case: I've the value of energy consumption measured by a meter. I need to calculate the energy consumption of the last month so I think I'd need to store the value of the previous month in variable and make a subtraction from the actual value. Code: Electrical_Consumption_Now = ("32/1/100")-- amount of energy measured by the meter Hope someone can help me. Thanks RE: Store a Value and use it for a calc - Daniel - 25.10.2024 Well you can create a virtual object and write value to it or use storage in script(see helpers). Another solution to the task is to make a trend for your energy object and fetch value from it: https://kb.logicmachine.net/libraries/trends/ RE: Store a Value and use it for a calc - Tuwat47 - 25.10.2024 (25.10.2024, 13:15)Daniel Wrote: Well you can create a virtual object and write value to it or use storage in script(see helpers). Thanks Daniel. I need your help once again if you're available. Using trends I can store data and this is ok. How can I call back the data for example at 31/10/2024 and use it in a calc? Based on my task, I should be able to use the data stored a 31/10/24 at 23:59 inside the variable "Electrical_Consumption_previous_month" and execute my calc. Are you agree with me? Can you suggest me how to do that? Thanks RE: Store a Value and use it for a calc - Daniel - 25.10.2024 You cannot look in to the future, not yet What is the period you want the data for? RE: Store a Value and use it for a calc - Tuwat47 - 25.10.2024 (25.10.2024, 15:00)Daniel Wrote: You cannot look in to the future, not yet I tought LM was able to divine the future Sorry Daniel my was only an example. I need to store data from now to indefinite date. I use this data for a script you have already seen this morning. The first day of every month I need to send an email to my customer using LM (I already know how to do it) where I show him the consumption of the month that has just ended. For achieve this result I need to subtract the energy at the beginning of the month from the energy at the end of the month. Hope to be clear in this post. I'm sure it will be useful for a lot of newbie users like me. RE: Store a Value and use it for a calc - Daniel - 25.10.2024 See this, you can modify this to your need. https://forum.logicmachine.net/showthread.php?tid=592&pid=31881#pid31881 |