cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
583
Views
0
Helpful
0
Replies

Macro WebEx Room 55: HDMI-CEC to Put Vizio TV (as secondary screen) In Standby (Power Off)

M44845
Level 1
Level 1

Hello!

 

This is my first time working with Macros with WebEx endpoints. I was able to get the Apple TV control to work fine, but I am trying to use the same concept to power off (standby) the 2nd screen (Vizio TV) when this macro is enabled. 

 

I thought that the correct command is “standby” but I get this in the logs: 

20:35:26AppleTV'CEC command sent:Video CEC Output KeyClick ConnectorId: 2 LogicalAddress:0 NamedKey: Standby'
 
20:35:26AppleTV'Unhandled promise rejection' { code: -32602, message: 'Bad usage: Bad argument to parameter "NamedKey".' }
 
Do I have to do something else to get it to “send” this command to the Vizio TV? Is this the correct command? Thanks!

 

 

Here is the code:

 

const xapi = require('xapi');
const CEC_LOGICAL_ADDRESS_FOR_APPLETV = 4;
const CODEC_CONNECTOR_ID_WHERE_APPLE_TV_IS_CONNECTED = 3;

const CEC_LOGICAL_ADDRESS_FOR_VIZIOTV = 0;
const CODEC_CONNECTOR_ID_WHERE_VIZIOTV_IS_CONNECTED = 2;


const signinsequence = [ 'Right','Right','Right','Right', 'Ok', 'Left', 'Left', 'Left','Ok'];

function sendCEC(key){
var cecstring = 'Video CEC Input KeyClick ConnectorId: ' + CODEC_CONNECTOR_ID_WHERE_APPLE_TV_IS_CONNECTED + ' LogicalAddress:' + CEC_LOGICAL_ADDRESS_FOR_APPLETV + ' NamedKey: ' + key;
xapi.command('Video CEC Input KeyClick', {ConnectorId: CODEC_CONNECTOR_ID_WHERE_APPLE_TV_IS_CONNECTED, LogicalAddress:CEC_LOGICAL_ADDRESS_FOR_APPLETV, NamedKey: key});
console.log(`CEC command sent:` + cecstring);
}

function sendCECVIZIOTV(key){
var cecstring = 'Video CEC Output KeyClick ConnectorId: ' + CODEC_CONNECTOR_ID_WHERE_VIZIOTV_IS_CONNECTED + ' LogicalAddress:' + CEC_LOGICAL_ADDRESS_FOR_VIZIOTV + ' NamedKey: ' + key;
xapi.command('Video CEC Output KeyClick', {ConnectorId: CODEC_CONNECTOR_ID_WHERE_VIZIOTV_IS_CONNECTED, LogicalAddress:CEC_LOGICAL_ADDRESS_FOR_VIZIOTV, NamedKey: key});
console.log(`CEC command sent:` + cecstring);
}


function sleep (time) {
return new Promise((resolve) => setTimeout(resolve, time));
}

// Usage!


function sendCECSequence(params){
let WAIT = 500;
let offset = 0;
console.log(`waiting:` + WAIT);

for (var i=0; i<=params.length; i++) {
sleep(offset+=WAIT).then(() => { sendCEC(params[i]);});
console.log(`waited:` + WAIT);
}
}

xapi.event.on('UserInterface Extensions Page Action', (event) => {
if(event.PageId == 'AppleTV'){
if(event.Type == 'Opened'){
console.log(`AppleTV was opened`);
xapi.command('Presentation Start', {ConnectorId: CODEC_CONNECTOR_ID_WHERE_APPLE_TV_IS_CONNECTED});
sendCEC('Ok');
sendCECVIZIOTV('Standby');
}
else{
console.log(`AppleTV was closed`);
xapi.command('Presentation Stop');
}
}
});


xapi.event.on('UserInterface Extensions Widget Action', (event) => {
if(event.WidgetId == 'appletv_navigator'){
if(event.Type == 'pressed'){
switch(event.Value){
case 'right':
sendCEC('Right');
break;
case 'left':
sendCEC('Left');
break;
case 'up':
sendCEC('Up');
break;
case 'down':
sendCEC('Down');
break;
case 'center':
sendCEC('Ok');
break;
default:
console.log(`Unhandled Navigation`);
}
}
}
else if(event.WidgetId == 'appletv_menu'){
if(event.Type == 'clicked'){
sendCEC('Back');
}
}
else if(event.WidgetId == 'appletv_play'){
if(event.Type == 'clicked'){
sendCEC('Play');
}
}
else if(event.WidgetId == 'appletv_signin'){
if(event.Type == 'clicked'){
sendCECSequence.apply(this, signinsequence);
}
}

});

0 Replies 0