Allow configuring modbus connection timeout (#613)
This commit is contained in:
parent
a0cafefb6a
commit
4e5376df1c
1 changed files with 7 additions and 0 deletions
|
|
@ -3,6 +3,7 @@ package meter
|
|||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/andig/evcc/api"
|
||||
"github.com/andig/evcc/util"
|
||||
|
|
@ -34,6 +35,7 @@ func NewModbusFromConfig(other map[string]interface{}) (api.Meter, error) {
|
|||
Model string
|
||||
modbus.Settings `mapstructure:",squash"`
|
||||
Power, Energy, SoC string
|
||||
Timeout time.Duration
|
||||
}{
|
||||
Power: "Power",
|
||||
}
|
||||
|
|
@ -55,6 +57,11 @@ func NewModbusFromConfig(other map[string]interface{}) (api.Meter, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
// set non-default timeout
|
||||
if cc.Timeout > 0 {
|
||||
conn.Timeout(cc.Timeout)
|
||||
}
|
||||
|
||||
conn.Logger(log.TRACE)
|
||||
|
||||
// prepare device
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue