Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor #27

Merged
merged 12 commits into from
Jan 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@ fhomed.1

# GoReleaser
dist/

*.iml
13 changes: 13 additions & 0 deletions .run/fhomed --homekit --debug.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="fhomed --homekit --debug" type="GoApplicationRunConfiguration" factoryName="Go Application" focusToolWindowBeforeRun="true">
<module name="fhome" />
<working_directory value="$PROJECT_DIR$" />
<parameters value="--homekit --debug" />
<kind value="PACKAGE" />
<package value="github.com/bartekpacia/fhome/cmd/fhomed" />
<directory value="$PROJECT_DIR$" />
<filePath value="$PROJECT_DIR$" />
<pty_enabled value="true" />
<method v="2" />
</configuration>
</component>
214 changes: 0 additions & 214 deletions cmd/fhomed/daemon.go

This file was deleted.

71 changes: 0 additions & 71 deletions cmd/fhomed/hack.go

This file was deleted.

10 changes: 8 additions & 2 deletions cmd/fhomed/homekit/homekit.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"context"
"fmt"
"log"
"log/slog"
"strings"

"github.com/bartekpacia/fhome/api"
Expand Down Expand Up @@ -116,14 +117,19 @@ func (c *Client) SetUp(cfg *api.Config) (*Home, error) {

bridge := accessory.NewBridge(accessory.Info{Name: c.Name})

fs := hap.NewFsStore("./db")
fs := hap.NewFsStore("./db") // TODO: Create this in ~/.local/state/fhomed
server, err := hap.NewServer(fs, bridge.A, accessories...)
if err != nil {
log.Panic(err)
}
server.Pin = c.PIN

go server.ListenAndServe(context.Background())
go func() {
err := server.ListenAndServe(context.Background())
if err != nil {
slog.Error("failed to start HAP server", slog.Any("error", err))
}
}()

return &Home{
Lightbulbs: lightbulbMap,
Expand Down
Loading
Loading