예제 #1
0
        private async void UpdateLightsStatus()
        {
            try
            {
                var lights = await _hueClient.GetLightsAsync();

                lights.ToList().ForEach(s =>
                {
                    var entity = new PhilipsHueEd
                    {
                        EntityName  = s.Name,
                        Brightness  = s.State.Brightness,
                        Hue         = s.State.Hue ?? -1,
                        IsOn        = s.State.On,
                        IsReachable = s.State.IsReachable ?? false,
                        Type        = PhilipsHueTypeEnum.LIGHT
                    };

                    _ioTService.InsertEvent(entity);
                });
            }
            catch (Exception ex)
            {
                _logger.LogError($"Error during update light status: {ex}");
            }
        }
예제 #2
0
        private async void UpdateLightGroupsStatus()
        {
            try
            {
                var groups = await _hueClient.GetGroupsAsync();

                groups.ToList().ForEach(g =>
                {
                    var entity = new PhilipsHueEd
                    {
                        EntityName = g.Name,
                        IsOn       = g.State?.AllOn == null ? g.State.AllOn.Value : false,
                        Type       = PhilipsHueTypeEnum.GROUP
                    };

                    _ioTService.InsertEvent(entity);
                });
            }
            catch (Exception ex)
            {
                _logger.LogError($"Error during update light group status: {ex}");
            }
        }