-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- docs added into README.md - client_test.ts fixed - lockfile updated - publish workflow added
- Loading branch information
Showing
8 changed files
with
116 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: Publish | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
id-token: write # The OIDC ID token is used for authentication with JSR. | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- run: npx jsr publish |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.idea | ||
.vscode | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,72 @@ | ||
# WebOS Client | ||
|
||
Simple Deno module for control LG WebOS TV's | ||
[![JSR Scope](https://jsr.io/badges/@bukhalo)](https://jsr.io/@bukhalo) | ||
[![JSR Score](https://jsr.io/badges/@bukhalo/webos-client/score)](https://jsr.io/@bukhalo/webos-client) | ||
[![JSR](https://jsr.io/badges/@bukhalo/webos-client)](https://jsr.io/@bukhalo/webos-client) | ||
|
||
Reference: | ||
Add package in your project: | ||
|
||
https://github.com/bendavid/aiopylgtv/ | ||
https://github.com/merdok/homebridge-webos-tv | ||
https://github.com/hobbyquaker/lgtv2 | ||
https://github.com/home-assistant/home-assistant.io/issues/17685 | ||
https://community.home-assistant.io/t/lg-webos-change-picture-setting-mode-with-scripts/262915/3 | ||
https://www.webosbrew.org/pages/commands-cheatsheet.html | ||
```bash | ||
deno add @bukhalo/webos-client | ||
``` | ||
|
||
Or add package without install step: | ||
|
||
```typescript | ||
import { Client } from "jsr:@bukhalo/webos-client"; | ||
``` | ||
|
||
Initialize the `Client` class by passing the IP address of the TV as the first | ||
argument, and run `register()` function: | ||
|
||
```typescript | ||
import { Client } from "@bukhalo/webos-client"; | ||
|
||
const client = new Client("192.168.0.1"); | ||
await client.register(); | ||
``` | ||
|
||
<!-- deno-fmt-ignore --> | ||
> [!IMPORTANT] | ||
> Once `register()` is executed, it will send a connection request to the TV, don't forget to confirm it. This is the reason why the function returns a promise. | ||
> | ||
> After confirming the request on the TV, you need to save the token. If the code is executed in a Deno environment, the token will be automatically saved to `localStorage`. If the code is not executed in Deno or you want to change the default behavior, create your own class for storage by inheriting the `Storage` abstract class from the package. You can specify your own storage when initializing the client by passing it as the second argument. | ||
After that you can call one of the available methods, for example `volumeUp()`: | ||
|
||
```typescript | ||
import { Client } from "@bukhalo/webos-client"; | ||
|
||
const client = new Client("192.168.0.1"); | ||
await client.register(); | ||
|
||
await client.volumeUp(); | ||
``` | ||
|
||
Or send a custom request if you know `type`, `uri` and `payload` for that | ||
request: | ||
|
||
```typescript | ||
import { Client, MessageType } from "@bukhalo/webos-client"; | ||
|
||
const client = new Client("192.168.0.1"); | ||
await client.register(); | ||
|
||
await client.sendMessage({ | ||
type: MessageType.REQUEST, | ||
uri: "ssap://audio/volumeUp", | ||
}); | ||
``` | ||
|
||
<!-- deno-fmt-ignore --> | ||
> [!NOTE] | ||
> Please note there are a very limited number of ready-made requests available in the client at the moment. | ||
### Reference | ||
|
||
- https://github.com/bendavid/aiopylgtv/ | ||
- https://github.com/merdok/homebridge-webos-tv | ||
- https://github.com/hobbyquaker/lgtv2 | ||
- https://github.com/home-assistant/home-assistant.io/issues/17685 | ||
- https://community.home-assistant.io/t/lg-webos-change-picture-setting-mode-with-scripts/262915/3 | ||
- https://www.webosbrew.org/pages/commands-cheatsheet.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,14 @@ | ||
{ | ||
"name": "@bukhalo/webos-client", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"exports": "./mod.ts", | ||
"tasks": { | ||
"lint": "deno fmt", | ||
// example command for run tests, use you own TV IP address | ||
"test": "deno test --allow-net=192.168.0.10:3000 -- ws://192.168.0.10:3000" | ||
"test": "deno test --allow-net=192.168.0.61:3000 -- ws://192.168.0.61:3000", | ||
"publish": "deno task lint && deno publish" | ||
}, | ||
"publish": { | ||
"exclude": [".github"] | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters