Skip to content

Commit

Permalink
release v0.2.1
Browse files Browse the repository at this point in the history
- docs added into README.md
- client_test.ts fixed
- lockfile updated
- publish workflow added
  • Loading branch information
bukhalo committed Jul 3, 2024
1 parent 511e485 commit d46a463
Show file tree
Hide file tree
Showing 8 changed files with 116 additions and 21 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/publish.yml
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.idea
.vscode
.env
76 changes: 68 additions & 8 deletions README.md
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
4 changes: 2 additions & 2 deletions client_test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { assertObjectMatch } from "./deps_test.ts";
import { assertObjectMatch } from "jsr:@std/assert";
import { Client } from "./client.ts";
import { MessageType } from "./message_type.ts";
import { MessageType } from "./types/message_type.ts";

Deno.test("client", async (test) => {
const url = Deno.args[0];
Expand Down
9 changes: 7 additions & 2 deletions deno.jsonc
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"]
}
}
26 changes: 19 additions & 7 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion deps_test.ts

This file was deleted.

2 changes: 1 addition & 1 deletion types/request_config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MessageType } from "./message_type.ts";
import type { MessageType } from "./message_type.ts";

export type RequestConfig<P = Record<string, any>> = {
id?: string;
Expand Down

0 comments on commit d46a463

Please sign in to comment.