internal async Task <MeasuresData> GetMeasure(string deviceId, MeasureScale scale, MeasuresFilters measureType, DateTime?dateBegin, DateTime?dateEnd, string moduleId = "", int limit = 1024)
        {
            if (!await CheckConnectionAsync().ConfigureAwait(false))
            {
                return(null);
            }
            var parameters = HttpUtility.ParseQueryString(string.Empty);

            parameters["access_token"] = _accessToken;
            parameters["device_id"]    = deviceId;
            parameters["scale"]        = scale.ToJsonString();
            parameters["type"]         = measureType.ToJsonString();
            if (dateBegin != null)
            {
                parameters["date_begin"] = dateBegin.FromLocalDateTime().ToString(CultureInfo.InvariantCulture);
            }
            if (dateEnd != null)
            {
                parameters["date_end"] = dateEnd.FromLocalDateTime().ToString(CultureInfo.InvariantCulture);
            }
            parameters["optimize"] = true.ToString(CultureInfo.InvariantCulture).ToUpperInvariant();
            parameters["limit"]    = limit.ToString(CultureInfo.InvariantCulture);
            if (moduleId.Length > 0)
            {
                parameters["module_id"] = moduleId;
            }

            using (HttpClient client = new HttpClient())
                using (HttpRequestMessage request = new HttpRequestMessage())
                {
                    request.Method     = HttpMethod.Post;
                    request.RequestUri = new Uri(host + apiPath + "/getmeasure");
                    request.Content    = new StringContent(parameters.ToString(), Encoding.UTF8, "application/x-www-form-urlencoded");
                    HttpResponseMessage response = await client.SendAsync(request).ConfigureAwait(false);

                    string responseBody = await response.Content.ReadAsStringAsync().ConfigureAwait(false);

                    MeasuresData measuresData = new MeasuresData().FromJson(responseBody);
                    if (measuresData.Content == null)
                    {
                        ErrorMessageData errorMessageData = new ErrorMessageData().FromJson(responseBody);
                        _errorMessage = errorMessageData.Error.Message;
                        return(null);
                    }
                    return(measuresData);
                }
        }
        internal async Task <RoomMeasures> GetRoomMeasures(string homeId, string roomId, MeasureScale scale, MeasuresFilters measureType, DateTime?dateBegin, DateTime?dateEnd, int limit = 1024)
        {
            if (!await CheckConnectionAsync().ConfigureAwait(false))
            {
                return(null);
            }
            var parameters = HttpUtility.ParseQueryString(string.Empty);

            parameters["home_id"] = homeId;
            parameters["room_id"] = roomId;
            parameters["scale"]   = scale.ToJsonString();
            parameters["type"]    = measureType.ToJsonString();
            if (dateBegin != null)
            {
                parameters["date_begin"] = dateBegin.FromLocalDateTime().ToString(CultureInfo.InvariantCulture);
            }
            if (dateEnd != null)
            {
                parameters["date_end"] = dateEnd.FromLocalDateTime().ToString(CultureInfo.InvariantCulture);
            }
            parameters["optimize"] = true.ToString(CultureInfo.InvariantCulture).ToUpperInvariant();
            parameters["limit"]    = limit.ToString(CultureInfo.InvariantCulture);

            using (HttpClient client = new HttpClient())
                using (HttpRequestMessage request = new HttpRequestMessage())
                {
                    request.Method     = HttpMethod.Post;
                    request.RequestUri = new Uri(host + apiPath + "/getroommeasure");

                    request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", _accessToken);
                    request.Content = new StringContent(parameters.ToString(), Encoding.UTF8, "application/x-www-form-urlencoded");
                    HttpResponseMessage response = await client.SendAsync(request).ConfigureAwait(false);

                    string responseBody = await response.Content.ReadAsStringAsync().ConfigureAwait(false);

                    RoomMeasures roomMeasures = new RoomMeasures().FromJson(responseBody);
                    if (roomMeasures.Body == null)
                    {
                        ErrorMessageData errorMessageData = new ErrorMessageData().FromJson(responseBody);
                        _errorMessage = errorMessageData.Error.Message;
                        return(null);
                    }
                    return(roomMeasures);
                }
        }