Using scripts in Node Red


I have a script that is switching off my Apple TV. When I run the script from the Home Assistant Script tab, it works as expected.

I have added this script in a Node-RED automation. However, when the script is kicked from this automation (even if I just ad an inject node directly before the automation node), it does an action that do not match the script. It worked at the beginning but stopped working for unknown reasons.

Any idea?


Screen Shot 2022-06-08 at 23.50.09

For service choose turn_on instead of the script name and put the script in the entity.

1 Like

Thanks for the help. I did this, but this did not solve the problem. Indeed, instead of switching off the Apple TV, it just pause the feed.



maybe a different question:

why do you need to run the HA script, instead of controlling the apple tv directly from NR. What the script does contain which cannot be implemented in NR?

This is kinda beyond an error. I’d expect the script to fail or execute. Changing the actual command and providing the right format to the apple tv is unlikely. The script executes normally from HA?

Since you are likely making service calls in the script, just do those service calls from NR instead. Easier to debug then.

Thanks for all your comments. Indeed, I am currently leveraging a script, because the script was already set up before I got interested to NR. I am new to this, so this was not my priority yet to convert the script, but rather the automation.

The script is fairly basic: it checked the state of a device and if the device is on, it runs the command on the Apple TV remote:

- home_hold
- select

Now I have tested just the script node with an inject node, and it seems that the problem does not come from the script node itself. I am using switch nodes to listen to the action on a z-wave remote:

Can this impact on the script itself ?


At face value the obvious mistake would be miss wiring the nodes. Maybe export the flow so we can look at the connections. Otherwise the call service node should show under it when it last fired.


Do you see that under the correct call service node with the script?

Thanks to all for your help. Indeed, there was another wrongly configured node that conflicted with this one…