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.

Store a Value and use it for a calc
#1
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

Electrical_Consumption_previous_month = ....

Electrical_Consumption_calculated = Electrical_Consumption_Now - Electrical_Consumption_previous_month

grp.write(32/1/101, Electrical_Consumption_Calculated)

Hope someone can help me.

Thanks
Reply
#2
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/
------------------------------
Ctrl+F5
Reply
#3
(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).
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/

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
Reply
#4
You cannot look in to the future, not yet Smile
What is the period you want the data for?
------------------------------
Ctrl+F5
Reply
#5
(25.10.2024, 15:00)Daniel Wrote: You cannot look in to the future, not yet Smile
What is the period you want the data for?

I tought LM was able to divine the future Big Grin

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.
Reply
#6
See this, you can modify this to your need.
https://forum.logicmachine.net/showthrea...1#pid31881
------------------------------
Ctrl+F5
Reply


Forum Jump: