Skip to content

Commit

Permalink
chore: refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
andig committed Jan 3, 2025
1 parent a83ad42 commit 07070a4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion charger/fritzdect.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,17 @@ func NewFritzDECTFromConfig(other map[string]interface{}) (api.Charger, error) {
// NewFritzDECT creates a new connection with standbypower for charger
func NewFritzDECT(embed embed, uri, ain, user, password string, standbypower float64) (*FritzDECT, error) {
conn, err := fritzdect.NewConnection(uri, ain, user, password)
if err != nil {
return nil, err
}

c := &FritzDECT{
conn: conn,
}

c.switchSocket = NewSwitchSocket(&embed, c.Enabled, c.conn.CurrentPower, standbypower)

return c, err
return c, nil
}

// Status implements the api.Charger interface
Expand Down
5 changes: 4 additions & 1 deletion charger/homematic.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,17 @@ func NewCCUFromConfig(other map[string]interface{}) (api.Charger, error) {
// NewCCU creates a new connection with standbypower for charger
func NewCCU(embed embed, uri, deviceid, meterid, switchid, user, password string, standbypower float64, cache time.Duration) (*CCU, error) {
conn, err := homematic.NewConnection(uri, deviceid, meterid, switchid, user, password, cache)
if err != nil {
return nil, err
}

c := &CCU{
conn: conn,
}

c.switchSocket = NewSwitchSocket(&embed, c.Enabled, c.conn.CurrentPower, standbypower)

return c, err
return c, nil
}

// Enabled implements the api.Charger interface
Expand Down

0 comments on commit 07070a4

Please sign in to comment.