Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
c7c1a75
feat(health): derive a ranked issue list from the node state
Developer-Simon Dec 3, 2026
f290fb2
feat(health): report issues and level, count only installed services
Developer-Simon Dec 3, 2026
b6538e8
test(demo): keep bridges without device files alive in the fake broker
Developer-Simon Dec 3, 2026
4a944fb
refactor(settings): retire status_bar_items, the status popover shows…
Developer-Simon Dec 3, 2026
1b4cce1
refactor(settings): drop the status field chooser from settings and i…
Developer-Simon Dec 3, 2026
0c99637
feat(dashboard): one title row with a status chip that names its cause
Developer-Simon Dec 3, 2026
ce581a5
fix(dashboard): format the status chip values for the locale
Developer-Simon Dec 3, 2026
d28e19e
style(dashboard): style the title row and the status chip
Developer-Simon Dec 3, 2026
28ca2c5
test(dashboard): check that the title row never truncates
Developer-Simon Dec 3, 2026
10a1384
style(dashboard): give update, guest and example notes one slim row form
Developer-Simon Dec 3, 2026
d2cc213
feat(dashboard): slide one tab indicator to the active tab
Developer-Simon Dec 3, 2026
97f7d92
docs(dashboard): describe the status chip and bump the changed assets
Developer-Simon Dec 3, 2026
8cb0b15
style(dashboard): darken the install button on hover so its label kee…
Developer-Simon Dec 3, 2026
be61f28
feat(dashboard): show CPU temperature and load in one status row
Developer-Simon Dec 3, 2026
327b355
fix(health): warn when the storage medium reports its end of life
Developer-Simon Dec 3, 2026
c1e5e20
feat(dashboard): show the remaining storage life in the status popover
Developer-Simon Dec 3, 2026
d753b60
feat(dashboard): give the status chip a tour target
Developer-Simon Dec 3, 2026
7490abd
fix(dashboard): record the cache-bust marks for the prerelease line
Developer-Simon Dec 3, 2026
d8b31bf
chore(release): bump component versions
Dec 3, 2026
f738feb
docs(changelog): update changelogs
Dec 3, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions changelog/highlights/316.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"de": {
"*": "Kompakte Kopfzeile, deren Status-Chip die Ursache einer Störung nennt"
},
"en": {
"*": "A compact header whose status chip names the cause of a problem"
},
"tour": {
"*": {
"steps": [
{
"device": "any",
"target": "status-chip",
"text": {
"de": "Titel, Status und Sprache stehen jetzt in einer Zeile. Der Status ist grün, solange alles läuft. Bei einer Störung wird er gelb oder rot und nennt die Ursache. Ein Klick zeigt alle Werte.",
"en": "Title, status and language now share one row. The status stays green while everything runs. When something is wrong it turns yellow or red and names the cause. A click shows all values."
},
"title": {
"de": "Neue Kopfzeile",
"en": "New header"
}
}
]
}
}
}
39 changes: 39 additions & 0 deletions dashboard/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,43 @@
# Changelog

## v0.12.1-pre.1 (2026-12-03)

### Features

