How to simplify a long sequence for remote button press simulation

I'm new to the Node RED world. This is a working sequence but it is just too long and hard to read and maintain. Since this sequence is just simulating button press, can I use one function node for this entire sequence?

UPDATE

Thanks @Steve-Mcl's suggestion using link in and link out nodes would make the sequence much easier to read.

Prossibly, but i suspect you are taking actions on each of these buttons so you might have to live with it (although it dowsnt have to be in one straight line - you could use link in/link out nodes and re-arrange it)

However, my question is - what on earth happens at the end of that flow?
It looks like your are operating dashboard buttons to get some kinda input somewhere?
Cant you just inspect the final value, capture that & send it directly?

Thanks for your advise. I think using LINK node would be helpful for nodes arrangement.

To answer your question, I am using an LG OLED TV so this sequence just turn off the screen. the TV is running on its webOS system but there is no interface to turn off the screen directly :frowning:

Are you sending IR commands? or talking over http? or other?

Take a look at the LGTV node.

Are you sending IR commands? or talking over http? or other?

I can use home assistant to control the TV but the functionality is limited https://github.com/bendavid/aiopylgtv/blob/master/aiopylgtv/endpoints.py. I believe the LGTV node would do something similar. It can communicate HTTP but i believe this setting is not exposed to the outside world. The remote control is using bluetooth (not so sure about it)? but it does not have a way to turn-off the screen with single button press.

The "screen off" option is hidden deeply inside the menu, Setting -> General Setting -> Picture -> Energy Saving -> Screen Off

One thing might worth to mention is that the audio control on the remote can actually turn off the screen by saying "turn of screen", however, i do not know how to capture this request.

How can I do this? the exposed API does not seem be able to do it, aiopylgtv/aiopylgtv/endpoints.py at master · bendavid/aiopylgtv · GitHub.

The node @bakman2 refers to states it can do this...

give it a go

sorry, let me be clear. I'm trying to turn the screen off not the TV off.

So like blank the screen? (but leave TV on - for say listening to music?)

yes, i want to turn the screen off so i can use the TV as another speaker with AirPlay.

It looks slightly manageable with link in and link out nodes :slight_smile:

It looks slightly manageable

lol

why do you need all these "button" nodes, can you not just use one and inject the button sequence ?

you mean make them a sub sequence? sorry, I'm new to Node RED and do not know how to use one node as you described. I definitely want to use one node vs. a ton of them

You are using home assistant nodes and have configured each node to perform some action, correct ?
The information in the field names in the call-service node can be set via another node (inject, change, function, etc).

read/watch the documentation of node-red.

Your flow can be reduced to 3 nodes.

This is what I was alluding to with these comments...

but from a guess, the OP has to "drive the TV menu" to enter this "screen off" mode.

Perhaps undocumented, but the TV could well have an API call or IR command to do this in one hit.

My other suggestion would be - get a google mini or amazon alexa or the apple equivalent (I have 4 google minis all in a sync'd group piping pink floyd around my house as i speak/write)

Thanks everyone for the pointers. I will read them and see what improvement I can make.

I think the point @Steve-Mcl was making is that you make one button on the dashboard send a sequence of commands to the TV one after another. One button on the dashboard is not limited to causing a single action.

I thought the blue nodes were button presses sent to a TV, nothing to do with the dashboard?

If I understood this correctly, one way to achieve the 3 nodes suggested by @bakman2 would be to inject an array of messages through a split and then delay node to a single instance of the blue nodes responsible of sending then commands to Home Assistant.

1 Like