Add explicit api checks

This commit is contained in:
andig 2021-07-04 12:12:33 +02:00
parent 6eda5fdb63
commit 9d2bb88651
2 changed files with 8 additions and 0 deletions

View file

@ -236,6 +236,8 @@ func (wb *Wallbe) currents() (float64, float64, float64, error) {
return currents[0], currents[1], currents[2], nil
}
var _ api.Diagnosis = (*Wallbe)(nil)
// Diagnose implements the Diagnosis interface
func (wb *Wallbe) Diagnose() {
if b, err := wb.conn.ReadInputRegisters(wbRegFirmware, 6); err == nil {

View file

@ -226,12 +226,16 @@ func (sm *SMA) CurrentPower() (float64, error) {
return sm.scale * (sm.asFloat(values[sunny.ActivePowerPlus]) - sm.asFloat(values[sunny.ActivePowerMinus])), err
}
var _ api.MeterEnergy = (*SMA)(nil)
// TotalEnergy implements the api.MeterEnergy interface
func (sm *SMA) TotalEnergy() (float64, error) {
values, err := sm.hasValue()
return sm.asFloat(values[sunny.ActiveEnergyPlus]) / 3600000, err
}
var _ api.MeterCurrent = (*SMA)(nil)
// Currents implements the api.MeterCurrent interface
func (sm *SMA) Currents() (float64, float64, float64, error) {
values, err := sm.hasValue()
@ -251,6 +255,8 @@ func (sm *SMA) soc() (float64, error) {
return sm.asFloat(values[sunny.BatteryCharge]), err
}
var _ api.Diagnosis = (*SMA)(nil)
// Diagnose implements the api.Diagnosis interface
func (sm *SMA) Diagnose() {
w := tabwriter.NewWriter(os.Stdout, 0, 0, 1, ' ', 0)