Esempio n. 1
0
        private async Task <string> FetchWeatherData()
        {
            Uri uri = new OpenWeatherMapConfigurationParser(_logger).GetUri();

            using (var httpClient = new HttpClient())
                using (HttpResponseMessage result = await httpClient.GetAsync(uri))
                {
                    return(await result.Content.ReadAsStringAsync());
                }
        }
Esempio n. 2
0
        public JsonObject ExportStatusToJsonObject()
        {
            var result = new JsonObject();

            var configurationParser = new OpenWeatherMapConfigurationParser(_logger);

            result.SetNamedValue("uri", configurationParser.GetUri().ToString().ToJsonValue());

            result.SetNamedValue("situation", SituationSensor.GetSituation().ToJsonValue());
            result.SetNamedValue("temperature", TemperatureSensor.GetValue().ToJsonValue());
            result.SetNamedValue("humidity", HumiditySensor.GetValue().ToJsonValue());

            result.SetNamedValue("lastFetched", _lastFetched.ToJsonValue());
            result.SetNamedValue("lastFetchedDifferentResponse", _lastFetchedDifferentResponse.ToJsonValue());

            result.SetNamedValue("sunrise", _sunrise.ToJsonValue());
            result.SetNamedValue("sunset", _sunset.ToJsonValue());

            return(result);
        }