diff --git a/internal/controllers/devices_controller.go b/internal/controllers/devices_controller.go index 4c83bcd3..b324d15a 100644 --- a/internal/controllers/devices_controller.go +++ b/internal/controllers/devices_controller.go @@ -48,6 +48,29 @@ func NewDeviceDefinitionFromGRPC(dd *grpc.GetDeviceDefinitionItemResponse) (serv for _, style := range dd.DeviceStyles { rp.Type.SubModels = append(rp.Type.SubModels, style.SubModel) } + // temporary until mobile app stops using this stuff + if rp.DeviceMake.Name == "Tesla" { + // add only tesla + rp.CompatibleIntegrations = append(rp.CompatibleIntegrations, buildCompatibleIntegration("Tesla", "Asia")) + rp.CompatibleIntegrations = append(rp.CompatibleIntegrations, buildCompatibleIntegration("Tesla", "West Asia")) + rp.CompatibleIntegrations = append(rp.CompatibleIntegrations, buildCompatibleIntegration("Tesla", "South America")) + rp.CompatibleIntegrations = append(rp.CompatibleIntegrations, buildCompatibleIntegration("Tesla", "Oceania")) + rp.CompatibleIntegrations = append(rp.CompatibleIntegrations, buildCompatibleIntegration("Tesla", "Europe")) + rp.CompatibleIntegrations = append(rp.CompatibleIntegrations, buildCompatibleIntegration("Tesla", "Americas")) + } else if rp.Type.Year > 2005 { + // add hw options, Americas, USA, Europe + rp.CompatibleIntegrations = append(rp.CompatibleIntegrations, buildCompatibleIntegration("AutoPi", "Americas")) + rp.CompatibleIntegrations = append(rp.CompatibleIntegrations, buildCompatibleIntegration("AutoPi", "Europe")) + rp.CompatibleIntegrations = append(rp.CompatibleIntegrations, buildCompatibleIntegration("Ruptela", "Americas")) + rp.CompatibleIntegrations = append(rp.CompatibleIntegrations, buildCompatibleIntegration("Ruptela", "Europe")) + rp.CompatibleIntegrations = append(rp.CompatibleIntegrations, buildCompatibleIntegration("Macaron", "Americas")) + rp.CompatibleIntegrations = append(rp.CompatibleIntegrations, buildCompatibleIntegration("Macaron", "Europe")) + } + if rp.DeviceMake.Name != "Tesla" && rp.Type.Year > 2018 { + // add smartcar + rp.CompatibleIntegrations = append(rp.CompatibleIntegrations, buildCompatibleIntegration("SmartCar", "Europe")) + rp.CompatibleIntegrations = append(rp.CompatibleIntegrations, buildCompatibleIntegration("SmartCar", "Americas")) + } return rp, nil } @@ -57,6 +80,47 @@ type DeviceRp struct { Name string `json:"name"` } +// buildCompatibleIntegration temporary until mobile app stops using this stuff +func buildCompatibleIntegration(vendor, region string) services.DeviceCompatibility { + dc := services.DeviceCompatibility{} + switch vendor { + case "AutoPi": + dc = services.DeviceCompatibility{ + ID: "27qftVRWQYpVDcO5DltO5Ojbjxk", + Type: "Hardware", + Style: "Addon", + } + case "SmartCar": + dc = services.DeviceCompatibility{ + ID: "22N2xaPOq2WW2gAHBHd0Ikn4Zob", + Type: "API", + Style: "Webhook", + } + case "Tesla": + dc = services.DeviceCompatibility{ + ID: "26A5Dk3vvvQutjSyF0Jka2DP5lg", + Type: "API", + Style: "OEM", + } + case "Ruptela": + dc = services.DeviceCompatibility{ + ID: "2lcaMFuCO0HJIUfdq8o780Kx5n3", + Type: "Hardware", + Style: "Addon", + } + case "Macaron": + dc = services.DeviceCompatibility{ + ID: "2ULfuC8U9dOqRshZBAi0lMM1Rrx", + Type: "Hardware", + Style: "Addon", + } + } + dc.Vendor = vendor + dc.Region = region + + return dc +} + // DeviceCompatibilityFromDB returns list of compatibility representation from device integrations db slice, assumes integration relation loaded func DeviceCompatibilityFromDB(dbDIS []*grpc.DeviceIntegration) []services.DeviceCompatibility { if len(dbDIS) == 0 {