Documentation ¶
Index ¶
- Constants
- Variables
- func DumpZones(log *log.Entry, s Speaker)
- func GetDevices(conf NetworkConfig) (speakers chan *Speaker)
- func LookupSpeakers(iface *net.Interface) <-chan *Speaker
- func LookupStaticSpeakers(speakerIPs []string) <-chan *Speaker
- func OpenInterface(interfaceName string) *net.Interface
- func SearchDevices(conf NetworkConfig) (speakers chan *Speaker)
- type Component
- type ConnectionStateUpdated
- type ContentItem
- type InfluxDB
- type Info
- type Initializer
- type Key
- type Member
- type MultiRoomZone
- type NetworkConfig
- type NowPlaying
- type PlayStatus
- type Plugin
- type PluginConfig
- type PluginFunc
- type Preset
- type Presets
- type Source
- type SourceItem
- type Sources
- type Speaker
- func (s *Speaker) AddPlugin(uhc Plugin)
- func (s *Speaker) AddZoneSlave(zi MultiRoomZone) error
- func (s *Speaker) Close() error
- func (s *Speaker) DeviceID() (name string)
- func (s *Speaker) Disable(pluginName string)
- func (s *Speaker) Execute(msgChan chan *Update)
- func (s *Speaker) GetData(action string) ([]byte, error)
- func (s *Speaker) GetZone() (Zone, error)
- func (s *Speaker) GetZoneMembers() []Member
- func (s *Speaker) HasPlugin(name string) bool
- func (s *Speaker) HasZone() bool
- func (s *Speaker) Info() (Info, error)
- func (s *Speaker) IsAlive() bool
- func (s *Speaker) IsMaster() bool
- func (s *Speaker) IsPoweredOn() bool
- func (s *Speaker) IsSpeakerMember(members []Member) bool
- func (s *Speaker) Listen() (chan *Update, error)
- func (s *Speaker) Name() (name string)
- func (s *Speaker) NowPlaying() (NowPlaying, error)
- func (s *Speaker) PowerOff() bool
- func (s *Speaker) PowerOn() bool
- func (s *Speaker) PowerOnWithVolume(vol int) bool
- func (s *Speaker) Presets() (Presets, error)
- func (s *Speaker) PressKey(key Key) error
- func (s *Speaker) RemovePlugin(name string)
- func (s *Speaker) Select(item ContentItem) error
- func (s *Speaker) SetData(action string, input []byte) ([]byte, error)
- func (s *Speaker) SetVolume(volume int) error
- func (s *Speaker) SetZone(zi MultiRoomZone) error
- func (s *Speaker) Sources() (Sources, error)
- func (s *Speaker) Volume() (Volume, error)
- type Speakers
- type Update
- type Volume
- type Zone
- type ZoneSlave
Constants ¶
const ( PlayState = "PLAY_STATE" PauseState = "PAUSE_STATE" BufferingState = "BUFFERING_STATE" InvalidPlayStatus = "INVALID_PLAY_STATUS" StopState = "STOP" Standby = "STANDBY" )
All Playing states of soundtouch speaker
const ( Slave = "SLAVE_SOURCE" InternetRadio = "INTERNET_RADIO" LocalInternetRadio = "LOCAL_INTERNET_RADIO" Pandora = "PANDORA" TuneIn = "TUNEIN" Airplay = "AIRPLAY" StoredMusic = "STORED_MUSIC" Aux = "AUX" Bluetooth = "BLUETOOTH" Product = "PRODUCT" OffSource = "OFF_SOURCE" CurratedRadio = "CURRATED_RADIO" UPDATE = "UPDATE" Deezer = "DEEZER" Spotify = "SPOTIFY" Alexa = "ALEXA" IHeart = "IHEART" )
All Sources of a soundtouch speaker
const ( RadioStreaming = "RADIO_STREAMING" TrackOnDemand = "TRACK_ONDEMAND" RadioTracks = "RADIO_TRACKS" // like Alexa )
All StreamTypes
const ( // PRESS KEY Values PLAY = "PLAY" PAUSE = "PAUSE" PLAYPAUSE = "PLAY_PAUSE" PREVTRACK = "PREV_TRACK" NEXTTRACK = "NEXT_TRACK" MUTE = "MUTE" SHUFFLEON = "SHUFFLE_ON" SHUFFLEOFF = "SHUFFLE_OFF" REPEATONE = "REPEAT_ONE" REPEATALL = "REPEAT_ALL" REPEATOFF = "REPEAT_OFF" ADDFAVORITE = "ADD_FAVORITE" REMOVEFAVORITE = "REMOVE_FAVORITE" THUMBSUP = "THUMBS_UP" THUMBSDOWN = "THUMBS_DOWN" BOOKMARK = "BOOKMARK" // PRESS or RELEASE Values PRESET1 = "PRESET_1" PRESET2 = "PRESET_2" PRESET3 = "PRESET_3" PRESET4 = "PRESET_4" PRESET5 = "PRESET_5" PRESET6 = "PRESET_6" // PRESS and RELEASE Values POWER = "POWER" )
All soundtouch key constants according: http://developer.bose.com/guides/bose-soundtouch-api/bose-soundtouch-api-reference
const (
WIFI = "NETWORK_WIFI_CONNECTED"
)
All network connection types
Variables ¶
var ALLKEYS = []string{ PLAY, PAUSE, PLAYPAUSE, PREVTRACK, NEXTTRACK, THUMBSUP, THUMBSDOWN, BOOKMARK, POWER, MUTE, PRESET1, PRESET2, PRESET3, PRESET4, PRESET5, PRESET6, SHUFFLEOFF, SHUFFLEON, REPEATOFF, REPEATONE, REPEATALL, ADDFAVORITE, REMOVEFAVORITE, }
ALLKEYS contains all KEY constant that can be sent to soundtouch
var ALLSOURCES = []string{ Slave, InternetRadio, LocalInternetRadio, Pandora, TuneIn, Airplay, StoredMusic, Aux, Bluetooth, Product, OffSource, CurratedRadio, UPDATE, Deezer, Spotify, IHeart, }
ALLSOURCES contains all soundtouch sources
var ALLSTATES = []string{ PlayState, PauseState, BufferingState, InvalidPlayStatus, StopState, Standby, }
ALLSTATES contains all soundtouch state constants
var ALLSTREAMS = []string{ RadioStreaming, TrackOnDemand, }
ALLSTREAMS contains all soundtouch streamtypes
Functions ¶
func GetDevices ¶
func GetDevices(conf NetworkConfig) (speakers chan *Speaker)
GetDevices starts listening on the indicated interface for the speakers to listen for. passes to speakers the series of speakers that are handled for further processing. Closes the speaker channel after all speakers found.
func LookupSpeakers ¶
LookupSpeakers listens via mdns for soundtouch speakers and returns Speaker channel
func LookupStaticSpeakers ¶
LookupSpeakers listens via mdns for soundtouch speakers and returns Speaker channel
func SearchDevices ¶
func SearchDevices(conf NetworkConfig) (speakers chan *Speaker)
SearchDevices searches on the indicated interface for the speakers to listen for. passes to speakers the series of speakers that are handled for further processing. Keeps the speaker channel open for additional speakers.
Types ¶
type Component ¶
type Component struct { ComponentCategory string `xml:"componentCategory" json:",omitempty"` SoftwareVersion string `xml:"softwareVersion" json:",omitempty"` SerialNumber string `xml:"serialNumber" json:",omitempty"` }
Component contains some component information
type ConnectionStateUpdated ¶
type ConnectionStateUpdated struct { // state="NETWORK_WIFI_CONNECTED" up="true" signal="MARGINAL_SIGNAL" State string `xml:"state,attr"` Up string `xml:"up,attr"` Signal string `xml:"signal,attr"` }
ConnectionStateUpdated defines the message communicated with the soundtouch system
func (ConnectionStateUpdated) String ¶
func (c ConnectionStateUpdated) String() string
String readable representation of message
type ContentItem ¶
type ContentItem struct { Type string `xml:"type,attr" json:",omitempty"` Source Source `xml:"source,attr" json:",omitempty"` Location string `xml:"location,attr" json:",omitempty"` Name string `xml:"itemName" json:",omitempty"` IsPresetable bool `xml:"isPresetable,attr"` }
ContentItem describe a playable item
type InfluxDB ¶
InfluxDB configures access to the influxdb instance
type Info ¶
type Info struct { DeviceID string `xml:"deviceID,attr" json:",omitempty"` Name string `xml:"name" json:",omitempty"` Type string `xml:"type" json:",omitempty"` IPAddress []string `xml:"networkInfo>ipAddress"` Component []Component `xml:"components>component" json:",omitempty"` MargeUrl string `xml:"margeURL" json:",omitempty"` ModuleType string `xml:"moduleType" json:",omitempty"` Variant string `xml:"variant" json:",omitempty"` VariantMode string `xml:"variantMode" json:",omitempty"` CountryCode string `xml:"countryCode" json:",omitempty"` RegionCode string `xml:"regionCode" json:",omitempty"` Raw []byte `json:"-"` }
Info defines the Info command for the soundtouch system
type Initializer ¶
type Initializer interface { // Init performs one time setup of the plugin and returns an error if the // configuration is invalid. Init() error }
Initializer is an interface that all plugin can optionally implement to initialize the plugin.
type MultiRoomZone ¶
type MultiRoomZone struct { XMLName xml.Name `xml:"zone"` Members []Member `xml:"member"` Master string `xml:"master,attr"` SenderIPAddress string `xml:"senderIPAddress,attr"` }
MultiRoomZone defines a zone with members
func NewZone ¶
func NewZone(master, slave Speaker) MultiRoomZone
type NetworkConfig ¶
type NetworkConfig struct { InterfaceName string NoOfSystems int SpeakerToListenFor []string StaticIPAddresses []string Plugins []Plugin }
NetworkConfig describes the soundtouch network InterfaceName as the network interface to listen, e.g. "en0" NoOfSystems is the number of expected systems. Searching for at least this amount of systems SpeakerToListenFor contains the defined list of speakers we are handling Plugins the list of handlers of handlers to be used.
type NowPlaying ¶
type NowPlaying struct { PlayStatus PlayStatus `xml:"playStatus" json:",omitempty"` Source string `xml:"source,attr" json:",omitempty"` SourceAccount string `xml:"sourceAccount,attr" json:",omitempty"` DeviceID string `xml:"deviceID,attr" json:",omitempty"` Content ContentItem `xml:"ContentItem" json:",omitempty"` Track string `xml:"track" json:",omitempty"` Artist string `xml:"artist" json:",omitempty"` Album string `xml:"album" json:",omitempty"` TrackID string `xml:"trackID" json:",omitempty"` Art string `xml:"art" json:",omitempty"` StreamType string `xml:"streamType" json:",omitempty"` Raw []byte `json:"-"` }
NowPlaying defines the now_playing message to/from soundtouch system
type Plugin ¶
type Plugin interface { // SampleConfig returns the default configuration of the Input SampleConfig() string // Description returns a one-sentence description on the Input Description() string // Execute operates on one update message Execute(pluginName string, update Update, speaker Speaker) // Disable temporarely the execution of the plugin Disable() // Enable temporarely the execution of the plugin Enable() // Name returns the name of the plugin Name() string // Terminate indicates that no further plugin will be executed on this speaker Terminate() bool // IsEnabled returns true if the plugin is not suspened IsEnabled() bool }
Plugin interface for that can handle valid update params
type PluginConfig ¶
type PluginConfig struct { Name string Speakers []string Suspended bool Pfunction PluginFunc }
PluginConfig describes an Plugin. It has a Name to be able to remove again Speakers list of SpeakerNames the handler is added. All if empty Terminate indicates whether this is the last handler to be called Suspended indicates that the plugin is temporarely suspended Plugin the plugin function
type PluginFunc ¶
PluginFunc turns a function with the right signature into a update handler
type Preset ¶
type Preset struct { ID int `xml:"id,attr"` Content ContentItem `xml:"ContentItem"` }
Preset specifies a preset field in soundtouch messages
type Presets ¶
type Presets struct { DeviceID string `xml:"deviceID,attr" json:",omitempty"` Presets []Preset `xml:"preset"` Raw []byte `json:"-"` }
Presets specifies the Presets Update message
type SourceItem ¶
type SourceItem struct { Source Source `xml:"source,attr" json:",omitempty"` SourceAccount string `xml:"sourceAccount,attr" json:",omitempty"` Status string `xml:"status,attr" json:",omitempty"` Local bool `xml:"isLocal,attr" json:",omitempty"` Value string `xml:",innerxml" json:",omitempty"` }
SourceItem defines a source within a soundtouch system
type Sources ¶
type Sources struct { DeviceID string `xml:"deviceID,attr" json:",omitempty"` SourceItems []SourceItem `xml:"sourceItem"` Raw []byte `json:"-"` }
Sources defines the soundtouch sources command
type Speaker ¶
type Speaker struct { IP net.IP Port int BaseHTTPURL url.URL WebSocketURL url.URL DeviceInfo Info WebSocketCh chan *Update Plugins []Plugin // contains filtered or unexported fields }
Speaker defines a soundtouch speaker
func GetSpeaker ¶
GetSpeaker returns the Speaker instance the Update has been send from
func GetSpeakerByDeviceId ¶
GetSpeakerByDeviceId retuns a speaker for a given DeviceId
func GetSpeakerByName ¶
GetSpeakerByName retuns a speaker for a given name
func NewIPSpeaker ¶
NewIPSpeaker creates a new speaker for the given ipAdress
func NewMdnsSpeaker ¶
func NewMdnsSpeaker(entry *mdns.ServiceEntry) *Speaker
NewMdnsSpeaker returns a new Speaker entity based on a mdns service entry
func (*Speaker) AddZoneSlave ¶
func (s *Speaker) AddZoneSlave(zi MultiRoomZone) error
AddZoneSlave sends the addZoneSlave command to the soundtouch system To be send to the master and should contain only new speakers to add
func (*Speaker) DeviceID ¶
DeviceID returns the speakers DeviceID as indicated in the info message, or "" if name unknwon
func (*Speaker) GetData ¶
GetData returns received raw data retrieved a GET for a given soundtouch action
func (*Speaker) GetZone ¶
GetZone sends the getZone command to the soundtouch system and returns the zone
func (*Speaker) GetZoneMembers ¶
GetZoneMembers returns the Members of the zone the speaker is a member
func (*Speaker) HasPlugin ¶
HasPlugin returns true if speaker has an UpdateHandler named name. False otherwise
func (*Speaker) IsPoweredOn ¶
IsPoweredOn returns true in case the soundtouch system is not in standby but powered
func (*Speaker) IsSpeakerMember ¶
func (*Speaker) Name ¶
Name returns the speakers name as indicated in the info message, or "" if name unknwon
func (*Speaker) NowPlaying ¶
func (s *Speaker) NowPlaying() (NowPlaying, error)
NowPlaying sends the now_playing command to the soundtouch system
func (*Speaker) PowerOff ¶
PowerOff powers off the soundtouch systems. True on success. Returns false in case it was already powered off.
func (*Speaker) PowerOn ¶
PowerOn switches the soundtouch system on. True on success. Returns false in case the system was already powered
func (*Speaker) PowerOnWithVolume ¶
PowerOnWithVolume switches the soundtouch system on and set's a specific volume. True on success. Returns false in case the system was already powered with no volume set.
func (*Speaker) PressKey ¶
PressKey sends key press command to soundtouch system. For POWER also release is send immediatly afterwards.
func (*Speaker) RemovePlugin ¶
func (*Speaker) Select ¶
func (s *Speaker) Select(item ContentItem) error
Select sends the select command to the soundtouch system
func (*Speaker) SetVolume ¶
SetVolume sends the volume command to the soundtouch system to set the volume
func (*Speaker) SetZone ¶
func (s *Speaker) SetZone(zi MultiRoomZone) error
SetZone sends the addZoneSlave command to the soundtouch system creates a multi-room zone
type Speakers ¶
func GetKnownDevices ¶
func GetKnownDevices() Speakers
GetKnownDevices returns a map of the already seen speakers
type Update ¶
type Update struct { DeviceID string Value interface{} }
Update carries all update messages communicated to/from soundtouch system
func (Update) ContentItem ¶
func (u Update) ContentItem() ContentItem
ContentItem returns the ContentItem if present, or an empty one if not present
func (Update) HasContentItem ¶
HasContentItem returns true if the Update message has contentItem, false else
func (Update) Is ¶
Is returns true in case Update message is of type msgTypeName is one of - ConnectionStateUpdated - Volume - NowPlaying - Preset
type Volume ¶
type Volume struct { DeviceID string `xml:"deviceID,attr"` TargetVolume int `xml:"targetvolume"` ActualVolume int `xml:"actualvolume"` Muted bool `xml:"mutedenabled"` Raw []byte `json:"-"` }
Volume defines the Volume command