evcc-io/meter/fritzdect.go
2025-10-31 15:25:53 +00:00

28 lines
744 B
Go

package meter
import (
"github.com/evcc-io/evcc/api"
"github.com/evcc-io/evcc/meter/fritzdect"
"github.com/evcc-io/evcc/util"
)
// AVM FritzBox AHA interface specifications:
// https://avm.de/fileadmin/user_upload/Global/Service/Schnittstellen/AHA-HTTP-Interface.pdf
func init() {
registry.Add("fritzdect", NewFritzDECTFromConfig)
}
// NewFritzDECTFromConfig creates a fritzdect meter from generic config
func NewFritzDECTFromConfig(other map[string]any) (api.Meter, error) {
var cc fritzdect.Settings
if err := util.DecodeOther(other, &cc); err != nil {
return nil, err
}
if cc.User == "" || cc.Password == "" {
return nil, api.ErrMissingCredentials
}
return fritzdect.NewConnection(cc.URI, cc.AIN, cc.User, cc.Password)
}