chore: fix ruleguard errors

This commit is contained in:
andig 2021-11-14 12:09:17 +01:00
parent 00c8852be4
commit fe217debbf
15 changed files with 15 additions and 15 deletions

View file

@ -263,7 +263,7 @@ func (evse *EVSEWifi) totalEnergy() (float64, error) {
// Currents implements the api.MeterCurrents interface
func (evse *EVSEWifi) currents() (float64, float64, float64, error) {
params, err := evse.getParameters()
return float64(params.CurrentP1), float64(params.CurrentP2), float64(params.CurrentP3), err
return params.CurrentP1, params.CurrentP2, params.CurrentP3, err
}
// Identify implements the api.Identifier interface

View file

@ -142,7 +142,7 @@ func (wb *PhoenixEMEth) ChargingTime() (time.Duration, error) {
// 2 words, least significant word first
secs := uint64(b[3])<<16 | uint64(b[2])<<24 | uint64(b[1]) | uint64(b[0])<<8
return time.Duration(time.Duration(secs) * time.Second), nil
return time.Duration(secs) * time.Second, nil
}
// CurrentPower implements the api.Meter interface

View file

@ -143,7 +143,7 @@ func (wb *PhoenixEVEth) ChargingTime() (time.Duration, error) {
// 2 words, least significant word first
secs := uint64(b[3])<<16 | uint64(b[2])<<24 | uint64(b[1]) | uint64(b[0])<<8
return time.Duration(time.Duration(secs) * time.Second), nil
return time.Duration(secs) * time.Second, nil
}
// CurrentPower implements the api.Meter interface

View file

@ -131,7 +131,7 @@ func (c *Tasmota) ChargedEnergy() (float64, error) {
var resp tasmota.StatusSNSResponse
err := c.GetJSON(c.cmdUri("Status 8"), &resp)
return float64(resp.StatusSNS.Energy.Today), err
return resp.StatusSNS.Energy.Today, err
}
// cmdUri creates the Tasmota command web request

View file

@ -186,7 +186,7 @@ func (wb *Wallbe) ChargingTime() (time.Duration, error) {
// 2 words, least significant word first
secs := uint64(b[1]) | uint64(b[0])<<8 | uint64(b[3])<<16 | uint64(b[2])<<24
return time.Duration(time.Duration(secs) * time.Second), nil
return time.Duration(secs) * time.Second, nil
}
func (wb *Wallbe) decodeReading(b []byte) float64 {

View file

@ -109,7 +109,7 @@ func (lp *LoadPoint) GetPhases() int {
lp.Lock()
defer lp.Unlock()
return int(lp.Phases)
return lp.Phases
}
// SetPhases sets loadpoint enabled phases

View file

@ -135,7 +135,7 @@ var _ IntProvider = (*Mqtt)(nil)
func (m *Mqtt) IntGetter() func() (int64, error) {
h := &msgHandler{
topic: m.topic,
scale: float64(m.scale),
scale: m.scale,
mux: util.NewWaiter(m.timeout, func() { m.log.DEBUG.Printf("%s wait for initial value", m.topic) }),
re: m.re,
jq: m.jq,

View file

@ -13,7 +13,7 @@ func TestEncode(t *testing.T) {
{int64(1), "1"},
{float64(1.23456), "1.2346"},
{"1.2345", "\"1.2345\""},
{time.Duration(time.Hour), "3600"},
{time.Hour, "3600"},
{"minpv", "\"minpv\""},
}

View file

@ -93,7 +93,7 @@ func (v *Provider) SoC() (float64, error) {
res, err := v.statusG()
if res, ok := res.(StatusData); err == nil && ok {
return float64(res.EvStatus.BatteryStatus), nil
return res.EvStatus.BatteryStatus, nil
}
return 0, err

View file

@ -288,7 +288,7 @@ var _ api.Battery = (*Ford)(nil)
func (v *Ford) SoC() (float64, error) {
res, err := v.statusG()
if res, ok := res.(fordVehicleStatus); err == nil && ok {
return float64(res.VehicleStatus.BatteryFillLevel.Value), nil
return res.VehicleStatus.BatteryFillLevel.Value, nil
}
return 0, err

View file

@ -164,7 +164,7 @@ func (v *Niu) Range() (int64, error) {
res, err := v.apiG()
if res, ok := res.(niu.Response); err == nil && ok {
return int64(res.Data.EstimatedMileage), nil
return res.Data.EstimatedMileage, nil
}
return 0, err

View file

@ -157,7 +157,7 @@ var _ api.VehicleRange = (*Provider)(nil)
func (v *Provider) Range() (int64, error) {
res, err := v.statusEmobilityG()
if res, ok := res.(EmobilityResponse); err == nil && ok {
return int64(res.BatteryChargeStatus.RemainingERange.ValueInKilometers), nil
return res.BatteryChargeStatus.RemainingERange.ValueInKilometers, nil
}
res, err = v.statusG()

View file

@ -87,7 +87,7 @@ var _ api.VehicleRange = (*Provider)(nil)
func (v *Provider) Range() (rng int64, err error) {
res, err := v.chargerG()
if res, ok := res.(ChargerResponse); err == nil && ok {
rng = int64(res.Battery.CruisingRangeElectricInMeters) / 1e3
rng = res.Battery.CruisingRangeElectricInMeters / 1e3
}
return rng, err

View file

@ -136,7 +136,7 @@ func (v *Tesla) ChargedEnergy() (float64, error) {
res, err := v.chargeStateG()
if res, ok := res.(*tesla.ChargeState); err == nil && ok {
return float64(res.ChargeEnergyAdded), nil
return res.ChargeEnergyAdded, nil
}
return 0, err

View file

@ -157,7 +157,7 @@ var _ api.VehicleOdometer = (*Volvo)(nil)
func (v *Volvo) Odometer() (float64, error) {
res, err := v.statusG()
if res, ok := res.(volvo.Status); err == nil && ok {
return float64(res.Odometer), nil
return res.Odometer, nil
}
return 0, err