I am trying to create a function that sets all of the different field values (service, domain, entity_id, data) and then push that into the “Data” field of a call service node. The idea is that none of the other fields are set in the call service node, allowing me to use one function node to, for example, turn on a light at a certain brightness or toggle an input_boolean.
You’re using the data field as if it’s like an HA field that supports templates, but it does not. Instead you would have to change the selector from JSON ("{}") to JSONata (“J”) and then enter it in the following format:
{ "data": payload }
However, this likely will still not work because it may complain about extra unwanted fields since you’re putting all of payload in there. You might find it easier to just define “msg.data” in your inbound message, or put all the data-related fields in “msg.payload.data” and then use that in the JSONata.