chore: don't initialise zero-valued structs
This commit is contained in:
parent
fce66c644c
commit
14693d2267
35 changed files with 72 additions and 68 deletions
|
|
@ -20,10 +20,10 @@ func init() {
|
|||
|
||||
// NewBlueprintFromConfig creates a blueprint meter from generic config
|
||||
func NewBlueprintFromConfig(other map[string]interface{}) (api.Meter, error) {
|
||||
cc := struct {
|
||||
var cc struct {
|
||||
URI string
|
||||
Cache time.Duration
|
||||
}{}
|
||||
}
|
||||
|
||||
if err := util.DecodeOther(other, &cc); err != nil {
|
||||
return nil, err
|
||||
|
|
|
|||
|
|
@ -50,11 +50,11 @@ func init() {
|
|||
|
||||
// NewBoschBpts5HybridFromConfig creates a Bosch BPT-S 5 Hybrid Meter from generic config
|
||||
func NewBoschBpts5HybridFromConfig(other map[string]interface{}) (api.Meter, error) {
|
||||
cc := struct {
|
||||
var cc struct {
|
||||
URI string
|
||||
Usage string
|
||||
Cache time.Duration
|
||||
}{}
|
||||
}
|
||||
|
||||
if err := util.DecodeOther(other, &cc); err != nil {
|
||||
return nil, err
|
||||
|
|
|
|||
|
|
@ -143,11 +143,11 @@ func (c *Connection) getSessionID() error {
|
|||
return err
|
||||
}
|
||||
|
||||
v := struct {
|
||||
var v struct {
|
||||
SID string
|
||||
Challenge string
|
||||
BlockTime string
|
||||
}{}
|
||||
}
|
||||
|
||||
if err = xml.Unmarshal(body, &v); err == nil && v.SID == "0000000000000000" {
|
||||
var challresp string
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ func init() {
|
|||
|
||||
// NewCCUFromConfig creates a Homematic meter from generic config
|
||||
func NewCCUFromConfig(other map[string]interface{}) (api.Meter, error) {
|
||||
cc := struct {
|
||||
var cc struct {
|
||||
URI string
|
||||
Device string
|
||||
MeterChannel string
|
||||
|
|
@ -26,7 +26,7 @@ func NewCCUFromConfig(other map[string]interface{}) (api.Meter, error) {
|
|||
User string
|
||||
Password string
|
||||
Usage string
|
||||
}{}
|
||||
}
|
||||
|
||||
if err := util.DecodeOther(other, &cc); err != nil {
|
||||
return nil, err
|
||||
|
|
|
|||
|
|
@ -17,12 +17,12 @@ func init() {
|
|||
|
||||
// NewConfigurableFromConfig creates api.Meter from config
|
||||
func NewConfigurableFromConfig(other map[string]interface{}) (api.Meter, error) {
|
||||
cc := struct {
|
||||
var cc struct {
|
||||
Power provider.Config
|
||||
Energy *provider.Config // optional
|
||||
SoC *provider.Config // optional
|
||||
Currents []provider.Config // optional
|
||||
}{}
|
||||
}
|
||||
|
||||
if err := util.DecodeOther(other, &cc); err != nil {
|
||||
return nil, err
|
||||
|
|
|
|||
|
|
@ -28,9 +28,9 @@ func init() {
|
|||
|
||||
// NewPowerWallFromConfig creates a PowerWall Powerwall Meter from generic config
|
||||
func NewPowerWallFromConfig(other map[string]interface{}) (api.Meter, error) {
|
||||
cc := struct {
|
||||
var cc struct {
|
||||
URI, Usage, User, Password string
|
||||
}{}
|
||||
}
|
||||
|
||||
if err := util.DecodeOther(other, &cc); err != nil {
|
||||
return nil, err
|
||||
|
|
|
|||
|
|
@ -13,12 +13,12 @@ func init() {
|
|||
|
||||
// NewShellyFromConfig creates a Shelly charger from generic config
|
||||
func NewShellyFromConfig(other map[string]interface{}) (api.Meter, error) {
|
||||
cc := struct {
|
||||
var cc struct {
|
||||
URI string
|
||||
User string
|
||||
Password string
|
||||
Channel int
|
||||
}{}
|
||||
}
|
||||
|
||||
if err := util.DecodeOther(other, &cc); err != nil {
|
||||
return nil, err
|
||||
|
|
|
|||
|
|
@ -13,11 +13,11 @@ func init() {
|
|||
|
||||
// NewTapoFromConfig creates a tapo meter from generic config
|
||||
func NewTapoFromConfig(other map[string]interface{}) (api.Meter, error) {
|
||||
cc := struct {
|
||||
var cc struct {
|
||||
URI string
|
||||
User string
|
||||
Password string
|
||||
}{}
|
||||
}
|
||||
|
||||
if err := util.DecodeOther(other, &cc); err != nil {
|
||||
return nil, err
|
||||
|
|
|
|||
|
|
@ -19,12 +19,12 @@ func init() {
|
|||
|
||||
// NewTasmotaFromConfig creates a Tasmota meter from generic config
|
||||
func NewTasmotaFromConfig(other map[string]interface{}) (api.Meter, error) {
|
||||
cc := struct {
|
||||
var cc struct {
|
||||
URI string
|
||||
User string
|
||||
Password string
|
||||
Usage string
|
||||
}{}
|
||||
}
|
||||
|
||||
if err := util.DecodeOther(other, &cc); err != nil {
|
||||
return nil, err
|
||||
|
|
|
|||
|
|
@ -12,10 +12,10 @@ func init() {
|
|||
}
|
||||
|
||||
func NewMeterFromTemplateConfig(other map[string]interface{}) (api.Meter, error) {
|
||||
cc := struct {
|
||||
var cc struct {
|
||||
Template string
|
||||
Other map[string]interface{} `mapstructure:",remain"`
|
||||
}{}
|
||||
}
|
||||
|
||||
if err := util.DecodeOther(other, &cc); err != nil {
|
||||
return nil, err
|
||||
|
|
|
|||
|
|
@ -13,9 +13,9 @@ func init() {
|
|||
|
||||
// NewTPLinkFromConfig creates a tapo meter from generic config
|
||||
func NewTPLinkFromConfig(other map[string]interface{}) (api.Meter, error) {
|
||||
cc := struct {
|
||||
var cc struct {
|
||||
URI string
|
||||
}{}
|
||||
}
|
||||
|
||||
if err := util.DecodeOther(other, &cc); err != nil {
|
||||
return nil, err
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue