bogosj / tesla

Provides a wrapper around the API to easily query and command a Telsa car.
Other
23 stars 18 forks source link

Unable to get Vehicle State #58

Closed Rudi9719 closed 3 years ago

Rudi9719 commented 3 years ago

Receiving the following error when calling

    vehicleState, err := vehicle.VehicleState()
    if err != nil {
        fmt.Printf("Unable to get Vehicle State: %+v\n", err)
        return
    }

Unable to get Vehicle State: json: cannot unmarshal number 50.0 into Go struct field .response.speed_limit_mode.min_limit_mph of type int

andig commented 3 years ago

Seems that would better be float- do you want to provide a PR?

Rudi9719 commented 3 years ago

Not sure if that's the issue, looks like it is already a float64?

    SpeedLimitMode struct {
        Active          bool    `json:"active"`
        CurrentLimitMph float64 `json:"current_limit_mph"`
        MaxLimitMph     float64 `json:"max_limit_mph"`
        MinLimitMph     float64 `json:"min_limit_mph"`
        PinCodeSet      bool    `json:"pin_code_set"`
    } `json:"speed_limit_mode"`
andig commented 3 years ago

Are you using an outdated version?

Rudi9719 commented 3 years ago

I'm not sure; I just pulled it this morning so I don't think so? Unless I'm missing a tag or something

github.com/bogosj/tesla v1.0.0
Rudi9719 commented 3 years ago

Seems like there have been commits since the last release v1.0.0, maybe that's the issue? (Sorry, accidentally closed prematurely)

andig commented 3 years ago

Are you using the latest commit (really same question as above)?

Rudi9719 commented 3 years ago

Not sure how to check with Go modules (required for go 1.16+). I assume that for therecipe/qt, and x/oauth with the v0.0.0, but then there's a timestamp of some sort followed by what I assume is the commit hash?

    github.com/bogosj/tesla v1.0.0
    github.com/therecipe/qt v0.0.0-20200904063919-c0c124a5770d
    golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914
    samhofi.us/x/keybase/v2 v2.1.1
)
Rudi9719 commented 3 years ago

go get github.com/bogosj/tesla@0e5b7bb5e9240d8b9adc69242a364b36c7341938 solved the issue, thank you!

andig commented 3 years ago

Or ….@main to fetch the latest commit.