Skip to content

📺 Package for control your WebOS-based LG TVs

License

Notifications You must be signed in to change notification settings

bukhalo/webos-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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