コード例 #1
0
        /// <summary>
        /// Retrieve private or partner weather station data
        /// </summary>
        /// <param name="deviceId">leave null or empty to get all devices, specify to get target device</param>
        /// <param name="getfavorites">set to true to get favorited devices</param>
        public async Task <Response <NetatmoModuleData> > GetStationsData(string deviceId = null, bool getfavorites = false)
        {
            var content  = HttpContentCreator.CreateGetStationsDataHttpContent(deviceId, getfavorites);
            var response = await Request <NetatmoModuleData>(AppConstants.NetatmoGetStationsDataUrl, content);

            return(response);
        }
コード例 #2
0
        /// <summary>
        /// Retrieve private or partner thermostat data
        /// </summary>
        /// <param name="deviceId">leave null or empty to get all devices, specify to get target device</param>
        public async Task <Response <NetatmoThermostatModuleData> > GetThermostatData(string deviceId = null)
        {
            var content  = HttpContentCreator.CreateGetThermostatDataHttpContent(deviceId);
            var response = await Request <NetatmoThermostatModuleData>(AppConstants.NetatmoGetThermostatDataUrl, content);

            return(response);
        }
コード例 #3
0
        /// <summary>
        /// Retrieve measurements
        /// </summary>
        /// <param name="deviceId">device id to retrieve measurements for</param>
        /// <param name="scale">Scale for the measurements, not all Measurement Types support all scales for more info see "https://dev.netatmo.com/doc/methods/getmeasure"</param>
        /// <param name="measurementTypes">Measurement types to retrieve</param>
        /// <param name="onlyLastMeasurement">Retrieve only the last measurement</param>
        /// <param name="moduleId">id of the module to retirve if not supplied the measurements from the device will be fetched</param>
        /// <param name="optimize">optimize response data</param>
        /// <param name="begin">begin date of measurements to retrieve</param>
        /// <param name="end">end date of measurements to retrieve</param>
        /// <param name="limit">limit the measurements by a given amount, max = 1024</param>
        /// <param name="realtime">In scales higher than max, since the data is aggregated, the timestamps returned are by default offset by +(scale/2). </param>
        public async Task <Response <MeasurementData> > GetMeasure(string deviceId, Scale scale, MeasurementType[] measurementTypes, string moduleId = null, bool onlyLastMeasurement = false, DateTime?begin = null, DateTime?end = null, bool optimize = true, int limit = 1024, bool realtime = false)
        {
            var content  = HttpContentCreator.CreateGetMeasureHttpContent(deviceId, scale, measurementTypes, moduleId, onlyLastMeasurement, begin, end, optimize, limit, realtime);
            var response = await Request <MeasurementData>(AppConstants.NetatmoGetMeasureUrl, content);

            if (response.Success)
            {
                response.Result.CreateMeasurementData(optimize, measurementTypes);
            }

            return(response);
        }
コード例 #4
0
        private async Task <bool> RefreshToken()
        {
            var content  = HttpContentCreator.CreateRefreshTokenHttpContent(OAuthAccessToken.RefreshToken, ClientId, ClientSecret);
            var response = await Request <OAuthAccessToken>(AppConstants.NetatmoRequestTokenUrl, content, true);

            if (!response.Success)
            {
                return(false);
            }

            OAuthAccessToken = response.Result;
            return(true);
        }
コード例 #5
0
        /// <summary>
        /// Login to netatmo and retrieve an OAuthToken
        /// </summary>
        /// <param name="scopes"></param>
        public async void Login(NetatmoScope[] scopes)
        {
            var content  = HttpContentCreator.CreateLoginHttpContent(ClientId, ClientSecret, AppConstants.NetatmoAccount, AppConstants.NetatmoPassword, scopes);
            var response = await Request <OAuthAccessToken>(AppConstants.NetatmoRequestTokenUrl, content, true);

            if (response.Success)
            {
                OAuthAccessToken = response.Result;
                OnLoginSuccessful();
            }
            else
            {
                OnLoginFailed();
            }
        }