Add support for Solax Gen2 (HAC) chargers (#24243)
This commit is contained in:
parent
5a636da04b
commit
0b118974aa
2 changed files with 44 additions and 9 deletions
|
|
@ -31,8 +31,9 @@ import (
|
|||
|
||||
// Solax charger implementation
|
||||
type Solax struct {
|
||||
log *util.Logger
|
||||
conn *modbus.Connection
|
||||
log *util.Logger
|
||||
conn *modbus.Connection
|
||||
isLegacyHw bool
|
||||
}
|
||||
|
||||
const (
|
||||
|
|
@ -58,11 +59,20 @@ const (
|
|||
)
|
||||
|
||||
func init() {
|
||||
registry.AddCtx("solax", NewSolaxFromConfig)
|
||||
registry.AddCtx("solax", NewSolaxG1FromConfig)
|
||||
registry.AddCtx("solax-g2", NewSolaxG2FromConfig)
|
||||
}
|
||||
|
||||
func NewSolaxG1FromConfig(ctx context.Context, other map[string]interface{}) (api.Charger, error) {
|
||||
return NewSolaxFromConfig(ctx, other, true)
|
||||
}
|
||||
|
||||
func NewSolaxG2FromConfig(ctx context.Context, other map[string]interface{}) (api.Charger, error) {
|
||||
return NewSolaxFromConfig(ctx, other, false)
|
||||
}
|
||||
|
||||
// NewSolaxFromConfig creates a Solax charger from generic config
|
||||
func NewSolaxFromConfig(ctx context.Context, other map[string]interface{}) (api.Charger, error) {
|
||||
func NewSolaxFromConfig(ctx context.Context, other map[string]interface{}, isLegacyHw bool) (api.Charger, error) {
|
||||
cc := modbus.Settings{
|
||||
ID: 1,
|
||||
}
|
||||
|
|
@ -71,11 +81,11 @@ func NewSolaxFromConfig(ctx context.Context, other map[string]interface{}) (api.
|
|||
return nil, err
|
||||
}
|
||||
|
||||
return NewSolax(ctx, cc.URI, cc.Device, cc.Comset, cc.Baudrate, cc.Protocol(), cc.ID)
|
||||
return NewSolax(ctx, cc.URI, cc.Device, cc.Comset, cc.Baudrate, cc.Protocol(), cc.ID, isLegacyHw)
|
||||
}
|
||||
|
||||
// NewSolax creates Solax charger
|
||||
func NewSolax(ctx context.Context, uri, device, comset string, baudrate int, proto modbus.Protocol, id uint8) (api.Charger, error) {
|
||||
func NewSolax(ctx context.Context, uri, device, comset string, baudrate int, proto modbus.Protocol, id uint8, isLegacyHw bool) (api.Charger, error) {
|
||||
conn, err := modbus.NewConnection(ctx, uri, device, comset, baudrate, proto, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
@ -89,8 +99,9 @@ func NewSolax(ctx context.Context, uri, device, comset string, baudrate int, pro
|
|||
conn.Logger(log.TRACE)
|
||||
|
||||
wb := &Solax{
|
||||
log: log,
|
||||
conn: conn,
|
||||
log: log,
|
||||
conn: conn,
|
||||
isLegacyHw: isLegacyHw,
|
||||
}
|
||||
|
||||
return wb, err
|
||||
|
|
@ -196,7 +207,11 @@ func (wb *Solax) TotalEnergy() (float64, error) {
|
|||
return 0, err
|
||||
}
|
||||
|
||||
return float64(binary.BigEndian.Uint32(b)) / 10, err
|
||||
if wb.isLegacyHw {
|
||||
return float64(binary.BigEndian.Uint32(b)) / 10, err
|
||||
}
|
||||
|
||||
return float64(encoding.Uint32LswFirst(b)) / 10, err
|
||||
}
|
||||
|
||||
var _ api.PhaseCurrents = (*Solax)(nil)
|
||||
|
|
|
|||
20
templates/definition/charger/solax-g2.yaml
Normal file
20
templates/definition/charger/solax-g2.yaml
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
template: solax-g2
|
||||
products:
|
||||
- brand: Solax
|
||||
description:
|
||||
generic: X3-HAC
|
||||
capabilities: ["mA"]
|
||||
requirements:
|
||||
evcc: ["sponsorship"]
|
||||
description:
|
||||
de: Die Wallbox muss sich im Modus "Schnell" befinden und vom Wechselrichtersystem entkoppelt sein.
|
||||
en: The charger must be in “Fast” mode and decoupled from the inverter system.
|
||||
params:
|
||||
- name: modbus
|
||||
choice: ["rs485"]
|
||||
baudrate: 9600
|
||||
comset: 8N1
|
||||
id: 70
|
||||
render: |
|
||||
type: solax-g2
|
||||
{{- include "modbus" . }}
|
||||
Loading…
Add table
Add a link
Reference in a new issue