Ejemplo n.º 1
0
        public async void AddStatus(GoodweData goodweData)
        {
            PvOutputData pvOutputData = new PvOutputData()
            {
                EnergyGeneration = (int)(goodweData.ETotal * 1000),
                PowerGeneration  = goodweData.OutputPower,
                Date             = goodweData.TimeStamp.ToString("yyyyMMdd"),
                Time             = goodweData.TimeStamp.ToString("HH:mm"),
            };


            var parameters = new Dictionary <string, string> {
                { "d", pvOutputData.Date },
                { "t", pvOutputData.Time },
                { "v1", pvOutputData.EnergyGeneration.ToString() },
                { "v2", pvOutputData.PowerGeneration.ToString() }
            };

            var encodedContent = new FormUrlEncodedContent(parameters);

            //if (!HttpClient.DefaultRequestHeaders.Contains("X-Pvoutput-Apikey"))
            //{
            //	HttpClient.DefaultRequestHeaders.Add("X-Pvoutput-Apikey", "7399e14968f03ce6329da1c324737632d6320185");
            //	HttpClient.DefaultRequestHeaders.Add("X-Pvoutput-SystemId", "79017");
            //}

            var response = await HttpClient.PostAsync("addstatus.jsp", encodedContent);

            if (response.StatusCode == HttpStatusCode.OK)
            {
                var resultString = await response.Content.ReadAsStringAsync();
            }
        }
Ejemplo n.º 2
0
        private void SendDataToPvOutput(DomoticzData energyGenerationData, DomoticzData p1MeterData)
        {
            PvOutputData pvOutputData = new PvOutputData();

            pvOutputData.Date             = DateTime.Parse(energyGenerationData.Result[0].LastUpdate).ToString("yyyyMMdd");
            pvOutputData.Time             = DateTime.Parse(energyGenerationData.Result[0].LastUpdate).ToString("HH:mm");
            pvOutputData.EnergyGeneration = int.Parse(Regex.Replace(energyGenerationData.Result[0].CounterToday, "[^0-9]", ""));
            pvOutputData.PowerGeneration  = int.Parse(Regex.Replace(energyGenerationData.Result[0].Usage, "[^0-9]", ""));


            //Energy
            var counterToday  = p1MeterData.Result[0].CounterToday;
            var deliveryToday = p1MeterData.Result[0].CounterDelivToday;

            // Power
            var usage            = int.Parse(Regex.Replace(p1MeterData.Result[0].Usage, "[^0-9]", ""));
            var delivery         = int.Parse(Regex.Replace(p1MeterData.Result[0].UsageDeliv, "[^0-9]", ""));
            var powerConsumption = usage - delivery;

            pvOutputData.PowerConsumption = powerConsumption;

            PvOutputDataList.Add(pvOutputData);
            if (PvOutputDataList.Count > 50)
            {
                PvOutputDataList.RemoveAt(0);
            }

            PvOutputService.AddStatus(pvOutputData);

            InvokeAsync(StateHasChanged);
        }
Ejemplo n.º 3
0
        public async void AddStatus(PvOutputData pvOutputData)
        {
            var parameters = new Dictionary <string, string> {
                { "d", pvOutputData.Date },
                { "t", pvOutputData.Time },
                { "v1", pvOutputData.EnergyGeneration.ToString() },
                { "v2", pvOutputData.PowerGeneration.ToString() },
                { "v4", pvOutputData.PowerConsumption.ToString() },
                { "n", "1" }
            };

            var encodedContent = new FormUrlEncodedContent(parameters);

            try
            {
                var response = await HttpClient.PostAsync("addstatus.jsp", encodedContent);

                if (response.StatusCode == HttpStatusCode.OK)
                {
                    var resultString = await response.Content.ReadAsStringAsync();
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }