Averaging

I've searched and searched the forum and every post leads me to @Cobra's Average All App, which unfortunately like all the others is no longer available.

Is anyone else able to do averaging of sensors (particular temp sensors) with Rule Machine or any other app/method? If so, could you point me to how?

3 Likes

The best way to do this is with a small custom app. RM could do it, but it would be very clumsy. The way the app would work is to subscribe to each of the sensors, and when any of them report, recompute the average by just grabbing all of the sensor values, add and divide. The app would create a virtual sensor, stuff the average value in it. I will write this up and share it in a while...

4 Likes

That is exactly what I'm looking for. I'm replacing my Ecobee that averages 3 remote sensors with the Thermostat, with the Zen Zigbee thermostat, and want a single virtual device that is an average of all my temp sensors so that I can use to control my thermostat set point.

Thank you for doing that.

15 Likes

Give the app a name, and the device it creates will have that same name. Then, you can use that device anywhere you would use a temperature sensor, but it's value will be the average of all of the selected sensors. I think it works, but I've only tested it for a few minutes.

4 Likes

Bruce,

This would be a nice example app to add to the Hubitat Public GitHub.

3 Likes

Damn that was fast, I'll give it a try. Thanks again!

1 Like

There's one small bug, with naming the app. Will fix in a minute.

I'm guessing this is what you meant by "Give the app a name" ?
app

I'm not sure how to do that I'm completely code illiterate

No, that's not what I meant. Recopy the source above, make sure you get all of it. Then paste it into the new app window.

Ok, got it. I guess it didn't copy complete last time

Do it once more, just fixed the fix..... Thus is realtime code development...

4 Likes

Perfect, seems to work great......it does have a LOT of digits after the decimal, but I doubt that matters any and should work just fine. Thank you!

Yeah, the digits after decimal point make no difference. It's just the math works out that way...

2 Likes

Bruce,

Thanks for the example! I'm currently doing this in RM using LV and Variable Math for Average Temperature, Average Relative Humidity, and Average Lux. You are correct that while it works it is VERY "clumsy".

Would rounding the resulting value be difficult? I use the value in Dashboard and kind of looks ugly with all the decimal places. Also, I'm guessing this could be adapted to RH and Lux too?

It simultaneously averages illuminance, temperature and humidity from a collection of Omni/Multisensors into a Virtual multisensor. It's a parent/child app so you can have multiple. I have 3 running: Upstairs, downstairs and 'everywhere.'

18%20PM10%20PM

Temp in my dashboard vertically, LUX in another dashboard, horizontally. :smiley:

The math behind it is different also.. it's a rolling, weighted average. Pick a number between 10 and 200. 10 samples weighed is a 'rapid' average.. where the latest number has a bigger effect. 200 is a 'slow' average where it takes a lot of sequential, similar values to move the average.

6 Likes

There you go!
I knew you'd get by without me :slight_smile:

6 Likes

Sure... but not as smoothly. :smiley:

5 Likes

Any chance that the virtual device created by Bruce's app above could in someway be recognized by HubConnect, as I'd prefer to have this app running on my remote hub instead because of how frequently this device updates from so many sensors reporting?

If not no big deal, I plan on switching my server and remote hubs sometime in the near future anyway.

I created a Custom Driver and it works fine... wanna try it? :smiley:

58%20AM

My 'trick' was to use a universal driver name I already knew was installed on the Hub. I looked at Sensors and saw I could pick from a large list: :slight_smile:

On the receiving Hub, I didn't get anything til there was an Update over on the 'real'. I manually changed it and saw it was reflected correctly.

12%20AM