Averaging

Looks like a bug in that displayed running average.

My first thought also, but examining the virtual device event data shows:

So the app wrote the suspect running average value to the device.

@bravenel, again thanks for the app, I did a little digging, fixed the issue by initializing the state.run array after the input parameter "useRun" is changed.

Here's the edit to the initRun procedure:

def initRun() {
def temp = averageTemp()
//	if(!state.run) {
		state.run = []
		for(int i = 0; i < useRun; i++) state.run += temp
//	}
    log.info "initRun: state.run = ${state.run}"
}
1 Like

So I'm still pretty new with HE and especially with groovy code, but using the examples from @bravenel, I was able to create an app that basically sums all of my vent positions and calculates the total open vent area. My question is regarding the result, I ended up using a Virtual Illuminance sensor since it would hold larger value than a switchLevel. Everything works, but it just seems kind of hokey using an Illuminance senor, it would make more sense if their were a virtual device for a number, decimal or string? Am I missing something here?

Global Variables?

Virtual devices created and set by apps like this are somewhat an anomaly. It is, after all, a virtual device. And, devices have attributes that have such properties as number, decimal or string. So you're on your own when you are creating a "total open vent area" device. You could create a driver for that, and it could have an attribute of openVentArea, a number. That would make more sense than using an illuminance device.

Then in a Groovy app you could reference device.currentOpenVentArea as a number. Rule Machine could work with such a device using custom attribute, for triggers or conditions. If you like, I could whip up such a driver for you, and put it in our public repo. There isn't much to it: one attribute and one command (setOpenVentArea).

Check this out (don't know what unit to use for total area, sq. meter, sq. inch, etc. -- up to you):

2 Likes

This is perfect, I was going ask where I might find a simple driver example, but you already hooked me up, thanks.

I had one more question that I couldn't find a definite answer for, I was trying to define a input condition for the capability, but it looks like you can only specify one capability type on an input, is there any way around that?

input "tempSensors", "capability.xxxx and capabilty.xxxx",

input "tempSensors", "capability.*",

I'm actually looking to do the opposite, I only wanted devices with a specific set of capabilities to show up. So in this case only keen vents, which have a switch, level and battery properties. So when I select a capability of switch, level or battery I get the vents in the list but I also get devices I don't want to see. Not a big deal either way I just wanted to know if that filtering was available or not.

Edit: in response to a now deleted post.....

The app creates a new device. You can use that in Rule Machine.

1 Like

Hi is there a way to lower the minumum samples for AverageThis? Will duplicating the sensor also have the same effect? Annotation 2020-06-08 093115

AverageThis uses a completely different equation than the code discussed in this Thread.. the number of samples affects the weight on an individual sample. Too small and the equation is no longer averaging, but simply following the most recent value.

But if you want to, you may alter the RANGE numbers in line 133 of the Child app:

  input (name: "numberOption", type: "number", defaultValue: "10", range: "10..200", title: "Number of Samples to average.", description: "10 samples will be very responsive, while 200 samples is quite slow.", required: true)

thanks, I'm actually using it to average the wind speed by using global variables connected to illuminance, but i needed more recent samples so i'm trying to decrease the amount

It's little stuff like this that helps the rest of us dare to learn how to do more with HE.

1 Like

@bravenel It's been some time since I first requested this and you put it together almost instantly and works flawlessly.

Would it be to much for me to ask again for another app that instead of averaging, does an accumulation of all sensors? I'm wanting this for an total monthly energy usage dashboard icon, so that at the end of the month it adds up all of my energy meter devices and displays a total energy usage from all devices.

I'm currently using RM to reset the energy meter readings on a certain day of every month for all the energy meter devices.

1 Like

So you would select more than one sensor of a given capability, then adds all of the values, and set a virtual sensor to that sum? Which capability do you need? Which sensor value?

Yes pretty much.

I believe the dashboard "template name" is Energy Meter

Right now I have all the devices each listed seperately showing monthly totals of energy usage, would like a single total of all devices icon.

OK, I'll take a look at it. Won't be quite so fast, as I have to go out in 5 minutes for the evening. Ping me again tomorrow if I haven't responded.

2 Likes

Somewhat OT (sorry) but as Bruce is looking at this any chance of having a min/max of a group of temp/humidity sensors ?