Exemplo n.º 1
0
 public void Initialize()
 {
     hassEventArgs = new HassEventArgs(_roomConfig.Name, "RoomInit");
     try
     {
         LogInfoJson(hassEventArgs, "Start", data: new
         {
             _roomConfig,
             Scheduler?.Now,
             _tracePrefix,
             _normalTimeout   = _normalTimeout.TotalSeconds,
             _nightTimeout    = _nightTimeout.TotalSeconds,
             _overrideTimeout = _overrideTimeout.TotalSeconds,
             _presenceEntityIds,
             _controlEntityIds,
             _nightControlEntityIds,
             _keepAliveEntityIds,
             NdUserId
         });
         VerifyConfig(_roomConfig);
         SetupEnabledSwitchEntity();
         IsDisabled();
         SetupSubscriptions();
         StartGuardDog();
         LogTrace("Initialize Complete");
     }
     catch (Exception e)
     {
         _app.LogError(e, "Error in Initialize");
         throw;
     }
 }
Exemplo n.º 2
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;
            }
        }
 public void Initialize()
 {
     try
     {
         LogTrace("Initialize Started");
         VerifyConfig(_roomConfig);
         LogConfig(_roomConfig);
         SetupEnabledSwitchEntity();
         IsDisabled();
         SetupSubscriptions();
         StartGuardDog();
         LogTrace("Initialize Complete");
     }
     catch (Exception e)
     {
         _app.LogError(e, "Error in Initialize");
         throw;
     }
 }