Can someone help me figure out the syntax to call a service from a Node Red Function Node? I know about the call service node, but I don’t want 100 of them lying about, when I can write a little bit of code.
I can get as far as global.get('homeassistant').homeAssistant.services.light.turn_on, but that’s not a function.
I think you will need to call the api directly using an http/request nodejs module if you want to do it in the function node. The services you are seeing are the description of the domain, service and data that appear in the call service node and retrieved by the ws api.
You don’t need a 100, the call service node can be ran with dynamic input(settings) you just need so set the payload correctly of domain, service and data. before it. I do this a lot in node-red
What is it exactly you are trying to solve here ?
I make really complex flows in NR, but never had the need to call services in function nodes (and I use function nodes a lot - really a lot)