diff --git a/internal/viessmann/client.go b/internal/viessmann/client.go index 6d40274..bc52175 100644 --- a/internal/viessmann/client.go +++ b/internal/viessmann/client.go @@ -17,7 +17,7 @@ import ( const ( tokenEndpoint = "https://iam.viessmann-climatesolutions.com/idp/v3/token" - apiBase = "https://api.viessmann.com/iot/v2" + apiBase = "https://api.viessmann-climatesolutions.com/iot/v2" ) // tokenFile mirrors the JSON structure stored on disk. diff --git a/main.go b/main.go index e595527..df498f4 100644 --- a/main.go +++ b/main.go @@ -361,7 +361,7 @@ func computeWWBoost(fc *forecast.Result, cfg *config.Config) float64 { // // Returns 0 on success, 1 on any failure. func runViessmannTest(vc *viessmann.Client) int { - ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) + ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second) defer cancel() pass := func(format string, args ...any) { fmt.Printf(" PASS "+format+"\n", args...) } @@ -396,15 +396,18 @@ func runViessmannTest(vc *viessmann.Client) int { } pass("round-trip confirmed (%.1f°C)", readback) - // Stage 3: +1°C delta — heat pump won't notice (5°C hysteresis), but API change is visible + // Stage 3: +1°C delta — heat pump won't notice (5°C hysteresis), but API change is visible. + // The Viessmann cloud queues the write to the gateway; the GET endpoint returns the last + // *confirmed* device value, so we wait up to 30s for the change to propagate. delta := original + 1 step("Stage 3 — +1°C delta test (%.1f°C → %.1f°C)", original, delta) if err := vc.SetDHWTemperature(ctx, delta); err != nil { fail("SetDHWTemperature(%.1f): %v", delta, err) - // Try to restore before returning _ = vc.SetDHWTemperature(ctx, original) return 1 } + fmt.Println(" ...waiting 30s for cloud→gateway propagation...") + time.Sleep(30 * time.Second) readback, err = vc.GetDHWTemperature(ctx) if err != nil { fail("read-back after +1°C: %v", err) @@ -412,7 +415,7 @@ func runViessmannTest(vc *viessmann.Client) int { return 1 } if readback != delta { - fail("+1°C mismatch: wrote %.1f, read back %.1f", delta, readback) + fail("+1°C mismatch: wrote %.1f, read back %.1f after 30s — gateway may be offline or propagation takes longer", delta, readback) _ = vc.SetDHWTemperature(ctx, original) return 1 } @@ -424,6 +427,8 @@ func runViessmannTest(vc *viessmann.Client) int { fail("restore SetDHWTemperature(%.1f): %v", original, err) return 1 } + fmt.Println(" ...waiting 30s for cloud→gateway propagation...") + time.Sleep(30 * time.Second) readback, err = vc.GetDHWTemperature(ctx) if err != nil { fail("read-back after restore: %v", err)