Refactor code structure and remove redundant sections for improved readability and maintainability
All checks were successful
Golan Testing / testing (1.24.x, ubuntu-latest) (push) Successful in 26s
All checks were successful
Golan Testing / testing (1.24.x, ubuntu-latest) (push) Successful in 26s
This commit is contained in:
@ -10,5 +10,5 @@ mysubaru:
|
||||
timezone: "America/New_York"
|
||||
logging:
|
||||
level: INFO
|
||||
output: json
|
||||
output: JSON
|
||||
source: false
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"git.savin.nyc/alex/mysubaru"
|
||||
"git.savin.nyc/alex/mysubaru/config"
|
||||
@ -21,9 +22,13 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
cfg.Logger.Debug("printing config", "config", cfg)
|
||||
// cfg.Logger.Debug("printing config", "config", cfg)
|
||||
|
||||
ms, _ := mysubaru.New(cfg)
|
||||
msc, err := mysubaru.New(cfg)
|
||||
if err != nil {
|
||||
cfg.Logger.Error("cannot create MySubaru client", "error", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// subaru := ms.SelectVehicle("4S4BTGPD0P3199198")
|
||||
|
||||
@ -37,48 +42,66 @@ func main() {
|
||||
// fmt.Printf("GEN #1: %+v\n\n", subaru1.getAPIGen())
|
||||
|
||||
// ABS_MIL ACCS AHBL_MIL ATF_MIL AWD_MIL BSD BSDRCT_MIL CEL_MIL EBD_MIL EOL_MIL EPAS_MIL EPB_MIL ESS_MIL EYESIGHT ISS_MIL OPL_MIL PANPM-TUIRWAOC PWAAADWWAP RAB_MIL RCC REARBRK RES RESCC RHSF RPOI RPOIA RTGU RVFS SRH_MIL SRS_MIL TEL_MIL TIF_35 TIR_33 TLD TPMS_MIL VALET VDC_MIL WASH_MIL g3
|
||||
outback := ms.GetVehicleByVIN("4S4BTGPD0P3199198")
|
||||
// subaru.GetLocation(true)
|
||||
outback, err := msc.GetVehicleByVIN("4S4BTGPD0P3199198")
|
||||
if err != nil {
|
||||
cfg.Logger.Error("cannot get a vehicle by VIN", "error", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
fmt.Printf("SUBARU #1 (Vehicle Status): %s\n", outback)
|
||||
|
||||
// subaru.EngineStart()
|
||||
fmt.Printf("SUBARU #1 (Vehicle Status):\n")
|
||||
// subaru.GetVehicleStatus()
|
||||
// fmt.Printf("SUBARU #1 (Vehicle Condition):\n")
|
||||
// subaru.GetVehicleCondition()
|
||||
// fmt.Printf("SUBARU #1: %+v\n", subaru)
|
||||
// subaru.GetClimatePresets()
|
||||
// subaru.GetClimateUserPresets()
|
||||
// fmt.Printf("SUBARU #2: %+v\n", subaru)
|
||||
// subaru.GetVehicleHealth()
|
||||
// subaru.GetFeaturesList()
|
||||
// subaru := mysubaru.GetVehicles()[0]
|
||||
// // Execute a LightsStart command
|
||||
// events, err := outback.LightsStart()
|
||||
// if err != nil {
|
||||
// cfg.Logger.Error("cannot execute LightsStart command", "error", err)
|
||||
// os.Exit(1)
|
||||
// }
|
||||
// for event := range events {
|
||||
// fmt.Printf("Lights Start Event: %+v\n", event)
|
||||
// }
|
||||
|
||||
// fmt.Printf("SUBARU: %+v\n", subaru)
|
||||
|
||||
// fmt.Printf("Subaru Gen: %+v\n\n", subaru.getAPIGen())
|
||||
|
||||
// subaru.EngineOn()
|
||||
// subaru.GetLocation(false)
|
||||
|
||||
// subaru.GetVehicleStatus()
|
||||
// subaru.GetVehicleCondition()
|
||||
|
||||
// subaru.GetClimateQuickPresets()
|
||||
// subaru.GetClimatePresets()
|
||||
// subaru.GetClimateUserPresets()
|
||||
|
||||
// subaru.GetVehicleStatus()
|
||||
|
||||
// subaru.GetClimateSettings()
|
||||
|
||||
// subaru.EngineStart()
|
||||
// time.Sleep(15 * time.Second)
|
||||
// subaru.EngineStop()
|
||||
|
||||
// subaru.Unlock()
|
||||
// // Wait for a while to see the lights on
|
||||
// time.Sleep(20 * time.Second)
|
||||
// subaru.Lock()
|
||||
|
||||
// subaru.GetLocation()
|
||||
fmt.Printf("SUBARU: %+v\n", outback)
|
||||
// // Execute a LightsStop command
|
||||
// events, err = outback.LightsStop()
|
||||
// if err != nil {
|
||||
// cfg.Logger.Error("cannot execute LightsStop command", "error", err)
|
||||
// os.Exit(1)
|
||||
// }
|
||||
// for event := range events {
|
||||
// fmt.Printf("Lights Stop Event: %+v\n", event)
|
||||
// }
|
||||
|
||||
// Execute a Unlock command
|
||||
events, err := outback.Unlock()
|
||||
if err != nil {
|
||||
cfg.Logger.Error("cannot execute Unlock command", "error", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
for event := range events {
|
||||
fmt.Printf("Unlock Event: %+v\n", event)
|
||||
}
|
||||
|
||||
// Wait for a while to see the lights on
|
||||
time.Sleep(20 * time.Second)
|
||||
|
||||
// Execute a Lock command
|
||||
events, err = outback.Lock()
|
||||
if err != nil {
|
||||
cfg.Logger.Error("cannot execute Lock command", "error", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
for event := range events {
|
||||
fmt.Printf("Lock Event: %+v\n", event)
|
||||
}
|
||||
|
||||
// Execute a forced GetLocation command
|
||||
// events, err = outback.GetLocation(true)
|
||||
// if err != nil {
|
||||
// cfg.Logger.Error("cannot execute forced GetLocation command", "error", err)
|
||||
// os.Exit(1)
|
||||
// }
|
||||
// for event := range events {
|
||||
// fmt.Printf("GeoLocation Event: %+v\n", event)
|
||||
// }
|
||||
}
|
||||
|
Reference in New Issue
Block a user