Categorygithub.com/kottle/go-webos
modulepackage
0.0.0-20211211210936-82106a909e96
Repository: https://github.com/kottle/go-webos.git
Documentation: pkg.go.dev

# README

Go WebOS πŸ“Ί

A small Go library for interaction with webOS enabled TVs. Tested on LG webOS TV UH668V (webOS version 05.30.20).

Go Report Card

dialer := websocket.Dialer{
    HandshakeTimeout: 10 * time.Second,
    // the TV uses a self-signed certificate
    TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
    NetDial: (&net.Dialer{Timeout: time.Second * 5}).Dial,
}

tv, err := webos.NewTV(&dialer, "<tv-ipv4-address>")
if err != nil {
    log.Fatalf("could not dial TV: %v", err)
}
defer tv.Close()

// the MessageHandler must be started to read responses from the TV
go tv.MessageHandler()

// AuthorisePrompt shows the authorisation prompt on the TV screen
key, err := tv.AuthorisePrompt()
if err != nil {
    log.Fatalf("could not authorise using prompt: %v", err)
}

// the key returned can be used for future request to the TV using the 
// AuthoriseClientKey(<key>) method, instead of AuthorisePrompt()
fmt.Println("Client Key:", key)

// see commands.go for available methods
tv.Notification("πŸ“ΊπŸ‘Œ")

See examples for usage.

🌟 Inspired by lgtv.js, go-lgtv and webostv.

# Packages

No description provided by the author

# Functions

NewInput dials the socket and returns a pointer to a new Input.
NewTV dials the socket and returns a pointer to a new TV.

# Constants

APIServiceListCommand lists the API services available on the TV.
ApplicationManagerForegroundAppCommand returns information about the forgeground app.
AudioGetVolumeCommand returns information about the TV's configured audio output volume.
AudioSetVolumeCommand sets the TV's configured audio output volume.
AudioVolumeDownCommand decrements the TV's configured audio output volume.
AudioVolumeSetMuteCommand sets/toggles muting the TV's configured audio output.
AudioVolumeStatusCommand returns information about the TV's configured audio output volume.
AudioVolumeUpCommand increments the TV's configured audio output volume.
ErrorMessageType is returned by the TV when an error has occurred.
https://github.com/supersaiyanmode/PyWebOSTV.
https://github.com/supersaiyanmode/PyWebOSTV.
MediaControlFastForwardCommand fast forwards the current media.
MediaControlPauseCommand pauses the current media.
MediaControlPlayCommand plays or resumes the current media.
MediaControlRewindCommand rewinds the current media.
MediaControlStopCommand stops the current media.
RegisteredMessageType is returned by the TV in response to a registration request.
RegisterMessageType is sent to the TV in a registration request.
RequestMessageType is sent to the TV when issuing Commands.
ResponseMessageType is returned by the TV in response to a request.
SystemLauncherCloseCommand closes a given application.
SystemLauncherGetAppStateCommand returns information about the given application state.
SystemLauncherLaunchCommand launches the given application.
SystemLauncherOpenCommand opens a previously launched application.
SystemNotificationsCreateToastCommand creates a "toast" notification.
SystemTurnOffCommand turns the TV off.
TVChannelDownCommand changes the channel down.
TVChannelListCommand returns information about the available channels.
TVChannelUpCommand changes the channel up.
TVCurrentChannelCommand returns information about the current channel.
TVCurrentChannelProgramCommand returns information about the current program playing on the current channel.

# Variables

Port is the port used to connect to the TV.
Protocol is the protocol used to connect to the TV.

# Structs

App represents an applications in the TVs responses.
No description provided by the author
Message represents the JSON message format used in request and responses to and from the TV.
Service represents services in the TVs responses.
ServiceList represents an array of Service types in the TVs responses.
TV represents the TV.
Volume represents the audio output volume in the TVs responses.
No description provided by the author

# Type aliases

Command is the type used by tv.Command to interact with the TV.
MessageType is the type sent to and returned by the TV in the `type` field.
Payload represents the Payload contained in the Message body.