def handle_platform_services(self, call) -> None: """Handle common services.""" service = call.service if self._config: if service == SERVICE_REFRESH_ACCESS: self._config.cognito = auth.refresh( user_id=self._config.cognito.user_id, refresh_token=self._config.cognito.refresh_token, ) account = WinixAccount(self._config.cognito.access_token) account.check_access_token() _LOGGER.info("Access token refreshed")
def _refresh(self): self.config.cognito = refresh( user_id=self.config.cognito.user_id, refresh_token=self.config.cognito.refresh_token, ) WinixAccount(self.config.cognito.access_token).check_access_token() self.config.save() print("Ok")
def _login(self): print( "You need to signup for a Winix account & associate your device in the phone app before using this." ) username = getattr(self.args, "username") or input("Username (email): ") password = getattr(self.args, "password") or getpass("Password: "******"Ok")
def login(self) -> None: """Login and setup platforms.""" config = self._config username = self._domain_config.get(CONF_USERNAME) password = self._domain_config.get(CONF_PASSWORD) try: config.cognito = auth.login(username, password) account = WinixAccount(config.cognito.access_token) account.register_user(username) account.check_access_token() config.devices = account.get_device_info_list() self._config = config device_stubs = self._config.devices _LOGGER.debug("Configuration initialized") self._hass.async_create_task( self.async_prepare_devices(device_stubs)) self.setup_services() except Exception as err: _LOGGER.error(err)
def execute(self): account = WinixAccount(self.config.cognito.access_token) self.config.devices = account.get_device_info_list() self.config.save() print("Ok")