Record Daily power consumption to Fuel Stream


#1

1) Give a description of the problem
I have a piston that records the energy from a Aeotec Energy Meter (Gen5). The issue is that it records incrementally indefinitely.

2) What is the expected behavior?
I want a piston to calculate the power used within 24 hour period (midnight to midnight) and record that to fuel stream or to a google doc or something.

3) What is happening/not happening?
I dont know where to start. How do I get the piston to record the reading at midnight so I can subtract it from next midnight so I can get the power used in that 24 hour period.

**4) Post a Green Snapshot

5) Attach any logs (From ST IDE and by turning logging level to Full)
No logs yet.


#2

Are you just looking for the statement:

image

if so it’s under the Timer action


#3

Thanks for the reply.
Not sure the timer action is what I need.
The meter value is ever increasing so I want it to record the reading at 12am and then at the next 12am find the difference between them and record that to a fuel stream.
So in the fuel stream I see the usage for that day rather than currently Id have to manually subtract yesterdays reading from todays to find the power used in the 24 hour period.


#4

I would use three variables… Maybe something like this:

Every day at 12AM
    Set variable {dataNow} to current reading
    Set variable {dataDiff} to {dataPrevious} - {dataNow}
    Wait 1 second
    Write to Fuel Stream {dataDiff}
    Set variable {dataPrevious} to {dataNow}
END EVERY

It will start returning the correct data to the fuel stream after the second midnight has passed.


#5

Thanks for that but I havent a clue what to do with that text.
Do I copy and paste it in somewhere ?
Thanks for your help but Im finding it hard to get instructions anywhere on how variables work and how to use them in webcore.
I see lots of examples of pistons but its not easy see how they are constructed.

I have 20 basic pistons but its more on an off on devices with motion or buttons but want to go to the next level but find it hard to understand or find any information.


#6

Sorry, I have over 300 pistons, so it is not smart for me to create another piston each time I try to help someone. I used text above to show the basic structure. You would still have to implement it yourself.

Of course, you usually end up learning much more this way than if I just handed you a completed piston… So it’s a win/win.


Did you follow the links to variables and variable data types?

That info, plus seeing examples from others should take you most of the way there.


Basically, you can create a local variable up top in the “define” section… but leave the initial value blank.

temp

Then, inside the body of the piston, you can write to the variables with the command “Set variable”. The variable will only change when that line of code executes.


#7

@WCmore This is what I have so far…
Not sure if its right or wrong. (more than likely its all wrong.)

The 2 I had trouble with so not sure if correct are

Set variable {dataDiff} to {dataPrevious} - {dataNow}
and
END EVERY

Couldnt find much information on subtracting one variable from another and how that was done.


#8

That is really quite good for your first attempt with variables!!

I made a few small adjustments, and added a few comments in green so you can see what is going on behind the scenes a bit…

I also added an informative log. (one line per day)
I recommend setting the logging on this piston to “Minimal”.

The one caveat is it will not start showing accurate results until the second midnight.
(It should work consistently thereafter.)


#9

Thanks for the help. You were right. By attempting it myself I now can more easily understand your edits.

So using Expressions is how to subtract 2 variables ?

What does the value 0 in the expression mean, It says Evaluating then 0. is it just the current calculated value of the “dataNow - dataPrev”


#10

It is not mandatory, but personally I prefer using Expressions most of the time.
I like how the grey box above shows the live results:

temp


The 0 is only because the piston is brand new. Once it has run once (at midnight), most of the variables will be populated, so it becomes even more helpful on future edits.
(it won’t be until the second midnight that dataPrev is accurate though)