add run script

master
Yorick van Pelt 2017-01-08 22:48:33 +01:00
parent bad01f6ef4
commit 96fabd494a
2 changed files with 13 additions and 2 deletions

10
run.js Normal file
View File

@ -0,0 +1,10 @@
const Bravia = require('./bravia')
const tasks = require('./tasks')
const {ip, secret} = JSON.parse(require('fs').readFileSync("/home/yorick/.braviarc.json"))
const tv = new Bravia(ip, secret)
switch(process.argv[2]) {
case "on": tv.sendCommand("WakeUp"); break
case "off": tv.sendCommand("Sleep"); break
case "cmd": tv.sendCommand(process.argv[3]); break
default: if(process.argv[2] in tasks) tv.sequence(tasks[process.argv[2]])
}

View File

@ -1,6 +1,7 @@
const {repeat} = require('./utils')
const utils = require('./utils')
const repeat = (...args) => Array.from(utils.repeat(...args))
const speakermenu = [
'WakeUp', 2000, 'Exit', 300, 'ActionMenu', 1000, repeat(['Up', 250], 9), repeat(['Down', 250], 7), 'DpadCenter', 1000
'WakeUp', 10000, 'Exit', 300, 'ActionMenu', 1000, repeat(['Up', 250], 9), repeat(['Down', 250], 7), 'DpadCenter', 1000
]
const speakermode = [speakermenu, 'Down', 500, 'DpadCenter', 500]