Overall, everything seems to work well. I have a couple of comments about your Power implementation and your Input implementation:
Power
These edits are part of the ‘if(mc)’ statement in Line 228. I added Wake-on-LAN functionality for a TV that is ‘deep sleeping’ (code borrowed from the WOL plugin floating around the forum).
if(mc) {
if(mc !== 'Power') {
//Regular commands
console.log(" sending keypress command: " + mc);
http.post("http://" + host + ":8060/keypress/" + mc);
} else {
console.log(" sending power command");
try {
var keyResponse = http.post("http://" + host + ":8060/keypress/Power", "", { timeout: 1000 });
console.log(" no WOL needed...powered on / off normally");
} catch (e) {
console.log(' TV is most likely powered off in deep sleep...trying WOL');
var mac = plugin.Settings["MACAddr"];;
var ip = host;
WOL.wake(mac);
sleep(500);
WOL.wake(mac, { address: ip });
sleep(500);
//WOL.wake(mac, { address: ip, port: parseInt(9) });
WOL.wake(mac, { address: ip, port: 9 });
};
}
}
Input Source
Using keypress for those 6 inputs works ok, as long as someone did not rename the HDMI ports, for instance. What I would recommend is exclusively using apps to call up the correct input. Here is my list of apps:
AV receiver,Wall Jack,HDMI 3,Live TV,Prime Video,The Roku Channel,Pandora,PBS KIDS,ESPN,4K Spotlight,MLB,NBA,NASA TV,Roku Media Player,ABC,YouTube
AV receiver is my renamed HDMI 1, Wall Jack is my renamed HDMI 2, and Live TV is what the TV automatically calls Tuner. All of those can be called up using the ‘/launch/’ syntax, so I have found no need to use keypress for this.
Current TV channel
Your plugin does seem to be pulling the correct app in for InputSource. I take it one step further if the current app is Live TV to determine the current channel and use /query/tv-active-channel: Link to the Roku ECP docs.
Hope that helps.