- **health:** derive a ranked issue list from the node state (c7c1a75)
- **health:** report issues and level, count only installed services (f290fb2)
- **dashboard:** one title row with a status chip that names its cause (0c99637)
- **dashboard:** slide one tab indicator to the active tab (d2cc213)
- **dashboard:** show CPU temperature and load in one status row (be61f28)
- **dashboard:** show the remaining storage life in the status popover (c1e5e20)
- **dashboard:** give the status chip a tour target (d753b60)
- **dashboard:** A compact header whose status chip names the cause of a problem (#316)

### Fixes

- **dashboard:** format the status chip values for the locale (ce581a5)
- **health:** warn when the storage medium reports its end of life (327b355)
- **dashboard:** record the cache-bust marks for the prerelease line (7490abd)

### Refactors

- **settings:** retire status_bar_items, the status popover shows every value (4a944fb)
- **settings:** drop the status field chooser from settings and installer (1b4cce1)

### Documentation

- **dashboard:** describe the status chip and bump the changed assets (97f7d92)

### Tests

- **dashboard:** check that the title row never truncates (28ca2c5)

### Style

- **dashboard:** style the title row and the status chip (d28e19e)
- **dashboard:** give update, guest and example notes one slim row form (10a1384)
- **dashboard:** darken the install button on hover so its label keeps contrast (8cb0b15)

## v0.12.0 (2026-12-02)

### Features
Expand Down Expand Up @@ -375,6 +413,7 @@
- **automations:** correct the learning methods after the spec check (#306) (0296218)
- **dashboard:** keep the Run at most field of the scenario editor in one row (#310) (9e29569)
- **auth:** give existing admins the network permission (#313) (5766220)
- **release:** align the cache-bust marks with main for v0.12.0 (2ad3918)
- **history:** keep proxies from compressing the event streams (#304) (0298760)
- **automations:** correct the learning feature after the full review (#296) (88f3c75)
- Monitoring names values without a role and links to the learning settings (#303) (29450b8)
Expand Down
2 changes: 1 addition & 1 deletion dashboard/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.12.0
v0.12.1-pre.1
7 changes: 4 additions & 3 deletions dashboard/cmd/dashboard/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -1565,9 +1565,10 @@ func main() {
"tailscale": cfg.ServiceInstalled("tailscale"),
"tuya": cfg.ServiceInstalled("tuya"),
},
MQTTBase: mqttBase,
NodeAgent: nodeAgent,
NodeSimulation: nodeSimPublisher,
ServiceInstalled: cfg.ServiceInstalled,
MQTTBase: mqttBase,
NodeAgent: nodeAgent,
NodeSimulation: nodeSimPublisher,
// Die API zeigt alle passenden Sensoren, ungefiltert, damit der
// MQTT-Tab sie abwaehlen kann.
EnergySensorOptions: func() []energydiscovery.OptionalSensor {
Expand Down
119 changes: 119 additions & 0 deletions dashboard/internal/httpapi/healthissues.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
package httpapi

import (
"math"
"time"

"github.com/Developer-Simon/energy-node-dashboard/internal/mqttclient"
"github.com/Developer-Simon/energy-node-dashboard/internal/nodeagent"
"github.com/Developer-Simon/energy-node-dashboard/internal/runtimecache"
"github.com/Developer-Simon/energy-node-dashboard/internal/storagehealth"
)

const (
healthCPUHotC = 80.0
healthRAMFullPct = 90.0
)

// healthIssue is one finding about the node state. Key is a catalog key the
// UI translates, Params fill its placeholders.
type healthIssue struct {
Key string `json:"key"`
Level string `json:"level"` // "warn" | "bad"
Params map[string]any `json:"params,omitempty"`
}

// healthIssueInput is the node state the issue list is derived from.
type healthIssueInput struct {
MQTT *mqttclient.Status // nil = no MQTT provider, no issue
Cache runtimecache.Status
Storage *storagehealth.Report // nil = no storage report
Telemetry *nodeagent.Telemetry // nil = no telemetry
Services []nodeagent.ServiceLiveness
Installed func(id string) bool // nil = every service installed
Window func(id string) time.Duration // nil = no grace
Uptime time.Duration
}

// collectHealthIssues returns the issues of the node state, bad ones first,
// then the warnings in table order. It never returns nil.
func collectHealthIssues(in healthIssueInput) []healthIssue {
bad := []healthIssue{}
warn := []healthIssue{}

if in.MQTT != nil && !in.MQTT.Connected {
bad = append(bad, healthIssue{Key: "mqtt_disconnected", Level: "bad"})
}
if in.Cache.Degraded() {
warn = append(warn, healthIssue{Key: "cache_error", Level: "warn"})
}
if storageWorn(in.Storage) {
warn = append(warn, healthIssue{Key: "storage_worn", Level: "warn"})
}
if in.Telemetry != nil {
if in.Telemetry.UndervoltageNow {
warn = append(warn, healthIssue{Key: "undervoltage", Level: "warn"})
}
if t := in.Telemetry.CPUTempC; t != nil && *t >= healthCPUHotC {
warn = append(warn, healthIssue{
Key: "cpu_hot",
Level: "warn",
Params: map[string]any{"value": math.Round(*t*10) / 10},
})
}
if r := in.Telemetry.RAMUsedPct; r != nil && *r >= healthRAMFullPct {
warn = append(warn, healthIssue{
Key: "ram_full",
Level: "warn",
Params: map[string]any{"value": int(math.Round(*r))},
})
}
}
for _, svc := range in.Services {
if svc.State == "active" {
continue
}
if in.Installed != nil && !in.Installed(svc.ID) {
continue
}
var window time.Duration
if in.Window != nil {
window = in.Window(svc.ID)
}
if in.Uptime < window {
continue
}
warn = append(warn, healthIssue{
Key: "service_down",
Level: "warn",
Params: map[string]any{"service": svc.ID},
})
}
return append(bad, warn...)
}

// storageWorn reports whether the medium itself says it is at the end of its
// life: pre-EOL warning or critical, or the endurance budget exceeded.
func storageWorn(r *storagehealth.Report) bool {
if r == nil || !r.Available {
return false
}
if r.PreEOL != nil && r.PreEOL.Code >= 2 {
return true
}
return r.LifeTimeA != nil && r.LifeTimeA.Code >= 11
}

// healthLevelOf returns the worst level of the issues: "bad", "warn" or "ok".
func healthLevelOf(issues []healthIssue) string {
level := "ok"
for _, i := range issues {
if i.Level == "bad" {
return "bad"
}
if i.Level == "warn" {
level = "warn"
}
}
return level
}
160 changes: 160 additions & 0 deletions dashboard/internal/httpapi/healthissues_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
package httpapi

import (
"testing"
"time"

"github.com/Developer-Simon/energy-node-dashboard/internal/mqttclient"
"github.com/Developer-Simon/energy-node-dashboard/internal/nodeagent"
"github.com/Developer-Simon/energy-node-dashboard/internal/runtimecache"
"github.com/Developer-Simon/energy-node-dashboard/internal/storagehealth"
)

func f64(v float64) *float64 { return &v }

func healthBase() healthIssueInput {
return healthIssueInput{
MQTT: &mqttclient.Status{Connected: true},
Telemetry: &nodeagent.Telemetry{CPUTempC: f64(50), RAMUsedPct: f64(40)},
Services: []nodeagent.ServiceLiveness{{ID: "apsystems", State: "active"}},
Uptime: time.Hour,
}
}

func issueKeys(issues []healthIssue) []string {
keys := make([]string, 0, len(issues))
for _, i := range issues {
keys = append(keys, i.Key)
}
return keys
}

func TestHealthIssuesEmptyWhenAllFine(t *testing.T) {
issues := collectHealthIssues(healthBase())
if issues == nil || len(issues) != 0 {
t.Fatalf("issues = %#v, want empty non-nil slice", issues)
}
if got := healthLevelOf(issues); got != "ok" {
t.Fatalf("level = %q, want ok", got)
}
}

func TestHealthIssuesMQTTDisconnectedIsBad(t *testing.T) {
in := healthBase()
in.MQTT = &mqttclient.Status{Connected: false}
issues := collectHealthIssues(in)
if len(issues) != 1 || issues[0].Key != "mqtt_disconnected" || issues[0].Level != "bad" {
t.Fatalf("issues = %+v, want [mqtt_disconnected bad]", issues)
}
if got := healthLevelOf(issues); got != "bad" {
t.Fatalf("level = %q, want bad", got)
}
}

func TestHealthIssuesOrderBadFirst(t *testing.T) {
in := healthBase()
in.MQTT = &mqttclient.Status{Connected: false}
in.Cache = runtimecache.Status{WriteError: "x"}
got := issueKeys(collectHealthIssues(in))
want := []string{"mqtt_disconnected", "cache_error"}
if len(got) != len(want) || got[0] != want[0] || got[1] != want[1] {
t.Fatalf("keys = %v, want %v", got, want)
}
}

func TestHealthIssuesThresholds(t *testing.T) {
in := healthBase()
in.Telemetry = &nodeagent.Telemetry{CPUTempC: f64(79.9), RAMUsedPct: f64(89.9)}
if issues := collectHealthIssues(in); len(issues) != 0 {
t.Fatalf("below threshold: issues = %+v, want none", issues)
}

in.Telemetry = &nodeagent.Telemetry{CPUTempC: f64(80.0), RAMUsedPct: f64(90.0)}
issues := collectHealthIssues(in)
if len(issues) != 2 {
t.Fatalf("at threshold: issues = %+v, want 2", issues)
}
if issues[0].Key != "cpu_hot" || issues[0].Level != "warn" || issues[0].Params["value"] != 80.0 {
t.Fatalf("cpu issue = %+v, want cpu_hot warn value 80", issues[0])
}
if issues[1].Key != "ram_full" || issues[1].Level != "warn" || issues[1].Params["value"] != 90 {
t.Fatalf("ram issue = %+v, want ram_full warn value 90", issues[1])
}
}

func TestHealthIssuesUndervoltage(t *testing.T) {
in := healthBase()
in.Telemetry = &nodeagent.Telemetry{CPUTempC: f64(50), RAMUsedPct: f64(40), UndervoltageNow: true}
issues := collectHealthIssues(in)
if len(issues) != 1 || issues[0].Key != "undervoltage" || issues[0].Level != "warn" {
t.Fatalf("issues = %+v, want [undervoltage warn]", issues)
}
}

func TestHealthIssuesStorageWorn(t *testing.T) {
cases := []struct {
name string
report *storagehealth.Report
want bool
}{
{"nil report", nil, false},
{"pre-eol normal", &storagehealth.Report{Available: true, PreEOL: &storagehealth.PreEOL{Code: 1}}, false},
{"pre-eol warning", &storagehealth.Report{Available: true, PreEOL: &storagehealth.PreEOL{Code: 2}}, true},
{"pre-eol critical", &storagehealth.Report{Available: true, PreEOL: &storagehealth.PreEOL{Code: 3}}, true},
{"life time 10", &storagehealth.Report{Available: true, LifeTimeA: &storagehealth.LifeTime{Code: 10}}, false},
{"life time budget exceeded", &storagehealth.Report{Available: true, LifeTimeA: &storagehealth.LifeTime{Code: 11}}, true},
{"unavailable", &storagehealth.Report{Available: false, PreEOL: &storagehealth.PreEOL{Code: 3}}, false},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
in := healthBase()
in.Storage = tc.report
issues := collectHealthIssues(in)
if !tc.want {
if len(issues) != 0 {
t.Fatalf("issues = %+v, want none", issues)
}
return
}
if len(issues) != 1 || issues[0].Key != "storage_worn" || issues[0].Level != "warn" {
t.Fatalf("issues = %+v, want [storage_worn warn]", issues)
}
})
}
}

func TestHealthIssuesSkipsUninstalledService(t *testing.T) {
in := healthBase()
in.Services = []nodeagent.ServiceLiveness{{ID: "tuya", State: "configured"}}
in.Installed = func(id string) bool { return false }
if issues := collectHealthIssues(in); len(issues) != 0 {
t.Fatalf("issues = %+v, want none", issues)
}
}

func TestHealthIssuesServiceGrace(t *testing.T) {
in := healthBase()
in.Services = []nodeagent.ServiceLiveness{{ID: "tuya", State: "configured"}}
in.Installed = func(id string) bool { return true }
in.Window = func(id string) time.Duration { return 120 * time.Second }

in.Uptime = 60 * time.Second
if issues := collectHealthIssues(in); len(issues) != 0 {
t.Fatalf("within grace: issues = %+v, want none", issues)
}

in.Uptime = 200 * time.Second
issues := collectHealthIssues(in)
if len(issues) != 1 || issues[0].Key != "service_down" || issues[0].Params["service"] != "tuya" {
t.Fatalf("after grace: issues = %+v, want service_down tuya", issues)
}
}

func TestHealthIssuesActiveServiceIsFine(t *testing.T) {
in := healthBase()
in.Services = []nodeagent.ServiceLiveness{{ID: "tuya", State: "active"}}
in.Window = func(id string) time.Duration { return 120 * time.Second }
if issues := collectHealthIssues(in); len(issues) != 0 {
t.Fatalf("issues = %+v, want none", issues)
}
}
Loading
Loading