Skip to content

Commit

Permalink
Backend support for the rest of the release
Browse files Browse the repository at this point in the history
  • Loading branch information
hilli committed Feb 25, 2024
1 parent 84fd21f commit 3ee9ff3
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions kefw2/kefw2.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,18 @@ func (s *KEFSpeaker) UpdateInfo() (err error) {
if err != nil {
return err
}
s.getId()
s.getModelAndVersion()
s.GetMaxVolume()
err = s.getId()
if err != nil {
return fmt.Errorf("failed to get speaker IDs: %w", err)
}
err = s.getModelAndVersion()
if err != nil {
return fmt.Errorf("failed to get model and version information: %w", err)
}
_, err = s.GetMaxVolume() // Don't actually need the maxvol, but saving it to config.
if err != nil {
return fmt.Errorf("failed to get maxvol: %w", err)
}
return nil
}

Expand Down Expand Up @@ -152,11 +161,20 @@ func (s KEFSpeaker) SetSource(source Source) error {
return s.setTypedValue(path, source)
}

func (s *KEFSpeaker) Source() (source Source, err error) {
src, err2 := JSONUnmarshalValue(s.getData("settings:/kef/play/physicalSource"))
func (s *KEFSpeaker) Source() (Source, error) {
data, err := s.getData("settings:/kef/play/physicalSource")
src, err2 := JSONUnmarshalValue(data, err)
return src.(Source), err2
}

func (s *KEFSpeaker) CanControlPlayback() (bool, error) {
source, err := s.Source()
if err != nil {
return false, fmt.Errorf("failed getting speaker source: %w", err)
}
return (source != SourceWiFi || source != SourceBluetooth), nil
}

func (s *KEFSpeaker) IsPoweredOn() (bool, error) {
powerState, err := JSONUnmarshalValue(s.getData("settings:/kef/host/speakerStatus"))
if powerState == SpeakerStatusOn {
Expand Down

0 comments on commit 3ee9ff3

Please sign in to comment.