From ab5efe467fa52bb178af7e1e1e68e45bf1ff5297 Mon Sep 17 00:00:00 2001 From: andig Date: Wed, 22 Jan 2025 20:11:05 +0100 Subject: [PATCH 1/2] 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 From 8eea2e3cf79a15010de88f1865e79b7627bd9830 Mon Sep 17 00:00:00 2001 From: andig Date: Thu, 23 Jan 2025 08:25:20 +0100 Subject: [PATCH 2/2] wip --- charger/vaillant.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/charger/vaillant.go b/charger/vaillant.go index 99717ea2a7..f3b7d027cd 100644 --- a/charger/vaillant.go +++ b/charger/vaillant.go @@ -135,8 +135,6 @@ 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 @@ -144,6 +142,7 @@ func NewVaillantFromConfig(ctx context.Context, other map[string]interface{}) (a return z.CurrentRoomTemperature } + var heatingTempSensor bool if heating { system, err := conn.GetSystem(systemId) if err != nil { @@ -160,14 +159,12 @@ func NewVaillantFromConfig(ctx context.Context, other map[string]interface{}) (a return 0, err } - if heating { + switch { + case heatingTempSensor: 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 case len(system.State.DomesticHotWater) > 0: