Ejemplo n.º 1
0
        public async Task <bool> Start()
        {
            _aircoManager = new AircoManager(_httpClientFactory.CreateClient());

            if (!string.IsNullOrEmpty(_config.AuthCode))
            {
                _aircoManager.SetAuthorizationToken(_config.AuthCode);

                _schedulerService.AddPolling(PollingConds, "PANASONIC_AIR_CONDITIONER",
                                             SchedulerServicePollingEnum.NORMAL_POLLING);
            }
            else if (!string.IsNullOrEmpty(_config.Username))
            {
                var result = await _aircoManager.Login("0", _config.Username, _config.Password);

                if (result.Result == 0)
                {
                    _config.AuthCode = result.UToken;

                    _componentsService.SaveComponentConfig(_config);
                }
            }

            return(true);
        }
Ejemplo n.º 2
0
        private async Task <bool> Login()
        {
            try
            {
                if (string.IsNullOrEmpty(_panasonicAirVault.AccessToken))
                {
                    var result = await _aircoManager.Login("0", Config.Username, Config.Password);

                    _panasonicAirVault.AccessToken = result.UToken;
                    SaveVault(_panasonicAirVault);
                    _isConfigured = true;
                }
                else
                {
                    _aircoManager.SetAuthorizationToken(_panasonicAirVault.AccessToken);
                    _isConfigured = true;
                }

                return(true);
            }
            catch (Exception e)
            {
                Logger.LogError($"Error during login {e.Message}");

                return(false);
            }
        }
Ejemplo n.º 3
0
        static async Task <int> Login(LoginOptions options)
        {
            var response = await _manager.Login("0", options.LoginId, options.Password);

            Console.WriteLine($"Login succesful. Storing token {response.UToken}");

            SetToken(response.UToken);

            return(0);
        }