@@ -40,6 +40,7 @@ type Connection struct {
40
40
quickVetoSetPoint float32
41
41
quickVetoExpiresAt string
42
42
relData VaillantRelDataStruct
43
+ getSystemUpdateInterval time.Duration
43
44
}
44
45
45
46
// Global variable SensoNetConn is used to make data available in vehicle vks (not needed without vehicle vks)
@@ -61,6 +62,7 @@ func NewConnection(ebusdAddress, pvUseStrategy string, heatingZone, phases int,
61
62
conn .log = log
62
63
conn .currentQuickmode = ""
63
64
conn .quickmodeStarted = time .Now ()
65
+ conn .getSystemUpdateInterval = 2 * time .Minute
64
66
VaillantEbusConn = conn //this is not needed without vehicle vaillant-ebus_vehicle
65
67
66
68
var err error
@@ -282,7 +284,7 @@ func (c *Connection) getSystem(relData *VaillantRelDataStruct, reset bool) error
282
284
var findResult string
283
285
var convertedValue float64
284
286
285
- if ! reset && time .Now ().Add (time . Duration ( - 2 * int64 ( time . Minute )) ).Before (c .lastGetSystemAt ) {
287
+ if ! reset && time .Now ().Add (c . getSystemUpdateInterval ).Before (c .lastGetSystemAt ) {
286
288
// Use relData that are already present instead of reading current data from ebusd
287
289
return nil
288
290
}
@@ -300,13 +302,13 @@ func (c *Connection) getSystem(relData *VaillantRelDataStruct, reset bool) error
300
302
c .ebusdReadBuffer = * bufio .NewReader (c .ebusdConn )
301
303
//Getting Data for Hotwater
302
304
findResult = ""
303
- for ! slices .Contains ([]string {"off" , "auto" , "manual " , "ERR:" }, findResult ) && err == nil {
305
+ for ! slices .Contains ([]string {"off" , "auto" , "day " , "ERR:" }, findResult ) && err == nil {
304
306
findResult , err = c .ebusdRead (EBUSDREAD_HOTWATER_OPMODE , - 1 )
305
307
}
306
308
if err != nil {
307
309
return err
308
310
} else {
309
- if slices .Contains ([]string {"off" , "auto" , "manual " }, findResult ) {
311
+ if slices .Contains ([]string {"off" , "auto" , "day " }, findResult ) {
310
312
relData .Hotwater .HwcOpMode = findResult
311
313
} else {
312
314
c .log .DEBUG .Printf ("Value '%s' returnd from ebusd for %s invalid and therefore ignored" , findResult , EBUSDREAD_HOTWATER_OPMODE )
@@ -374,7 +376,26 @@ func (c *Connection) getSystem(relData *VaillantRelDataStruct, reset bool) error
374
376
if err != nil {
375
377
return err
376
378
} else {
377
- relData .Status .CurrentConsumedPower , _ = strconv .ParseFloat (findResult , 64 )
379
+ convertedValue , err = strconv .ParseFloat (findResult , 64 )
380
+ if err != nil || convertedValue <= 0 {
381
+ c .log .DEBUG .Printf ("Value '%s' returnd from ebusd for %s invalid and therefore ignored" , findResult , EBUSDREAD_STATUS_CURRENTCONSUMEDPOWER )
382
+ } else {
383
+ relData .Status .CurrentConsumedPower = convertedValue
384
+ }
385
+ }
386
+ findResult , err = c .ebusdRead (EBUSDREAD_STATUS_STATUS01 , - 1 )
387
+ if err != nil {
388
+ return err
389
+ } else {
390
+ relData .Status .Status01 = findResult
391
+ c .log .DEBUG .Printf ("Info: Value '%s' returnd from ebusd for %s" , findResult , EBUSDREAD_STATUS_STATUS01 )
392
+ }
393
+ findResult , err = c .ebusdRead (EBUSDREAD_STATUS_STATE , - 1 )
394
+ if err != nil {
395
+ return err
396
+ } else {
397
+ relData .Status .State = findResult
398
+ c .log .DEBUG .Printf ("Info: Value '%s' returnd from ebusd for %s" , findResult , EBUSDREAD_STATUS_STATE )
378
399
}
379
400
380
401
//Getting Zone Data
@@ -394,7 +415,7 @@ func (c *Connection) getSystem(relData *VaillantRelDataStruct, reset bool) error
394
415
if err != nil {
395
416
return err
396
417
} else {
397
- if slices .Contains ([]string {"off" , "auto" , "manual " }, findResult ) {
418
+ if slices .Contains ([]string {"off" , "auto" , "day " }, findResult ) {
398
419
relData .Zones [i ].OpMode = findResult
399
420
} else {
400
421
c .log .DEBUG .Printf ("Value '%s' returnd from ebusd for %s invalid and therefore ignored" , findResult , EBUSDREAD_ZONE_OPMODE )
@@ -404,7 +425,7 @@ func (c *Connection) getSystem(relData *VaillantRelDataStruct, reset bool) error
404
425
if err != nil {
405
426
return err
406
427
} else {
407
- if slices .Contains ([]string {"off" , " auto" , "manual " }, findResult ) {
428
+ if slices .Contains ([]string {"auto" , "veto " }, findResult ) {
408
429
relData .Zones [i ].SFMode = findResult
409
430
} else {
410
431
c .log .DEBUG .Printf ("Value '%s' returnd from ebusd for %s invalid and therefore ignored" , findResult , EBUSDREAD_ZONE_SFMODE )
@@ -414,20 +435,45 @@ func (c *Connection) getSystem(relData *VaillantRelDataStruct, reset bool) error
414
435
if err != nil {
415
436
return err
416
437
} else {
417
- relData .Zones [i ].ActualRoomTempDesired , _ = strconv .ParseFloat (findResult , 64 )
438
+ convertedValue , err = strconv .ParseFloat (findResult , 64 )
439
+ if err != nil || convertedValue <= 0 {
440
+ c .log .DEBUG .Printf ("Value '%s' returnd from ebusd for %s invalid and therefore ignored" , findResult , EBUSDREAD_ZONE_ACTUALROOMTEMPDESIRED )
441
+ } else {
442
+ relData .Zones [i ].ActualRoomTempDesired = convertedValue
443
+ }
418
444
}
419
445
findResult , err = c .ebusdRead (zonePrefix + EBUSDREAD_ZONE_ROOMTEMP , 180 )
420
446
if err != nil {
421
447
return err
422
448
} else {
423
- relData .Zones [i ].RoomTemp , _ = strconv .ParseFloat (findResult , 64 )
449
+ convertedValue , err = strconv .ParseFloat (findResult , 64 )
450
+ if err != nil || convertedValue <= 0 {
451
+ c .log .DEBUG .Printf ("Value '%s' returnd from ebusd for %s invalid and therefore ignored" , findResult , EBUSDREAD_ZONE_ROOMTEMP )
452
+ } else {
453
+ relData .Zones [i ].RoomTemp = convertedValue
454
+ }
424
455
}
425
456
findResult , err = c .ebusdRead (zonePrefix + EBUSDREAD_ZONE_QUICKVETOTEMP , 0 )
426
457
if err != nil {
427
458
return err
428
459
} else {
429
460
relData .Zones [i ].QuickVetoTemp , _ = strconv .ParseFloat (findResult , 64 )
430
461
}
462
+ findResult , err = c .ebusdRead (zonePrefix + EBUSDREAD_ZONE_QUICKVETOENDDATE , - 1 )
463
+ if err != nil {
464
+ return err
465
+ } else {
466
+ relData .Zones [i ].QuickVetoEndDate = findResult
467
+ }
468
+ findResult , err = c .ebusdRead (zonePrefix + EBUSDREAD_ZONE_QUICKVETOENDTIME , - 1 )
469
+ if err != nil {
470
+ return err
471
+ } else {
472
+ relData .Zones [i ].QuickVetoEndTime = findResult
473
+ if relData .Zones [i ].SFMode == "veto" {
474
+ c .quickVetoExpiresAt = relData .Zones [i ].QuickVetoEndTime
475
+ }
476
+ }
431
477
432
478
//Set timestamp lastGetSystemAt and return nil error
433
479
c .lastGetSystemAt = time .Now ()
@@ -464,6 +510,19 @@ func (c *Connection) getSFMode(relData *VaillantRelDataStruct) error {
464
510
} else {
465
511
relData .Zones [i ].SFMode = findResult
466
512
}
513
+ findResult , err = c .ebusdRead (zonePrefix + EBUSDREAD_ZONE_QUICKVETOENDDATE , 0 )
514
+ if err != nil {
515
+ return err
516
+ } else {
517
+ relData .Zones [i ].QuickVetoEndDate = findResult
518
+ }
519
+ findResult , err = c .ebusdRead (zonePrefix + EBUSDREAD_ZONE_QUICKVETOENDTIME , 0 )
520
+ if err != nil {
521
+ return err
522
+ } else {
523
+ relData .Zones [i ].QuickVetoEndTime = findResult
524
+ }
525
+ c .log .DEBUG .Println ("Timestamp for end of zone quick veto: " , relData .Zones [i ].QuickVetoEndDate + " " + relData .Zones [i ].QuickVetoEndTime )
467
526
return nil
468
527
}
469
528
func (d * Connection ) Phases () int {
@@ -476,6 +535,7 @@ func (d *Connection) CurrentQuickmode() string {
476
535
477
536
func (d * Connection ) QuickVetoExpiresAt () string {
478
537
return d .quickVetoExpiresAt
538
+
479
539
}
480
540
481
541
// CurrentTemp is called bei Soc
@@ -551,9 +611,13 @@ func (c *Connection) WhichQuickMode() (int, error) {
551
611
c .log .DEBUG .Printf ("Checking if hot water boost possible. Operation Mode = %s, temperature setpoint= %02.2f, live temperature= %02.2f" ,
552
612
c .relData .Hotwater .HwcOpMode , c .relData .Hotwater .HwcTempDesired , c .relData .Hotwater .HwcStorageTemp )
553
613
hotWaterBoostPossible := false
554
- //if (c.relData.Hotwater.HwcStorageTemp <= c.relData.Hotwater.HwcTempDesired-5 || c.pvUseStrategy == PVUSESTRATEGY_HOTWATER) &&
555
- // c.relData.Hotwater.HwcOpMode == OPERATIONMODE_AUTO {
556
- if c .relData .Hotwater .HwcStorageTemp <= c .relData .Hotwater .HwcTempDesired - 5 &&
614
+ // For pvUseStrategy='hotwater', a hotwater boost is possible when hotwater storage temperature is less than the temperature setpoint.
615
+ // For other pvUseStrategies, a hotwater boost is possible when hotwater storage temperature is less than the temperature setpoint minus 5°C
616
+ addOn := - 5.0
617
+ if c .pvUseStrategy == PVUSESTRATEGY_HOTWATER {
618
+ addOn = 0.0
619
+ }
620
+ if c .relData .Hotwater .HwcStorageTemp < c .relData .Hotwater .HwcTempDesired + addOn &&
557
621
c .relData .Hotwater .HwcOpMode == OPERATIONMODE_AUTO {
558
622
hotWaterBoostPossible = true
559
623
}
0 commit comments