Fix Viessmann API hostname and harden test propagation waits
- Update apiBase: api.viessmann.com → api.viessmann-climatesolutions.com (Viessmann renamed their IoT API host; old domain is NXDOMAIN) - Extend --test-viessmann context to 120s - Add 30s propagation wait before read-back in both Stage 3 and Restore: cloud accepts writes immediately but gateway polls on its own schedule, so GET returns the last confirmed device value with ~30s lag Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -17,7 +17,7 @@ import (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
tokenEndpoint = "https://iam.viessmann-climatesolutions.com/idp/v3/token"
|
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.
|
// tokenFile mirrors the JSON structure stored on disk.
|
||||||
|
|||||||
13
main.go
13
main.go
@@ -361,7 +361,7 @@ func computeWWBoost(fc *forecast.Result, cfg *config.Config) float64 {
|
|||||||
//
|
//
|
||||||
// Returns 0 on success, 1 on any failure.
|
// Returns 0 on success, 1 on any failure.
|
||||||
func runViessmannTest(vc *viessmann.Client) int {
|
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()
|
defer cancel()
|
||||||
|
|
||||||
pass := func(format string, args ...any) { fmt.Printf(" PASS "+format+"\n", args...) }
|
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)
|
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
|
delta := original + 1
|
||||||
step("Stage 3 — +1°C delta test (%.1f°C → %.1f°C)", original, delta)
|
step("Stage 3 — +1°C delta test (%.1f°C → %.1f°C)", original, delta)
|
||||||
if err := vc.SetDHWTemperature(ctx, delta); err != nil {
|
if err := vc.SetDHWTemperature(ctx, delta); err != nil {
|
||||||
fail("SetDHWTemperature(%.1f): %v", delta, err)
|
fail("SetDHWTemperature(%.1f): %v", delta, err)
|
||||||
// Try to restore before returning
|
|
||||||
_ = vc.SetDHWTemperature(ctx, original)
|
_ = vc.SetDHWTemperature(ctx, original)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
fmt.Println(" ...waiting 30s for cloud→gateway propagation...")
|
||||||
|
time.Sleep(30 * time.Second)
|
||||||
readback, err = vc.GetDHWTemperature(ctx)
|
readback, err = vc.GetDHWTemperature(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fail("read-back after +1°C: %v", err)
|
fail("read-back after +1°C: %v", err)
|
||||||
@@ -412,7 +415,7 @@ func runViessmannTest(vc *viessmann.Client) int {
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
if readback != delta {
|
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)
|
_ = vc.SetDHWTemperature(ctx, original)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
@@ -424,6 +427,8 @@ func runViessmannTest(vc *viessmann.Client) int {
|
|||||||
fail("restore SetDHWTemperature(%.1f): %v", original, err)
|
fail("restore SetDHWTemperature(%.1f): %v", original, err)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
fmt.Println(" ...waiting 30s for cloud→gateway propagation...")
|
||||||
|
time.Sleep(30 * time.Second)
|
||||||
readback, err = vc.GetDHWTemperature(ctx)
|
readback, err = vc.GetDHWTemperature(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fail("read-back after restore: %v", err)
|
fail("read-back after restore: %v", err)
|
||||||
|
|||||||
Reference in New Issue
Block a user