Esempio n. 1
0
        public async Task <FieldValueDto> GetFieldValueAsync(string authToken, string deviceId, FieldDescriptorDto field)
        {
            var uri = string.Format(baseUri, deviceId, field.Channel, field.Name);

            LambdaLogger.Log("Get field from: " + uri);
            SenMLDto senml = await _restClient.GetAsJsonAsync <SenMLDto>(authToken, uri);

            return(senml.e.FirstOrDefault());
        }
        /// <summary>
        /// Get a list of the devices that are tagged with "Alexa.SmartDevice"
        /// </summary>
        /// <param name="authToken"></param>
        /// <returns></returns>
        public async Task <List <DeviceDto> > GetDevicesAsync(string authToken)
        {
            var uri = string.Format(BaseUri, "");

            uri += "?tagged[]=Alexa.SmartDevice"; // not in production yet!
            List <DeviceDto> devices = await _restClient.GetAsJsonAsync <List <DeviceDto> >(authToken, uri);

            List <DeviceDto> filteredDevices = new List <DeviceDto>();

            foreach (var deviceDto in devices)
            {
                if (deviceDto.Tags != null)
                {
                    if (deviceDto.Tags.Contains("Alexa.SmartDevice"))
                    {
                        filteredDevices.Add(deviceDto);
                    }
                }
            }

            return(filteredDevices);
        }