Sliding average dummy device

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
gibbon_
New user
Posts: 9
Joined: 08 Aug 2016, 11:38
Location: Germany

Sliding average dummy device

#1 Post by gibbon_ » 09 Aug 2016, 15:56

Hi,

for measuring values over a certain time and averaging them, I would find it useful to have a dummy device that takes the last X values one sends to it and represents the average over these values.
Best case:
  • X is configurable (i am thinking about 2-16 values)
    Only set values are taken into account (and unset values are ignored)
Do any such efforts exist? Did anyone hack this already? I was trying to use custom events and the values of several dummy devices, but did not manage to get to a usable solution yet.

I know that normally this kind of job would be done by a central home automation system, but I am trying to avoid this as much as possible. I am trying to use this for building an room activity meter (using several PIR sensors) that sanitizes the values measured in the ESP and output a calculated result value.

User avatar
jsilver
Normal user
Posts: 23
Joined: 24 May 2016, 14:45
Location: Lewes, UK
Contact:

Re: Sliding average dummy device

#2 Post by jsilver » 09 Aug 2016, 16:13

This sort of thing might certainly find uses. Even if you have a central machine doing processing of raw data, it's often useful to use local horsepower to do simple smoothing, deadband processing, deduping, exception filtering, rate of change calculations, hysteresis or other operations on the raw data before forwarding it.

gibbon_
New user
Posts: 9
Joined: 08 Aug 2016, 11:38
Location: Germany

Re: Sliding average dummy device

#3 Post by gibbon_ » 09 Aug 2016, 16:33

Agreed.

In this case it would be to do thresholding and filtering of unreliable input. As you said: We have the cycles, why not put them to good use. :)

lyndondr
Normal user
Posts: 12
Joined: 20 Aug 2018, 22:03

Re: Sliding average dummy device

#4 Post by lyndondr » 13 Nov 2018, 21:55

I'm also looking for a moving or sliding average function also. Is this possible in the Rules and Custom Variables possibly?

User avatar
toffel969
Normal user
Posts: 469
Joined: 03 Jan 2017, 10:58
Location: Germany

Re: Sliding average dummy device

#5 Post by toffel969 » 14 Nov 2018, 09:38

lyndondr wrote: 13 Nov 2018, 21:55 I'm also looking for a moving or sliding average function also. Is this possible in the Rules and Custom Variables possibly?
Ya it sure is, you can use rules and dummy devices to do that.
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8

lyndondr
Normal user
Posts: 12
Joined: 20 Aug 2018, 22:03

Re: Sliding average dummy device

#6 Post by lyndondr » 14 Nov 2018, 19:59

toffel969 wrote: 14 Nov 2018, 09:38
lyndondr wrote: 13 Nov 2018, 21:55 I'm also looking for a moving or sliding average function also. Is this possible in the Rules and Custom Variables possibly?
Ya it sure is, you can use rules and dummy devices to do that.
Do you have any examples you can post?

Domosapiens
Normal user
Posts: 307
Joined: 06 Nov 2016, 13:45

Re: Sliding average dummy device

#7 Post by Domosapiens » 15 Nov 2018, 01:06

Not a real moving average (FIFO), but an approximation.
Simplified (understandable) version of my hourly and daily temperature averaging.
(with thanks to my '80 teacher Digital Filtering, Prof. Dr. Hermann, of the University Twente)

Assumption:
1 sample per 10 min

Hour filter length=6
Define a Dummy task <x>, AV_hour
Val1: published Average
Val2: calculated Average
Val3: newest sample

Rule for hour filter:
On newest_sample Do
Taskvalueset,x,3,%eventvalue% //store newest 1/6th hour sample
Taskvalueset,x,2,(([AV_hour#Val3]*0.166)+([AV_hour#Val1]*0.833)) //take 1/6th of the new value plus 5/6th of the published hour value
Taskvalueset,x,1,[AV_hour#Val2] //promote the calculated Avarage to the published Average
EndOn

Day filter length=144
Define a Dummy task <y>, AV_day
Val1: published Average
Val2: calculated Average
Val3: newest sample

Rule for day filter:
On newest_sample Do
Taskvalueset,x,3,%eventvalue% //store newest 1/6th hour sample
Taskvalueset,x,2,(([AV_day#Val3]*0.0.006)+([AV_day#Val1]*0.0.993)) //take 1/6*1/24th of the new value plus 143/144*th of the published day value
Taskvalueset,x,1,[AV_day#Val2] //promote the calculated Avarage to the published Average
EndOn

For faster filter run-in give the published Average (Val1) a reasonable start value in the mid of the expected range.
For outside temperature .. say 10 degrees C.

On System#Boot Do
"initiate values"
EndOn


With the latest possibilities, you could use (I think):

On Time#Initialized Do
TaskRun <sensortask> //force first reading
"store first reading as published Average"
EndOn
30+ ESP units for production and test. Ranging from control of heating equipment, flow sensing, floor temp sensing, energy calculation, floor thermostat, water usage, to an interactive "fun box" for my grandson. Mainly Wemos D1.

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 30 guests