feat(ui): Smooth efficiency average display using Exponential Moving Average (EMA)

Open Beginner friendly
#1,801 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Quiet
Tech stack
typescript
Domain
frontend

Research direction

Start in main/http_server/axe-os/src/app/components/home/home.component.ts, at the efficiencyAverage update and the existing calculateEfficiency calls. Trace how telemetry updates reach this component, then verify in the web interface that the displayed average uses the one-hour hashrate and remains stable while power readings fluctuate.

Written by the indexing model from the issue text.

Description

Markdown

Problem

The efficiencyAverage in the web interface currently calculates the 1-minute average (or 1-hour average when modified) by dividing the live power consumption (info.power) by the hashrate. Because info.power is updated and telemetry is fetched every second, the displayed efficiency value fluctuates rapidly by ~0.15 J/TH or more due to minor real-time power draw spikes. This causes unnecessary visual flickering in the UI for a value labeled as an "average".

Solution

This introduces a frontend-side Exponential Moving Average (EMA) filter to smooth out the real-time power fluctuations for the efficiencyAverage display.

  1. Added smoothedEfficiencyAverage to home.component.ts to persist the filtered state.
  2. Applied a 99% historical / 1% new value split (old * 0.99) + (new * 0.01) to damp out the per-second noise.
  3. Changed the backend data source for the average from hashRate_1m to hashRate_1h to provide a true, rock-solid long-term efficiency metric.
Result

The efficiency average indicator is now visually stable and reflects the true hardware performance without nervous second-by-second jumping, while still accurately adapting to frequency or voltage changes over a few minutes.

diff --git a/main/http_server/axe-os/src/app/components/home/home.component.ts b/main/http_server/axe-os/src/app/components/home/home.component.ts
index b5314a74..7a5d4cdf 100644
--- a/main/http_server/axe-os/src/app/components/home/home.component.ts
+++ b/main/http_server/axe-os/src/app/components/home/home.component.ts
@@ -175,6 +175,7 @@ export class HomeComponent implements OnInit, OnDestroy {
    public asicDomainsAmount: number = 0;
    public efficiency: number = 0;
    public efficiencyAverage: number = 0;
+   public smoothedEfficiencyAverage: number = 0;
    public expectedEfficiency: number = 0;
    public activePoolUserAddressPart: string = '';
    public activePoolUserSuffixPart: string = '';
@@ -871,12 +872,24 @@ export class HomeComponent implements OnInit, OnDestroy {
 
          this.efficiency = this.calculateEfficiency(info, 'hashRate');
          
-        // MANUELLE BERECHNUNG FÜR DEN STUNDEN-DURCHSCHNITT:
+        // BERECHNUNG MIT GEGLÄTTETEM FILTER (DÄMPFUNG)
          if (info && info.power > 0 && info.hashRate_1h > 0) {
-            // Leistung (W) geteilt durch Hashrate (GH/s umgerechnet in TH/s -> durch 1000)
-            this.efficiencyAverage = (info.power * 1000) / info.hashRate_1h;
+            const currentRawAvg = (info.power * 1000) / info.hashRate_1h;
+            
+            // Wenn der Wert zum ersten Mal berechnet wird, nimm den aktuellen Wert
+            if (this.smoothedEfficiencyAverage === 0) {
+                this.smoothedEfficiencyAverage = currentRawAvg;
+            } else {
+                // FILTER: 99% alter Wert + 1% neuer Wert. 
+                this.smoothedEfficiencyAverage = (this.smoothedEfficiencyAverage * 0.99) + (currentRawAvg * 0.01);
+            }
+            
+            // Weise den geglätteten Wert der Anzeige zu
+            this.efficiencyAverage = this.smoothedEfficiencyAverage;
          } else {
             this.efficiencyAverage = 0;
+            this.smoothedEfficiencyAverage = 0;
          }
 
         this.expectedEfficiency = this.calculateEfficiency(info, 'expectedHashrate');```
Dominant language
C
Stars
957
Forks
423
Avg merge
3d 15h
Merged PRs (30d)
19

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from bitaxeorg/ESP-Miner

All issues in bitaxeorg/ESP-Miner

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.