-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
44 lines (36 loc) · 1016 Bytes
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
const { Samsung, APPS, KEYS } = require('samsung-tv-control')
/*
Typescript Example for Dinamic Keys
import { $enum } from 'ts-enum-util'
*/
const config = {
debug: true, // Default: false
ip: '192.168.4.32',
mac: '5c497d22f462',
nameApp: 'NodeJS-Test', // Default: NodeJS
saveToken: true
}
const control = new Samsung(config)
async function main() {
await control.turnOn()
await control.isAvailable()
let token = await control.getTokenPromise()
console.log('$$ token:', token)
/*
Typescript Example
const KeyTypes = $enum(KEYS).getValues()
const getEnumValue = (key: any) => {
return KeyTypes[key]
}
*/
await control.sendKeyPromise(KEYS.KEY_HOME)
await control.sendTextPromise('Text to be inserted in some focused input')
await control.getAppsFromTVPromise()
await control.openApp(APPS.Spotify)
// await control.openApp(APPS.YouTube)
await control.sendKeyPromise(KEYS.KEY_POWER)
await control.getLogs()
control.closeConnection()
return
}
main()