package main import ( "fmt" "log" "os" "time" "git.savin.nyc/alex/mysubaru" "git.savin.nyc/alex/mysubaru/config" ) func main() { var err error configFile, err := os.ReadFile("config.yaml") if err != nil { log.Fatal(err) } cfg, err := config.FromBytes(configFile) if err != nil { log.Fatal(err) } // cfg.Logger.Debug("printing config", "config", 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") // 11.6MMAN 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 NAV_TOMTOM OPL_MIL RAB_MIL RCC REARBRK RES RESCC RHSF RPOI RPOIA SRS_MIL TEL_MIL TIF_35 TIR_33 TPMS_MIL VDC_MIL WASH_MIL g2 // subaru1 := mysubaru.GetVehicleByVIN("4S4BTGND8L3137058") // fmt.Printf("SUBARU #2 (Vehicle Status):\n") // subaru1.GetVehicleStatus() // fmt.Printf("SUBARU #2 (Vehicle Condition):\n") // subaru1.GetVehicleCondition() // fmt.Printf("SUBARU #1: %+v\n", subaru1) // 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, 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) // // 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) // } // // Wait for a while to see the lights on // time.Sleep(20 * time.Second) // // 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) // } }