From 70176ceababf33926023a8d0d073e15d1a8d6daf Mon Sep 17 00:00:00 2001 From: Joshua Rich Date: Fri, 27 Dec 2024 10:13:17 +1000 Subject: [PATCH] fix(agent): :bug: fix registration flow from changes in 7591c7a --- internal/agent/register.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/internal/agent/register.go b/internal/agent/register.go index 453505f0..e0ba35b6 100644 --- a/internal/agent/register.go +++ b/internal/agent/register.go @@ -31,7 +31,7 @@ func checkRegistration(ctx context.Context, agentUI ui) error { } // If not headless, present a UI for the user to configure options. - if options.headless { + if !options.headless { userInputDoneCh := agentUI.DisplayRegistrationWindow(ctx, registrationOptions) if canceled := <-userInputDoneCh; canceled { return ErrUserCancelledRegistration @@ -43,12 +43,15 @@ func checkRegistration(ctx context.Context, agentUI ui) error { if err != nil { return fmt.Errorf("device registration failed: %w", err) } - // Save the returned preferences. if err := preferences.SetHassPreferences(registrationDetails, registrationOptions); err != nil { return fmt.Errorf("saving registration failed: %w", err) } - + // Set registration status. + if err := preferences.SetRegistered(true); err != nil { + return fmt.Errorf("saving registration failed: %w", err) + } + // Save preferences to disk. if err := preferences.Save(); err != nil { return fmt.Errorf("saving registration failed: %w", err) }