Hey folks.
Need some help.
I have a "smart" TV (cough) but it is ONLY used for displaying.
It has 4 HDMI inputs.
I have an NVidia shield plugged into HDMI1.
I have an Amp with multiple HDMI inputs plugged into HDMI2.
HDMI2 is the usual input.
That has Foxtel plugged into it.
I use the Foxtel remote to control things. HDMI CEC.
I can detect if the TV is OFF/ON.
The shield is usually turned off.
NORMAL use the Foxtel is wateched mostly.
Now and then I turn on the shield to watch local stuff.
Problem
I can't really cheat to know when it is turned off as it still allows PING replies, so.....
I'm stuck with this point.
What happens.
I power on the shield and it starts returning PING values.
That indicates it is ON.
It also turns on the TV and it (The TV) adjusts its input to HDMI1.
I don't always turn off the Shield (power down) when not using it.
So, I turn on the Foxtel, and this is where things get complicated.
It sets itself to HDMI2 input, but doesn't get it exact.
I control the TV (Foxtel) also via HDMI CEC for channel changes, etc.
So the input selection needs to be correct. Not Generic.
To get around this I have a mode mode for the TV (flow context) to indicate the desired input.
Going to Shield input works fine. Going back to Foxtel mode doesn't.
To recap:
Normal mode (Foxtel) is active.
I turn on (power it on) the shield and the TV adjusts its input.
NR blocks any usual Foxtel/TV commands as they are channel changes.
It indicates it is set to SHIELD mode.
So I want to go back to Foxtel.
I pick up the Foxtel remote and Power it on.
The TV adjusts its input to the GENERIC HDMI input, but it isn't the exact one.
I don't think I can fix this EXACT problem as described.
But I'm wanting to get some code that - if the MODE is set to FOXTEL - tweaks what happens when the TV is powered on for the first time to set the correct input.
WHAT?
As in:
It is in SHIELD mode, but turned off.
I power on the TV but it is set to FOXTEL mode.
It sends some extra commands to tweak the input to the correct one.
Without posting the entire code - not fair to you - I just want some help with one bit of JS code in a function node.
//////////////////////////////////////////////////////////
// 2026 09 15 //
// ========== //
// //
// Addition/modification to code. //
// ------------------------------ //
// //
// Outputs: //
// 1 - Message to voice //
// 2 - Output to input changer code //
// //
// //
// Variables: //
// `shield` - status of the shield. //
// `tvstate` - status of the tv. //
// `tvmode` - mode set for tv input. //
// `flag` - used to stop resending of same message that day. //
// //
// Still to do: //
// Need code to detect tv input was on `shield` but //
// shield is off and tv is ON/`true` and send the //
// A.I.C. command to change input on TV. //
//
// get values needed.
const shield = flow.get("SHIELD")
const tvstate = flow.get("TVState")
const tvmode = flow.get("TV_MODE")
let flag = context.get("flag") || 0
// store then in context only to help tracking.
context.set("shield",shield)
context.set("tvstate",tvstate)
context.set("tvmode",tvmode)
const msgA = "Warning. Shield detected. Mode set for Foxtel"
const msgB = "Please check TV is set to FOXTEL input and not just set to Onkyo"
const msgCC = "Change TV input"
const alert = "bellding.mp3"
//let mute = 0
//node.warn("Shield state " + shield)
//node.warn("TV state " + tv)
//node.warn("TV mode " + mode)
// TV off
if (tvstate == false)
{
//
node.status({})
context.set("flag",0)
node.status({ fill: "red", shape: "dot", text: "OFF" });
return
}
// mode mismatch - first time
if (shield == "ON" && tvstate == true && tvmode == "FOXTEL" && flag == 0)
{
//node.warn("HERE")
// This is maybe where the signal needs to go (output 2) to signal the TV input tweak?
node.status({fill:"red"})
// msg.payload = "Warning. Shield detected. Mode set for Foxtel"
msg.payload = msgA
msg.mute = 1
msg.alert = alert
node.status({ fill: "red", shape: "dot", text: "Mismatch" })
context.set("flag",1)
return msg
}
// Shield - all good - first time
if (shield == "ON" && tvstate == true && tvmode == "SHIELD" && flag == 0)
{
//
node.status({fill:"green", text: "Shield"})
context.set("flag",0)
return
}
// Shield - all good - WHY NEEDED?
if (shield == "ON" && tvstate == true && tvmode == "SHIELD" && flag == 1)
{
//
node.status({ fill: "green", text: "Shield" })
context.set("flag", 0)
return
}
// Foxtel - all good - first time
if (shield == "OFF" && tvstate == true && tvmode == "FOXTEL" && flag == 0)
{
// This needs work to send message to adjust TV input
// msgCC needed in this part of the code sent out of second output
// and msgB is sent on first output
node.status({fill:"yellow", text: "Foxtel"})
return
}
Sorry for some of the commented lines. I'm still testing the waters. ![]()
I'm confused.
This NEARLY is what I want.
But it doesn't have the input for when I change the mode from SHIELD to FOXTEL.
(Isn't hard, but I'm just saying. This is where I'm at.)
Thoughts?