Skip to content

Latest commit

 

History

History
72 lines (52 loc) · 2.4 KB

README.md

File metadata and controls

72 lines (52 loc) · 2.4 KB

WebOS Client

JSR Scope JSR Score JSR

Add package in your project:

deno add @bukhalo/webos-client

Or add package without install step:

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:

import { Client } from "@bukhalo/webos-client";

const client = new Client("192.168.0.1");
await client.register();

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():

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:

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",
});

Note

Please note there are a very limited number of ready-made requests available in the client at the moment.

Reference