https://github.com/kaperys/go-webos
A small Go webOS library
https://github.com/kaperys/go-webos
go iot webos
Last synced: about 1 year ago
JSON representation
A small Go webOS library
- Host: GitHub
- URL: https://github.com/kaperys/go-webos
- Owner: kaperys
- License: mit
- Created: 2018-07-24T11:42:40.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2020-05-01T05:04:42.000Z (about 6 years ago)
- Last Synced: 2024-06-19T19:49:15.912Z (about 2 years ago)
- Topics: go, iot, webos
- Language: Go
- Homepage: https://godoc.org/github.com/kaperys/go-webos
- Size: 15.6 KB
- Stars: 12
- Watchers: 4
- Forks: 8
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Go WebOS πΊ
A small Go library for interaction with webOS enabled TVs. Tested on LG webOS TV UH668V (webOS version 05.30.20).
[](https://goreportcard.com/report/github.com/kaperys/go-webos)
```go
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, "")
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() method, instead of AuthorisePrompt()
fmt.Println("Client Key:", key)
// see commands.go for available methods
tv.Notification("πΊπ")
```
See [examples](examples/) for usage.
π Inspired by [lgtv.js](https://github.com/msloth/lgtv.js), [go-lgtv](https://github.com/dhickie/go-lgtv) and [webostv](https://github.com/snabb/webostv).