Skip to content

Commit

Permalink
Refactor (#27)
Browse files Browse the repository at this point in the history
* refactor `fhomed` to prepare it for influxdb-streaming feature

* more wip

* restructuring and refactoring WIP

* get rid of influxdb

* uh

* get rid of docker-compose

* print warning when failed to start HAP server

* cleanuos

* yay

* gofumpt

* webserver: add comment
  • Loading branch information
bartekpacia authored Jan 1, 2025
1 parent a3cfd9e commit 432bd15
Show file tree
Hide file tree
Showing 12 changed files with 356 additions and 297 deletions.
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

0 comments on commit 432bd15

Please sign in to comment.