From 96fabd494a2b9b92497c34dcec2c1bec8dea76a6 Mon Sep 17 00:00:00 2001 From: Yorick van Pelt Date: Sun, 8 Jan 2017 22:48:33 +0100 Subject: [PATCH] add run script --- run.js | 10 ++++++++++ tasks.js | 5 +++-- 2 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 run.js diff --git a/run.js b/run.js new file mode 100644 index 0000000..0970c8e --- /dev/null +++ b/run.js @@ -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]]) +} diff --git a/tasks.js b/tasks.js index 70da91f..9d28d7e 100644 --- a/tasks.js +++ b/tasks.js @@ -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]