Skip to content

Commit

Permalink
Remove dead code (loops)
Browse files Browse the repository at this point in the history
  • Loading branch information
claes committed Dec 14, 2024
1 parent ef826d8 commit 746e65a
Show file tree
Hide file tree
Showing 10 changed files with 109 additions and 517 deletions.
7 changes: 7 additions & 0 deletions internal/controller-bedroom.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ import (
"github.com/qmuntal/stateless"
)

type blindsState int

const (
bedroomBlindsStateOpen blindsState = iota
bedroomBlindsStateClosed
)

type BedroomController struct {
BaseController
}
Expand Down
7 changes: 7 additions & 0 deletions internal/controller-kitchen.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ import (
"github.com/qmuntal/stateless"
)

type ampState int

const (
ampStateOn ampState = iota
ampStateOff
)

type KitchenController struct {
BaseController
}
Expand Down
5 changes: 5 additions & 0 deletions internal/controller-livingroom.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ import (
"github.com/qmuntal/stateless"
)

const (
stateLivingroomFloorlampOn = "LampOn"
stateLivingroomFloorlampOff = "LampOff"
)

type LivingroomController struct {
BaseController
}
Expand Down
82 changes: 82 additions & 0 deletions internal/controller-snapcast.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,28 @@ package regelverk
import (
"context"
"encoding/json"
"fmt"
"log/slog"
"reflect"
"regexp"
"time"

pulsemqtt "github.com/claes/pulseaudio-mqtt/lib"
snapcastmqtt "github.com/claes/snapcast-mqtt/lib"
"github.com/qmuntal/stateless"
)

type snapcastState int

var topicStreamRe = regexp.MustCompile(`snapcast/stream/([^/]+)$`)
var topicClientRe = regexp.MustCompile(`snapcast/client/([^/]+)$`)
var topicGroupRe = regexp.MustCompile(`snapcast/group/([^/]+)$`)

const (
stateSnapcastOn snapcastState = iota
stateSnapcastOff
)

type SnapcastController struct {
BaseController
snapcastServerState snapcastmqtt.SnapcastServer
Expand Down Expand Up @@ -145,3 +159,71 @@ func (c *SnapcastController) parsePulseaudio(ev MQTTEvent) {
}
}
}

func snapcastOnOutputTmp(sinkInputIndex uint32, sinkName string) []MQTTPublish {
result := []MQTTPublish{
{
Topic: "pulseaudio/sinkinput/req",
Payload: fmt.Sprintf(`{ "Command": "movesink", "SinkInputIndex": %d, "SinkName": "%s" }`, sinkInputIndex, sinkName),
Qos: 2,
Retained: false,
Wait: 0 * time.Second,
},
{
Topic: "snapcast/client/livingroom/stream/set",
Payload: "pulseaudio",
Qos: 2,
Retained: false,
Wait: 0 * time.Second,
},
{
Topic: "pulseaudio/cardprofile/0/set",
Payload: "output:iec958-stereo+input:analog-stereo",
Qos: 2,
Retained: false,
Wait: 0 * time.Second,
},
{
Topic: "rotel/command/send",
Payload: "opt2!",
Qos: 2,
Retained: false,
Wait: 0 * time.Second,
},
}
return result
}

func snapcastOffOutputTmp(sinkInputIndex uint32, sinkName string) []MQTTPublish {
result := []MQTTPublish{
{
Topic: "pulseaudio/cardprofile/0/set",
Payload: "output:hdmi-stereo", //TODO: switch this in advance?
Qos: 2,
Retained: false,
Wait: 0 * time.Second,
},
{
Topic: "pulseaudio/sinkinput/req",
Payload: fmt.Sprintf(`{ "Command": "movesink", "SinkInputIndex": %d, "SinkName": "%s" }`, sinkInputIndex, sinkName),
Qos: 2,
Retained: false,
Wait: 2 * time.Second,
},
{
Topic: "snapcast/client/livingroom/stream/set",
Payload: "default",
Qos: 2,
Retained: false,
Wait: 2 * time.Second,
},
{
Topic: "rotel/command/send",
Payload: "opt1!",
Qos: 2,
Retained: false,
Wait: 2 * time.Second,
},
}
return result
}
8 changes: 8 additions & 0 deletions internal/controller-tv.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ import (
"github.com/qmuntal/stateless"
)

type tvState int

const (
stateTvOn tvState = iota
stateTvOff
stateTvOffLong
)

type TVController struct {
BaseController
}
Expand Down
107 changes: 0 additions & 107 deletions internal/loop-bedroom.go

This file was deleted.

54 changes: 0 additions & 54 deletions internal/loop-kitchen.go

This file was deleted.

55 changes: 0 additions & 55 deletions internal/loop-livingroom.go

This file was deleted.

Loading

0 comments on commit 746e65a

Please sign in to comment.