GroveStreams

Calculate value at specific time of day462

micl78 private msg quote post Address this user
Hi,
I am trying to find the best way to derive a stream at 8am each day. Here is what I want to do:
A point stream "Home Occupancy" either WorkingDay or NonWorkingDay.
Run the calculation at 8am each day to decide the value, this is simple if WaterMeter Last Hour SUM > 20 & ElectricityMeter Last Hour SUM > 0.2 then WorkinDay else NonWorkingDay.

This will be used for usage events to set thresholds. High usage on working days will generate events. I will also have the ability from the event email to force Home Occupancy to NonWorkingDay, this will simply update the point stream. I think this is all doable, I just need to know how to derive Home Occupancy at 8am each day.

Thanks,
Michael.
Post 1 • IP   flag post
MikeMills private msg quote post Address this user
Sounds like you want a "Daily" Interval derived stream with Intervals that start and stop at 8:00 am.

1) Create a new Cycle. Set it to "1 Day" and set its reference date to Jan 1, 2017 8:00 am
2) Create a new Interval Stream and set its base cycle to the new 8:00 am Cycle. Do not select a Rollup Calendar
3) Setup derivation on its derivation tab.

There are a lot of details left out here. But this is how you can setup a daily calculation for a specific time.

I don't know what your dependent streams look like. Their cycles may or may not have to line up with the new cycle used in derivation.

Derivation will actually run as dependent data arrives over the course of that day so the daily value will change throughout the day as dependent data arrives during that day.
Post 2 • IP   flag post
micl78 private msg quote post Address this user
'Derivation will actually run as dependent data arrives over the course of that day so the daily value will change throughout the day as dependent data arrives during that day.'
That is a problem, as I need the value to be calculated once, at 8am. the data collected between 7 and 8 sets up the conditions for the rest of the day. Also, If i manually force the value later in the day it must not change again until 8am the following day. This is what I'm struggling to do. Is it possible to reference a particular sample, rather than just n-1, n-2 etc.. Can I specifically access the 8am 1hr sum value? for the current day?
Thanks,
Michael.
Post 3 • IP   flag post
MikeMills private msg quote post Address this user
You can write code that uses our RESTful API and do whatever you want. But, I suspect you don't want to write code that hard codes in a calculation for a specific day. You want to do it every day.

That's where derivation comes in. It can be designed to run each day.

You could have the derived stream be a regular stream and have it use the "Day" "LAST" values of the dependents. The calculation will run only after each of the dependents have samples for the current day being calculated. It will use the last values that arrived for the current day being calculated.

Once 8:00 am passes by, the next day will start being derived.

Create a derived stream and play with it to get a feel for how it is working.
Post 4 • IP   flag post
MikeMills private msg quote post Address this user
I just can't remember if the result will have a time of the beginning of the interval or the end of the interval. You still might want to use a DAY Interval stream for the derived stream.
Post 5 • IP   flag post
2581 5 5
Log in or sign up to compose a reply.
destitute