Skip to content

Commit

Permalink
Switch cardprofile for snapcast
Browse files Browse the repository at this point in the history
  • Loading branch information
claes committed Dec 10, 2024
1 parent 3654f39 commit 5a2a072
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions internal/loop-snapcast.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ func (l *SnapcastLoop) ProcessEvent(ev MQTTEvent) []MQTTPublish {

l.parsePulseaudio(ev)
l.foo(ev)
l.remoteToggle(ev)

l.stateMachineMQTTBridge.stateValueMap.LogState()
slog.Debug("Fire event")
Expand Down Expand Up @@ -235,3 +236,15 @@ func (l *SnapcastLoop) foo(ev MQTTEvent) {
l.stateMachineMQTTBridge.stateValueMap.setState("snapcast", snapcast)
}
}

func (l *SnapcastLoop) remoteToggle(ev MQTTEvent) {
if ev.Topic == "zigbee2mqtt/media_remote" {
m := parseJSONPayload(ev)
action := m["action"].(string)
if action == "arrow_right_click" {
l.stateMachineMQTTBridge.stateValueMap.setState("snapcast", true)
} else if action == "arrow_left_click" {
l.stateMachineMQTTBridge.stateValueMap.setState("snapcast", false)
}
}
}

0 comments on commit 5a2a072

Please sign in to comment.