Skip to content

Commit

Permalink
Vaillant: add heating zone temperature
Browse files Browse the repository at this point in the history
  • Loading branch information
andig committed Jan 22, 2025
1 parent 904d95c commit ab5efe4
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion charger/vaillant.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ab5efe4

Please sign in to comment.