Exemplo n.º 1
0
        private void ProcessStateObj()
        {
            var state = _stateObj.State();

            _logger.Debug($"Action '{_sceneAction.Name}' state recent/now = '{_currentState.ToString()}/{state.ToString()}'");
            //if state the same nothing to do
            if (_currentState == state)
            {
                return;
            }

            if (state == ActionStateEnum.Active)
            {
                _logger.Info($"Action '{_sceneAction.Name}' activated");
                BecomeActive();

                //queue/schedule 'then's
                foreach (var mqttAction in _sceneAction.Then)
                {
                    _logger.Debug($"Action '{_sceneAction.Name}' Perform 'then' action publish to  {mqttAction.Topic} {(mqttAction.Delay==null?string.Empty:$"with delay {mqttAction.Delay}")}");
                    if (mqttAction.Delay == null)
                    {
                        Self.Tell(new DoThen(mqttAction));
                    }
                    else
                    {
                        Context.System.Scheduler.ScheduleTellOnce(mqttAction.Delay.Value, Self, new DoThen(mqttAction), Self);
                    }
                }
            }