Beispiel #1
0
        public async Task <IReadOnlyList <PhilipsHueUsernameDiscoveryModel> > AutoDetectUsername()
        {
            var isBridgeReachable = await IsBridgeReachable().ConfigureAwait(false);

            if (!isBridgeReachable)
            {
                throw new Exception(GetBridgeNotFoundErrorMessage());
            }

            var device = new PhilipsHueDeviceTypeModel(string.Empty);

            return(await AttemptAndRetry(() => _philipsHueBridgeApiClient.AutoDetectUsername(device), 1).ConfigureAwait(false));
        }
Beispiel #2
0
        public static async ValueTask <List <PhilipsHueUsernameDiscoveryModel> > AutoDetectUsername(string philipsHueBridgeIPAddress)
        {
            var isBridgeReachable = IsBridgeReachable(philipsHueBridgeIPAddress);

            if (!isBridgeReachable)
            {
                throw new Exception(GetBridgeNotFoundErrorMessage());
            }

            var deviceType = new PhilipsHueDeviceTypeModel {
                DeviceType = string.Empty
            };

            return(await PostObjectToAPI <List <PhilipsHueUsernameDiscoveryModel>, PhilipsHueDeviceTypeModel>($"http://{philipsHueBridgeIPAddress}/api", deviceType).ConfigureAwait(false));
        }