コード例 #1
0
ファイル: TeslaVehicle.cs プロジェクト: razfriman/TeslaLib
        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));
        }
コード例 #2
0
        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));
        }
コード例 #3
0
ファイル: TeslaVehicle.cs プロジェクト: mangzee/TeslaLib
        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);
        }
コード例 #4
0
ファイル: TeslaClient.cs プロジェクト: tallichet/teslalib
        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);
        }