EEBUS: simplify port configuration (BC)

This commit is contained in:
andig 2026-01-11 14:11:03 +01:00
parent 8ff5403aee
commit 852592260f
2 changed files with 4 additions and 16 deletions

View file

@ -4,9 +4,7 @@ import (
"crypto/tls"
"errors"
"fmt"
"net"
"slices"
"strconv"
"strings"
"sync"
"time"
@ -90,7 +88,7 @@ var Instance *EEBus
func NewServer(other Config) (*EEBus, error) {
cc := Config{
URI: ":4712",
Port: 4712,
}
if err := mergo.Merge(&cc, other, mergo.WithOverride); err != nil {
@ -111,22 +109,11 @@ func NewServer(other Config) (*EEBus, error) {
return nil, err
}
_, portValue, err := net.SplitHostPort(cc.URI)
if err != nil {
return nil, err
}
port, err := strconv.Atoi(portValue)
if err != nil {
return nil, err
}
// TODO: get the voltage from the site
configuration, err := eebusapi.NewConfiguration(
BrandName, BrandName, Model, serial,
model.DeviceTypeTypeEnergyManagementSystem,
[]model.EntityTypeType{model.EntityTypeTypeCEM},
port, certificate, time.Second*4,
cc.Port, certificate, time.Second*4,
)
if err != nil {
return nil, err

View file

@ -15,7 +15,8 @@ type Certificate struct {
}
type Config struct {
URI string
URI_ string `mapstructure:"uri"` // TODO deprecated
Port int
ShipID string
Interfaces []string
Certificate Certificate