chore: apply gofumpt

This commit is contained in:
andig 2022-07-12 11:20:05 +02:00
parent 4afed292c2
commit 815cc58555
48 changed files with 99 additions and 83 deletions

View file

@ -160,7 +160,7 @@ type VehicleRange interface {
// VehicleClimater provides climatisation data
type VehicleClimater interface {
Climater() (active bool, outsideTemp float64, targetTemp float64, err error)
Climater() (active bool, outsideTemp, targetTemp float64, err error)
}
// VehicleOdometer returns the vehicles milage

View file

@ -126,7 +126,7 @@ func (wb *ABLeMH) set(reg, val uint16) error {
b := make([]byte, 2)
binary.BigEndian.PutUint16(b, val)
//write two times
// write two times
_, _ = wb.conn.WriteMultipleRegisters(reg, 1, b)
_, err := wb.conn.WriteMultipleRegisters(reg, 1, b)
@ -134,7 +134,7 @@ func (wb *ABLeMH) set(reg, val uint16) error {
}
func (wb *ABLeMH) get(reg, count uint16) ([]byte, error) {
//read two times
// read two times
_, _ = wb.conn.ReadHoldingRegisters(reg, count)
b, err := wb.conn.ReadHoldingRegisters(reg, count)

View file

@ -41,7 +41,7 @@ func NewDaheimLadenFromConfig(other map[string]interface{}) (api.Charger, error)
}
// NewDaheimLaden creates DaheimLaden charger
func NewDaheimLaden(token string, stationID string) (*DaheimLaden, error) {
func NewDaheimLaden(token, stationID string) (*DaheimLaden, error) {
c := &DaheimLaden{
Helper: request.NewHelper(util.NewLogger("daheim")),
stationID: stationID,

View file

@ -1,10 +1,12 @@
package daheimladen
type ChargePointStatus string
type RemoteStartStatus string
type RemoteStopStatus string
type ConfigKey string
type ChangeConfigStatus string
type (
ChargePointStatus string
RemoteStartStatus string
RemoteStopStatus string
ConfigKey string
ChangeConfigStatus string
)
const BASE_URL string = "https://api.daheimladen.com/v1"

View file

@ -156,7 +156,6 @@ func (c *EEBus) showCurrentChargingSetup() {
timestamp := time.Now()
c.log.WARN.Println("!! ", timestamp.Format("2006-01-02 15:04:05"), " ev-charger-self-consumption-support support changed from ", prevSelfConsumptionSupport, " to ", data.EVData.UCSelfConsumptionAvailable)
}
}
func (c *EEBus) dataUpdateHandler(dataType communication.EVDataElementUpdateType, data *communication.EVSEClientDataType) {

View file

@ -49,6 +49,7 @@ func TestLocalV1(t *testing.T) {
t.Error(err)
}
}
func TestLocalV2(t *testing.T) {
h := &handler{}
srv := httptest.NewServer(h)

View file

@ -171,7 +171,7 @@ func (wb *Salia) Enabled() (bool, error) {
func (wb *Salia) pause(enable bool) {
// ignore error for FW <1.52
var offOn = map[bool]string{false: "1", true: "0"}
offOn := map[bool]string{false: "1", true: "0"}
_ = wb.post(salia.PauseCharging, offOn[enable])
}

View file

@ -78,7 +78,7 @@ func NewMobileConnectFromConfig(other map[string]interface{}) (api.Charger, erro
}
// NewMobileConnect creates MCC charger
func NewMobileConnect(uri string, password string) (*MobileConnect, error) {
func NewMobileConnect(uri, password string) (*MobileConnect, error) {
log := util.NewLogger("mcc")
mcc := &MobileConnect{
@ -153,7 +153,6 @@ func (mcc *MobileConnect) refresh() error {
// creates a http request that contains the auth token
func (mcc *MobileConnect) request(method, uri string) (*http.Request, error) {
// do we need a token refresh?
if mcc.token != "" {
// is it time to refresh the token?

View file

@ -92,7 +92,7 @@ func NewNRGKickBLE(device, mac string, pin int) (*NRGKickBLE, error) {
return nil, err
}
//Connect DBus System bus
// Connect DBus System bus
conn, err := dbus.SystemBus()
if err != nil {
return nil, err

View file

@ -156,7 +156,6 @@ func detectSmartChargingCapabilities(options map[string]core.ConfigurationKey) (
}
return profile, nil
}
func parseIntOption(key SmartchargingChargeProfileKey, options map[string]core.ConfigurationKey) (int, error) {

View file

@ -117,7 +117,6 @@ func (cs *CS) OnFirmwareStatusNotification(chargePointId string, request *firmwa
}
return cp.FirmwareStatusNotification(request)
}
func (cs *CS) TriggerResetRequest(cp *CP, resetType core.ResetType) {

View file

@ -177,7 +177,7 @@ func (wb *PCElectric) Enabled() (bool, error) {
// Enable implements the api.Charger interface
func (wb *PCElectric) Enable(enable bool) error {
if wb.slaveIndex > 0 {
return nil //Slave wird immer mit dem Master geschaltet!
return nil // Slave wird immer mit dem Master geschaltet!
}
// Master Only !!
@ -216,7 +216,7 @@ func (wb *PCElectric) MinCurrent(current int64) error {
// MaxCurrent implements the api.Charger interface
func (wb *PCElectric) MaxCurrent(current int64) error {
if wb.slaveIndex > 0 {
return nil //Slave wird immer mit dem Master geschaltet!
return nil // Slave wird immer mit dem Master geschaltet!
}
// Ohne Loadbalancer Regelung über currentlimit:

View file

@ -80,7 +80,7 @@ func NewSmaevchargerFromConfig(other map[string]interface{}) (api.Charger, error
}
// NewSmaevcharger creates an SMA EV Charger
func NewSmaevcharger(uri string, user string, password string, cache time.Duration) (api.Charger, error) {
func NewSmaevcharger(uri, user, password string, cache time.Duration) (api.Charger, error) {
log := util.NewLogger("smaevcharger").Redact(user, password)
wb := &Smaevcharger{
@ -343,7 +343,7 @@ func (wb *Smaevcharger) Send(values ...smaevcharger.Value) error {
}
// value creates an smaevcharger.Value
func value(id string, value string) smaevcharger.Value {
func value(id, value string) smaevcharger.Value {
return smaevcharger.Value{
Timestamp: time.Now().UTC().Format(smaevcharger.TimestampFormat),
ChannelId: id,

View file

@ -216,7 +216,7 @@ func (c *CmdConfigure) processParamRequirements(param templates.Param) error {
return nil
}
func (c *CmdConfigure) askSponsortoken(required bool, feature bool) error {
func (c *CmdConfigure) askSponsortoken(required, feature bool) error {
fmt.Println("-- Sponsorship -----------------------------")
if required {
fmt.Println()
@ -239,7 +239,8 @@ func (c *CmdConfigure) askSponsortoken(required bool, feature bool) error {
sponsortoken := c.askValue(question{
label: c.localizedString("Requirements_Sponsorship_Token_Input", nil),
mask: true,
required: true})
required: true,
})
err := sponsor.ConfigureSponsorship(sponsortoken)
if err != nil {
@ -273,22 +274,26 @@ func (c *CmdConfigure) configureMQTT(templateItem templates.Template) (map[strin
host := c.askValue(question{
label: paramHost.Description.String(c.lang),
mask: false,
required: true})
required: true,
})
port := c.askValue(question{
label: paramPort.Description.String(c.lang),
mask: false,
required: true})
required: true,
})
user := c.askValue(question{
label: paramUser.Description.String(c.lang),
mask: false,
required: false})
required: false,
})
password := c.askValue(question{
label: paramPassword.Description.String(c.lang),
mask: true,
required: false})
required: false,
})
fmt.Println()
fmt.Println("--------------------------------------------")
@ -532,7 +537,8 @@ func (c *CmdConfigure) processInputConfig(param templates.Param) string {
valueType: param.ValueType,
validValues: param.ValidValues,
mask: param.Mask,
required: param.Required})
required: param.Required,
})
if param.ValueType == templates.ParamValueTypeBool && value == "true" {
if err := c.processParamRequirements(param); err != nil {

View file

@ -179,7 +179,7 @@ func (c *CmdConfigure) flowNewConfigFile() {
filename := DefaultConfigFilename
for ok := true; ok; {
file, err := os.OpenFile(filename, os.O_WRONLY, 0666)
file, err := os.OpenFile(filename, os.O_WRONLY, 0o666)
if errors.Is(err, os.ErrNotExist) {
break
}
@ -196,10 +196,11 @@ func (c *CmdConfigure) flowNewConfigFile() {
filename = c.askValue(question{
label: c.localizedString("File_NewFilename", nil),
exampleValue: "evcc_neu.yaml",
required: true})
required: true,
})
}
err = os.WriteFile(filename, yaml, 0755)
err = os.WriteFile(filename, yaml, 0o755)
if err != nil {
fmt.Printf("%s: ", c.localizedString("File_Error_SaveFailed", localizeMap{"FileName": filename}))
c.log.FATAL.Fatal(err)
@ -283,7 +284,8 @@ func (c *CmdConfigure) configureLoadpoints() {
loadpointTitle := c.askValue(question{
label: c.localizedString("Loadpoint_Title", nil),
defaultValue: c.localizedString("Loadpoint_DefaultTitle", nil),
required: true})
required: true,
})
loadpoint := loadpoint{
Title: loadpointTitle,
Phases: 3,
@ -330,14 +332,16 @@ func (c *CmdConfigure) configureLoadpoints() {
valueType: templates.ParamValueTypeNumber,
minNumberValue: int64(minValue),
maxNumberValue: 32,
required: true})
required: true,
})
loadpoint.MinCurrent, _ = strconv.Atoi(minAmperage)
maxAmperage := c.askValue(question{
label: c.localizedString("Loadpoint_WallboxMaxAmperage", nil),
valueType: templates.ParamValueTypeNumber,
minNumberValue: 6,
maxNumberValue: 32,
required: true})
required: true,
})
loadpoint.MaxCurrent, _ = strconv.Atoi(maxAmperage)
if !chargerHasMeter {
@ -378,7 +382,8 @@ func (c *CmdConfigure) configureLoadpoints() {
valueType: templates.ParamValueTypeNumber,
minNumberValue: int64(minValue),
maxNumberValue: 32,
required: true})
required: true,
})
loadpoint.MaxCurrent, _ = strconv.Atoi(amperage)
if !chargerHasMeter {
@ -415,6 +420,7 @@ func (c *CmdConfigure) configureSite() {
siteTitle := c.askValue(question{
label: c.localizedString("Site_Title", nil),
defaultValue: c.localizedString("Site_DefaultTitle", nil),
required: true})
required: true,
})
c.configuration.config.Site.Title = siteTitle
}

View file

@ -40,7 +40,7 @@ func runHealth(cmd *cobra.Command, args []string) {
u.RegisterLocation(serviceName, server.SocketPath)
var client = http.Client{
client := http.Client{
Transport: u,
}

View file

@ -59,5 +59,4 @@ func TestVehicleDetectByStatus(t *testing.T) {
c.release(res)
}
}
}

View file

@ -1272,7 +1272,6 @@ func (lp *LoadPoint) UpdateChargePower() {
return nil
}, retryOptions...)
if err != nil {
lp.log.ERROR.Printf("charge meter: %v", err)
}
@ -1409,7 +1408,7 @@ func (lp *LoadPoint) publishSoCAndRange() {
}
// Update is the main control function. It reevaluates meters and charger state
func (lp *LoadPoint) Update(sitePower float64, cheap bool, batteryBuffered bool) {
func (lp *LoadPoint) Update(sitePower float64, cheap, batteryBuffered bool) {
mode := lp.GetMode()
lp.publish("mode", mode)

View file

@ -595,6 +595,7 @@ func TestChargedEnergyAtDisconnect(t *testing.T) {
ctrl.Finish()
}
func TestTargetSoC(t *testing.T) {
ctrl := gomock.NewController(t)
vhc := mock.NewMockVehicle(ctrl)
@ -634,6 +635,7 @@ func TestTargetSoC(t *testing.T) {
}
}
}
func TestSoCPoll(t *testing.T) {
clock := clock.NewMock()
tRefresh := pollInterval

View file

@ -8,8 +8,10 @@ import (
"github.com/evcc-io/evcc/tariff"
)
const DefaultGridPrice = 0.30
const DefaultFeedInPrice = 0.08
const (
DefaultGridPrice = 0.30
DefaultFeedInPrice = 0.08
)
// publisher gives access to the site's publish function
type publisher interface {

View file

@ -17,7 +17,7 @@ import (
// Updater abstracts the LoadPoint implementation for testing
type Updater interface {
Update(availablePower float64, cheapRate bool, batteryBuffered bool)
Update(availablePower float64, cheapRate, batteryBuffered bool)
}
// Site is the main configuration container. A site can host multiple loadpoints.

View file

@ -15,7 +15,7 @@ func TestRemainingChargeDuration(t *testing.T) {
ctrl := gomock.NewController(t)
charger := mock.NewMockCharger(ctrl)
vehicle := mock.NewMockVehicle(ctrl)
//9 kWh userBatCap => 10 kWh virtualBatCap
// 9 kWh userBatCap => 10 kWh virtualBatCap
vehicle.EXPECT().Capacity().Return(int64(9))
ce := NewEstimator(util.NewLogger("foo"), charger, vehicle, false)

View file

@ -34,9 +34,7 @@ const (
maxAge = 1800
)
var (
serverName = "EVCC SEMP Server " + server.Version
)
var serverName = "EVCC SEMP Server " + server.Version
// SEMP is the SMA SEMP server
type SEMP struct {

View file

@ -171,7 +171,7 @@ func (c *Connection) getSessionID() error {
}
// createChallengeResponse creates the Fritzbox challenge response string
func createChallengeResponse(challenge string, pass string) (string, error) {
func createChallengeResponse(challenge, pass string) (string, error) {
encoder := unicode.UTF16(unicode.LittleEndian, unicode.IgnoreBOM).NewEncoder()
utf16le, err := encoder.String(challenge + "-" + pass)
if err != nil {

View file

@ -41,7 +41,7 @@ func NewSMAFromConfig(other map[string]interface{}) (IntProvider, error) {
return nil, fmt.Errorf("failed to get discoverer failed: %w", err)
}
var provider = &SMA{
provider := &SMA{
scale: cc.Scale,
}
switch {

View file

@ -21,7 +21,6 @@ func (lp *mockLoadpoint) SetTargetCharge(time time.Time, soc int) {
}
func TestTargetChargeHandler(t *testing.T) {
tc := []struct {
inSoC string
inTime string
@ -29,8 +28,10 @@ func TestTargetChargeHandler(t *testing.T) {
outSoC int
outTime time.Time
}{
{"70", "2022-05-17T06:20:59.509Z", http.StatusOK,
70, time.Date(2022, 05, 17, 06, 20, 59, 509000000, time.UTC)},
{
"70", "2022-05-17T06:20:59.509Z", http.StatusOK,
70, time.Date(2022, 0o5, 17, 0o6, 20, 59, 509000000, time.UTC),
},
{"foo", "2022-05-17T06:20:59.509Z", http.StatusBadRequest, 0, time.Time{}},
{"70", "2022-05-17 06:20:59", http.StatusBadRequest, 0, time.Time{}},
}
@ -69,5 +70,4 @@ func TestTargetChargeHandler(t *testing.T) {
t.Errorf("wrong target time year: got %v want %v", mockLp.TargetTime.UTC().Format(isoFormat), tc.outTime.Format(isoFormat))
}
}
}

View file

@ -11,9 +11,7 @@ import (
"github.com/google/go-github/v32/github"
)
var (
latest *github.RepositoryRelease
)
var latest *github.RepositoryRelease
// Run regularly checks version
func Run(log *util.Logger, httpd webServer, tee util.TeeAttacher, outChan chan<- util.Param) {

View file

@ -17,9 +17,7 @@ import (
var Host = "cloud.evcc.io:8080"
var (
conn *grpc.ClientConn
)
var conn *grpc.ClientConn
//go:embed ca-cert.pem
var caCert []byte

View file

@ -5,7 +5,7 @@ import (
)
// DecodeOther uses mapstructure to decode into target structure. Unused keys cause errors.
func DecodeOther(other interface{}, cc interface{}) error {
func DecodeOther(other, cc interface{}) error {
decoderConfig := &mapstructure.DecoderConfig{
Result: cc,
ErrorUnused: true,

View file

@ -6,7 +6,7 @@ import (
// RandomString creates random string of N integers
func RandomString(n int) string {
var letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")
letters := []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")
s := make([]rune, n)
for i := range s {
s[i] = letters[rand.Intn(len(letters))]

View file

@ -368,7 +368,7 @@ type SunSpecOperation struct {
}
// ParsePoint parses sunspec point from string
func ParsePoint(selector string) (model int, block int, point string, err error) {
func ParsePoint(selector string) (model, block int, point string, err error) {
err = fmt.Errorf("invalid point: %s", selector)
el := strings.Split(selector, ":")

View file

@ -18,7 +18,7 @@ func DefaultPort(conn string, port int) string {
}
// DefaultScheme prepends given scheme to uri if not specified
func DefaultScheme(uri string, scheme string) string {
func DefaultScheme(uri, scheme string) string {
u, err := url.Parse(uri)
if err != nil {
if strings.HasSuffix(err.Error(), "first path segment in URL cannot contain colon") {

View file

@ -38,6 +38,7 @@ func TestDefaultScheme(t *testing.T) {
t.Errorf("expected %s, got %s", expect, uri)
}
}
func TestDefaultSchemeWithEmptyUri(t *testing.T) {
expect := ""

View file

@ -13,8 +13,10 @@ import (
"golang.org/x/exp/maps"
)
const docsPath = "../../../templates/docs"
const websitePath = "../../../templates/evcc.io"
const (
docsPath = "../../../templates/docs"
websitePath = "../../../templates/evcc.io"
)
//go:generate go run generate.go
@ -23,7 +25,7 @@ func main() {
path := fmt.Sprintf("%s/%s", docsPath, class)
_, err := os.Stat(path)
if os.IsNotExist(err) {
if err := os.MkdirAll(path, 0755); err != nil {
if err := os.MkdirAll(path, 0o755); err != nil {
panic(err)
}
}
@ -69,7 +71,7 @@ func writeTemplate(class string, index int, product templates.Product, tmpl temp
}
filename := fmt.Sprintf("%s/%s/%s_%d.yaml", docsPath, class, tmpl.Template, index)
if err := os.WriteFile(filename, b, 0644); err != nil {
if err := os.WriteFile(filename, b, 0o644); err != nil {
return err
}
return nil
@ -153,7 +155,7 @@ func generateBrandJSON() error {
}
file, _ := json.MarshalIndent(brands, "", " ")
error := ioutil.WriteFile(websitePath+"/brands.json", file, 0644)
error := ioutil.WriteFile(websitePath+"/brands.json", file, 0o644)
return error
}

View file

@ -49,8 +49,10 @@ const (
var ValidParamValueTypes = []string{ParamValueTypeString, ParamValueTypeNumber, ParamValueTypeFloat, ParamValueTypeBool, ParamValueTypeStringList, ParamValueTypeChargeModes, ParamValueTypeDuration}
var ValidModbusChoices = []string{ModbusChoiceRS485, ModbusChoiceTCPIP}
var ValidUsageChoices = []string{UsageChoiceGrid, UsageChoicePV, UsageChoiceBattery, UsageChoiceCharge}
var (
ValidModbusChoices = []string{ModbusChoiceRS485, ModbusChoiceTCPIP}
ValidUsageChoices = []string{UsageChoiceGrid, UsageChoicePV, UsageChoiceBattery, UsageChoiceCharge}
)
const (
DependencyCheckEmpty = "empty"
@ -78,7 +80,8 @@ const (
var ValidRequirements = []string{RequirementEEBUS, RequirementMQTT, RequirementSponsorship}
var predefinedTemplateProperties = []string{"type", "template", "name",
var predefinedTemplateProperties = []string{
"type", "template", "name",
ModbusParamNameId, ModbusParamNameDevice, ModbusParamNameBaudrate, ModbusParamNameComset,
ModbusParamNameURI, ModbusParamNameHost, ModbusParamNamePort, ModbusParamNameRTU,
ModbusKeyTCPIP, ModbusKeyRS485Serial, ModbusKeyRS485TCPIP,

View file

@ -218,7 +218,7 @@ func (v *CarWings) Range() (int64, error) {
var _ api.VehicleClimater = (*CarWings)(nil)
// Climater implements the api.VehicleClimater interface
func (v *CarWings) Climater() (active bool, outsideTemp float64, targetTemp float64, err error) {
func (v *CarWings) Climater() (active bool, outsideTemp, targetTemp float64, err error) {
res, err := v.climateG()
// silence ErrClimateStatusUnavailable errors

View file

@ -95,7 +95,8 @@ func (v *JLR) RegisterDevice(log *util.Logger, user, device string, t jlr.Token)
"access_token": t.AccessToken,
"authorization_token": t.AuthToken,
"expires_in": "86400",
"deviceID": device}
"deviceID": device,
}
uri := fmt.Sprintf("%s/users/%s/clients", jlr.IFOP_BASE_URL, url.PathEscape(user))

View file

@ -117,7 +117,8 @@ func (v *API) AuthenticateVinService(vin, user, service string) (PinResponse, er
pin := vin[len(vin)-4:]
data := map[string]string{
"serviceName": service,
"pin": pin}
"pin": pin,
}
uri := fmt.Sprintf("%s/vehicles/%s/users/%s/authenticate", IF9_BASE_URL, vin, user)
req, err := request.New(http.MethodPost, uri, request.MarshalJSON(data), map[string]string{

View file

@ -1,6 +1,7 @@
package mb
import (
"context"
"crypto/rand"
"encoding/base64"
"fmt"
@ -10,7 +11,6 @@ import (
"net/url"
"strings"
"context"
"github.com/evcc-io/evcc/util"
"github.com/evcc-io/evcc/util/request"
cv "github.com/nirasan/go-oauth-pkce-code-verifier"

View file

@ -70,7 +70,7 @@ func (v *API) BatteryStatus(vin string) (StatusResponse, error) {
}
// RefreshRequest requests battery status refresh
func (v *API) RefreshRequest(vin string, typ string) (ActionResponse, error) {
func (v *API) RefreshRequest(vin, typ string) (ActionResponse, error) {
var res ActionResponse
uri := fmt.Sprintf("%s/v1/cars/%s/actions/refresh-battery-status", CarAdapterBaseURL, vin)

View file

@ -17,7 +17,7 @@ type Provider struct {
}
// NewProvider creates a new vehicle
func NewProvider(log *util.Logger, api *API, emobility *EmobilityAPI, mobile *MobileAPI, vin string, carModel string, cache time.Duration) *Provider {
func NewProvider(log *util.Logger, api *API, emobility *EmobilityAPI, mobile *MobileAPI, vin, carModel string, cache time.Duration) *Provider {
impl := &Provider{
statusG: provider.Cached(func() (StatusResponse, error) {
return api.Status(vin)
@ -181,7 +181,7 @@ func (v *Provider) Status() (api.ChargeStatus, error) {
var _ api.VehicleClimater = (*Provider)(nil)
// Climater implements the api.VehicleClimater interface
func (v *Provider) Climater() (active bool, outsideTemp float64, targetTemp float64, err error) {
func (v *Provider) Climater() (active bool, outsideTemp, targetTemp float64, err error) {
res, err := v.mobileG()
if err == nil {
m, err := res.MeasurementByKey("CLIMATIZER_STATE")

View file

@ -129,7 +129,7 @@ func (v *Provider) Status() (api.ChargeStatus, error) {
var _ api.VehicleClimater = (*Provider)(nil)
// Climater implements the api.VehicleClimater interface
func (v *Provider) Climater() (active bool, outsideTemp float64, targetTemp float64, err error) {
func (v *Provider) Climater() (active bool, outsideTemp, targetTemp float64, err error) {
res, err := v.statusG()
if err == nil {
active := strings.ToLower(res.Preconditionning.AirConditioning.Status) != "disabled"

View file

@ -464,7 +464,7 @@ func (v *Renault) FinishTime() (time.Time, error) {
var _ api.VehicleClimater = (*Renault)(nil)
// Climater implements the api.VehicleClimater interface
func (v *Renault) Climater() (active bool, outsideTemp float64, targetTemp float64, err error) {
func (v *Renault) Climater() (active bool, outsideTemp, targetTemp float64, err error) {
res, err := v.hvacG()
// Zoe Ph2

View file

@ -87,7 +87,7 @@ func (v *Provider) Range() (int64, error) {
var _ api.VehicleClimater = (*Provider)(nil)
// Climater implements the api.VehicleClimater interface
func (v *Provider) Climater() (active bool, outsideTemp float64, targetTemp float64, err error) {
func (v *Provider) Climater() (active bool, outsideTemp, targetTemp float64, err error) {
res, err := v.statusG()
return res.Services.Climatisation.Active, 21, 21, err
}

View file

@ -31,7 +31,7 @@ func NewProvider(log *util.Logger, api *API, vin string, expiry, cache time.Dura
return v
}
func (v *Provider) status(statusG func() (StatusResponse, error), refreshG func() (StatusResponse, error)) (StatusResponse, error) {
func (v *Provider) status(statusG, refreshG func() (StatusResponse, error)) (StatusResponse, error) {
res, err := statusG()
// if ts := res.Status.Data.Soc.Ts.Time; err == nil && ts.Add(v.expiry).Before(time.Now()) {

View file

@ -32,6 +32,7 @@ var Config = &oidc.ProviderConfig{
func Login(log *util.Logger, q url.Values, user, password string) (url.Values, error) {
return LoginWithAuthURL(log, Config.AuthURL, q, user, password)
}
func LoginWithAuthURL(log *util.Logger, uri string, q url.Values, user, password string) (url.Values, error) {
var verify func(url.Values)

View file

@ -101,7 +101,7 @@ func (v *Provider) Odometer() (float64, error) {
var _ api.VehicleClimater = (*Provider)(nil)
// Climater implements the api.VehicleClimater interface
func (v *Provider) Climater() (active bool, outsideTemp float64, targetTemp float64, err error) {
func (v *Provider) Climater() (active bool, outsideTemp, targetTemp float64, err error) {
res, err := v.statusG()
if err == nil {
state := strings.ToLower(res.Data.ClimatisationStatus.ClimatisationState)

View file

@ -139,7 +139,7 @@ func (v *Provider) Odometer() (float64, error) {
var _ api.VehicleClimater = (*Provider)(nil)
// Climater implements the api.VehicleClimater interface
func (v *Provider) Climater() (active bool, outsideTemp float64, targetTemp float64, err error) {
func (v *Provider) Climater() (active bool, outsideTemp, targetTemp float64, err error) {
res, err := v.climateG()
if err == nil {
state := strings.ToLower(res.Climater.Status.ClimatisationStatusData.ClimatisationState.Content)