Пример #1
0
        public RoomPresenceImplementation(INetDaemonRxApp app, PresenceConfig presenceConfig, IRandomController controller)
        {
            _app            = app;
            _presenceConfig = presenceConfig;
            _controller     = controller;

            try
            {
                _roomConfig    = presenceConfig.RoomConfig;
                Scheduler      = presenceConfig.Scheduler;
                _tracePrefix   = $"({_roomConfig.Name}) - ";
                _normalTimeout = TimeSpan.FromSeconds(presenceConfig.RoomConfig.Timeout != 0
                    ? presenceConfig.RoomConfig.Timeout
                    : 300);
                _nightTimeout = TimeSpan.FromSeconds(presenceConfig.RoomConfig.NightTimeout != 0
                    ? presenceConfig.RoomConfig.NightTimeout
                    : 60);
                _overrideTimeout = TimeSpan.FromSeconds(presenceConfig.RoomConfig.OverrideTimeout != 0
                    ? presenceConfig.RoomConfig.OverrideTimeout
                    : 900);
                _presenceEntityIds     = presenceConfig.RoomConfig.PresenceEntityIds?.ToArray() ?? Array.Empty <string>();
                _controlEntityIds      = presenceConfig.RoomConfig.ControlEntityIds.ToArray();
                _nightControlEntityIds = presenceConfig.RoomConfig.NightControlEntityIds.ToArray();
                _keepAliveEntityIds    = presenceConfig.RoomConfig.KeepAliveEntityIds.ToArray();
                NdUserId = presenceConfig.NdUserId;
            }
            catch (Exception e)
            {
                _app.LogError(e, "Error in Constructor");
                throw;
            }
        }
Пример #2
0
        private void LogConfig(RoomConfig roomConfig)
        {
            LogTrace("LogConfig");

            var jsonConfig = ToJson(roomConfig);

            LogTrace($"{nameof(roomConfig)} for: {roomConfig.Name}");
            LogTrace(jsonConfig, new { });
        }
 private void LogConfig(RoomConfig roomConfig)
 {
     LogTrace("LogConfig");
     LogTrace($"{nameof(roomConfig)} name: {roomConfig.Name}");
     _app.LogInformation($"Config for roomConfig: {roomConfig.Name}"
                         + $"\n  Timeout: {_normalTimeout}"
                         + $"\n  NightTimeout: {_nightTimeout}"
                         + $"\n  LuxLimit: {LuxLimit()}"
                         + $"\n  LuxEntityId: {roomConfig.LuxEntityId}"
                         + $"\n  LuxLimitEntityId: {roomConfig.LuxLimitEntityId}"
                         + $"\n  NightTimeEntityId: {roomConfig.NightTimeEntityId}"
                         + $"\n  PresenceEntityIds:\n   - {string.Join("\n   - ", _presenceEntityIds)}"
                         + $"\n  KeepAliveEntityIds:\n   - {string.Join("\n   - ", _keepAliveEntityIds)}"
                         + $"\n  ControlEntityIds:\n   - {string.Join("\n   - ", _controlEntityIds)}"
                         + $"\n  NightControlEntityIds:\n   - {string.Join("\n   - ", _nightControlEntityIds)}\n"
                         );
 }
Пример #4
0
        private void VerifyConfig(RoomConfig roomConfig)
        {
            var entities = _roomConfig.ControlEntityIds
                           .Union(_roomConfig.PresenceEntityIds)
                           .Union(_roomConfig.KeepAliveEntityIds)
                           .Union(_roomConfig.NightControlEntityIds)
                           .Union(new List <string> {
                _roomConfig.LuxEntityId ?? "", _roomConfig.LuxLimitEntityId ?? "", _roomConfig.NightTimeEntityId ?? "", roomConfig.ConditionEntityId
            })
                           .Where(e => !string.IsNullOrEmpty(e))
                           .ToList();

            var invalidEntities = entities.Except(_app.States.Select(s => s.EntityId)).ToList();

            if (invalidEntities.Any())
            {
                _app.LogError($"{_roomConfig.Name} contains the following invalid EntityIds:\n{string.Join("\n  - ", invalidEntities)}");
            }
        }
Пример #5
0
 public PresenceConfig(RoomConfig roomConfig)
 {
     RoomConfig = roomConfig;
 }