From ab5efe467fa52bb178af7e1e1e68e45bf1ff5297 Mon Sep 17 00:00:00 2001 From: andig Date: Wed, 22 Jan 2025 20:11:05 +0100 Subject: [PATCH] Vaillant: add heating zone temperature --- charger/vaillant.go | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/charger/vaillant.go b/charger/vaillant.go index c395fd2695..99717ea2a7 100644 --- a/charger/vaillant.go +++ b/charger/vaillant.go @@ -135,14 +135,38 @@ func NewVaillantFromConfig(ctx context.Context, other map[string]interface{}) (a }, cc.Cache) } + var heatingTempSensor bool + + heatingTemp := func(zz []sensonet.StateZone) float64 { + z, _ := lo.Find(zz, func(z sensonet.StateZone) bool { + return z.Index == cc.HeatingZone + }) + return z.CurrentRoomTemperature + } + + if heating { + system, err := conn.GetSystem(systemId) + if err != nil { + return nil, err + } + heatingTempSensor = heatingTemp(system.State.Zones) > 0 + } + var temp func() (float64, error) - if !heating { + if !heating || heatingTempSensor { temp = provider.Cached(func() (float64, error) { system, err := conn.GetSystem(systemId) if err != nil { return 0, err } + if heating { + if res := heatingTemp(system.State.Zones); res > 0 { + return res, nil + } + return 0, api.ErrNotAvailable + } + switch { case len(system.State.Dhw) > 0: return system.State.Dhw[0].CurrentDhwTemperature, nil