public ResultStatus SetPanoramicRoofLevel(TeslaVehicle vehicle, PanoramicRoofState roofState, int percentOpen = 0) { RequireLogin(); RequireVehicle(vehicle); try { if (vehicle.Options.RoofType != RoofType.NONE) { return(new ResultStatus { Result = false, Reason = "No Panoramic Roof" }); } string response; if (roofState == PanoramicRoofState.MOVE) { response = webClient.DownloadString(Path.Combine(TESLA_SERVER(IsDebugMode), string.Format(SUN_ROOF_CONTROL_PATH_WITH_PERCENT, vehicle.Id, roofState.GetEnumValue(), percentOpen))); } else { response = webClient.DownloadString(Path.Combine(TESLA_SERVER(IsDebugMode), string.Format(SUN_ROOF_CONTROL_PATH, vehicle.Id, roofState.GetEnumValue()))); } var result = ParseResultStatus(response); return(result); } catch (Exception) { } return(null); }
public async Task <ResponseWrapper <ResultStatus> > SetPanoramicRoofLevel(PanoramicRoofState roofState, int percentOpen = 0) { var uri = $"vehicles/{Id}/command/sun_roof_control?state={roofState.GetEnumValue()}"; if (roofState == PanoramicRoofState.Move) { uri += $"&percent={percentOpen}"; } return(await Client.Post <ResultStatus>(uri).ConfigureAwait(false)); }
public ResultStatus SetPanoramicRoofLevel(PanoramicRoofState roofState, int percentOpen = 0) { var request = new RestRequest("vehicles/{id}/command/sun_roof_control?state={state}&percent={percent}"); request.AddParameter("id", Id, ParameterType.UrlSegment); request.AddParameter("state", roofState.GetEnumValue(), ParameterType.UrlSegment); if (roofState == PanoramicRoofState.Move) { request.AddParameter("percent", percentOpen, ParameterType.UrlSegment); } var response = Client.Post(request); return(ParseResult <ResultStatus>(response)); }
public ResultStatus SetPanoramicRoofLevel(PanoramicRoofState roofState, int percentOpen = 0) { var request = new RestRequest("vehicles/{id}/command/sun_roof_control?state={state}&percent={percent}"); request.AddParameter("id", Id, ParameterType.UrlSegment); request.AddParameter("state", roofState.GetEnumValue(), ParameterType.UrlSegment); if (roofState == PanoramicRoofState.MOVE) { request.AddParameter("percent", percentOpen, ParameterType.UrlSegment); } var response = Client.Post(request); var json = JObject.Parse(response.Content)["response"]; var data = JsonConvert.DeserializeObject <ResultStatus>(json.ToString()); return(data); }