@@ -7,19 +7,21 @@ import (
7
7
8
8
// Connection is the SensonetEbus connection
9
9
type Connection struct {
10
- logger Logger
11
- ebusdConn * EbusConnection
12
- currentQuickmode string
13
- quickmodeStarted time.Time
14
- quickmodeStopped time.Time
15
- relData VaillantRelData
10
+ logger Logger
11
+ ebusdConn * EbusConnection
12
+ currentQuickmode string
13
+ quickmodeStarted time.Time
14
+ quickmodeStopped time.Time
15
+ quickModeExpiresAt string
16
+ relData VaillantRelData
16
17
}
17
18
18
19
// NewConnection creates a new Sensonet device connection.
19
20
func NewConnection (ebusdAddress string , opts ... ConnOption ) (* Connection , error ) {
20
21
conn := & Connection {}
21
22
conn .currentQuickmode = ""
22
23
conn .quickmodeStarted = time .Now ()
24
+ conn .quickModeExpiresAt = ""
23
25
24
26
for _ , opt := range opts {
25
27
opt (conn )
@@ -44,6 +46,10 @@ func (c *Connection) GetCurrentQuickMode() string {
44
46
return c .currentQuickmode
45
47
}
46
48
49
+ func (c * Connection ) GetQuickModeExpiresAt () string {
50
+ return c .quickModeExpiresAt
51
+ }
52
+
47
53
func (c * Connection ) GetSystem (refresh bool ) (VaillantRelData , error ) {
48
54
err := c .ebusdConn .getSystem (& c .relData , refresh )
49
55
c .refreshCurrentQuickMode ()
@@ -176,13 +182,19 @@ func (c *Connection) StartStrategybased(strategy int, heatingPar *HeatingParStru
176
182
c .currentQuickmode = QUICKMODE_HOTWATER
177
183
c .quickmodeStarted = time .Now ()
178
184
c .debug ("Starting hotwater boost" )
185
+ c .quickModeExpiresAt = ""
179
186
}
180
187
case 2 :
181
188
err = c .StartZoneQuickVeto (heatingPar .ZoneIndex , heatingPar .VetoSetpoint , heatingPar .VetoDuration )
182
189
if err == nil {
183
190
c .currentQuickmode = QUICKMODE_HEATING
184
191
c .quickmodeStarted = time .Now ()
185
192
c .debug ("Starting zone quick veto" )
193
+ if heatingPar .VetoDuration < 0.0 {
194
+ c .quickModeExpiresAt = (time .Now ().Add (time .Duration (int64 (ZONEVETODURATION_DEFAULT * 60 ) * int64 (time .Minute )))).Format ("15:04" )
195
+ } else {
196
+ c .quickModeExpiresAt = (time .Now ().Add (time .Duration (int64 (heatingPar .VetoDuration * 60 ) * int64 (time .Minute )))).Format ("15:04" )
197
+ }
186
198
}
187
199
default :
188
200
if c .currentQuickmode == QUICKMODE_HOTWATER {
@@ -201,6 +213,7 @@ func (c *Connection) StartStrategybased(strategy int, heatingPar *HeatingParStru
201
213
}
202
214
c .currentQuickmode = QUICKMODE_NOTHING
203
215
c .quickmodeStarted = time .Now ()
216
+ c .quickModeExpiresAt = (time .Now ().Add (time .Duration (10 * time .Minute ))).Format ("15:04" )
204
217
c .debug ("Enable called but no quick mode possible. Starting idle mode" )
205
218
}
206
219
@@ -237,6 +250,7 @@ func (c *Connection) StopStrategybased(heatingPar *HeatingParStruct) (string, er
237
250
c .debug ("Nothing to do, no quick mode active" )
238
251
}
239
252
c .currentQuickmode = ""
253
+ c .quickModeExpiresAt = ""
240
254
c .quickmodeStopped = time .Now ()
241
255
242
256
c .relData .LastGetSystem = time.Time {} // reset the cache
0 commit comments