Node Red service node doesn't seem to communicate with home assistant

Hello all. I’m new to Home Assistant and am stumbling with my first automation. I have an attic fan that I’m controlling with a Tasmota-flashed Sonoff TH16 switch. I’m using Node Red to create my automation.

I used an events:state node to trigger the fan which seems to work fine. However, I can’t seem to get the service node to communicate with the switch. I’ve tried variations of JSON lines in the Data cell to no avail. I’ve seen youtube videos where that cell was left blank and it didn’t seem to affect them. Domain, Service and Entity id cells are all a mystery to me, was well. Any recommendations would be greatly appreciated.

Sorry, you joined 30 minutes ago and have read 3 minutes.
Could you please read : -

Please do not post images, they are difficult to read, impossible to test and correct.
Can you cut and paste you actual automation (from the yaml file) using the preformatted text option </>

1 Like

I think you were thrown by the use of the word “automation” but this is actually a Node-Red flow so screenshots will be needed.

1 Like

Thanks for the info. I appreciate the coaching. As 123 Taras has indicated, I incorrectly called this an automation. It’s really a Node Red question. So, the screenshot of the node info was all that I could share.

In response to the community standards section of your response, here is additional information about my issue:

  • Home Assistant Core 0.108.4 and OS 3.12 is running on a Raspberry Pi 4
  • There isn’t really an error message but the node in question outputs the following:{“domain”:“fan”,“service”:“turn_on”,“data”:{“entity_id”:“switch.attic_fan”}} (Note that I’ve since changed the service to “turn_on” rather than “switch.turn_on”)
  • I’m not sure if I should have pursued this question on Node Red’s forum instead but I figured the HA people would have more direct experience.

Anyway, I’m on day three of this problem and was just hoping someone in the community might be able to figure out what I’m doing wrong.

Thanks 123. You are correct. This is a Node Red issue and not a HA problem. I’ve corrected the heading.

What happens if domain is set to switch?
Have you use the debug node in node red to troubleshoot?


Try this:

Set Domain to switch
Set Service to turn_on
Set Entity Id to switch.attic_fan
Set Data to {“entity_id”:“switch.attic_fan”}

1 Like

Thanks SigP

I tried these settings. The node yielded the following error message:

Call-service API error. Error Message: extra keys not allowed @ data[‘0’]

Some extra bits of information are that I’m able to use Node Red to send messages to my Lutron Caseta lights so I know Node Red is capable of talking to HA. Also, the tasmota/sonoff is readily operated from HA or directly through tasmota using its IP address. My work around will be to do it in YAML but I want to try to figure this out first.


Domain: homeassistant
Service: turn_on
Entity Id: switch.attic_fan
Data: leave blank
1 Like

You can’t use a domain “fan” and a different domain for the service “switch”. Leave your data field blank unless you properly format the data.

The service and domain should match the entity_id prefix (switch, in this case)

If you want that switch to act like a fan, use the Template Fan to create one inside HA:

You just want this:
Screen Shot 2020-04-21 at 3.41.50 PM

The call service node in Node RED gives special treatment to the entity_id field just like HA does when configuring a “Call Service” action. The ‘Data’ field is for everything except entity_id. If you’re calling a service which accepts entity_id as an input you should put that in the field labeled ‘Entity Id’ and not in data. And if that is the only input (like in the case of switch.turn_on) then just leave the data field blank.

Btw the ‘Domain’, ‘Service’ and ‘Entity Id’ fields all have prompting if you press the down arrow. If you use that while you’re getting started its probably a bit easier. Then you don’t have to guess what that input looks like you can just pick something from the list.

EDIT: Right @NK553, its fan, whoops lol. Updated my screenshot. Although I have noticed that switch.turn_on and homeassistant.turn_on do seem to work with things that aren’t necessarily the same domain. But still good practice just always pick the same domain so you can get correctly prompted in the Service field.

Thanks for the response. You are correct that my domain was incorrect. See my response to SigP below for what happened when I made these changes. Spoiler alert: I’m still getting error messages.

Thanks Mike

It tried you suggestion and the node output this:

{“domain”:“switch”,“service”:“turn_on”,“data”: object}

I feel like this is something that the node should be outputting but maybe HA is not doing anything with it.

Thanks Brian,

I corrected the domain to “switch”. The node now outputs:


Still confused why HA doesn’t do anything with this.

Thanks for the response, Mike. I tried both your recommendation and the same thing with switch as the domain. The node output:

{“domain”:“fan”,“service”:“turn_on”,“data”: object}

I feel like Node Red is outputting things properly but its not getting communicated properly to HA. What’s curious is that I’ve been able to write other Node Red sequences with my Lutron Caseta lights and everything works fine. Likewise, I’m able to operate the tasmota/sonoff switch for the fan using HA so seems like the breakdown is between NR and HA.

Have you tried domain switch?

Yes, I have. Seems like that would be the correct domain. Yields the same response as the fan setting though.

{“domain”:“switch”,“service”:“turn_on”,“data”: object}

Ok couple things here. First of all you see how at the bottom of the panel there’s a checkbox that says ‘Show Debug Information’? Can you check that? Also please put a debug node in your flow right before the service call and route the message to it so we can see what the payload is that this service is being called with. Then please copy the information in the debug view in here so we can see.

It seems like there’s something odd going on so further debugging requires the full picture of what the inputs and outputs are at this point.

Also just for everyone’s sanity can you us a favor and confirm that if you put this in the Services tab of the Developer Tools panel it does work?
Screen Shot 2020-04-21 at 5.10.54 PM

The service call in DEVELOPER TOOLS/SERVICES worked although with:

service: switch.turn_on
entity: switch.attic_fan
entity_id: switch.attic_fan.

Seems like HA is communicating properly with the switch.

I checked the ‘Show Debug Information’ box and added a node at the input of the service call node. The service call node currently has these inputs:

Domain: switch
Service: switch.turn_on
Entity id: switch.attic_fan
Data: (Empty)

Here is what it outputs. (I’m using an inject node to trigger the service call.):

Should be
Domain: switch
Service: turn_on

Although interestingly it looks like node RED figured that out anyway since it just says the service is ‘turn_on’ in the debug entry.

In that first debug entry, can you expand the details so I can see what is in data within that msg.payload? Because this is still the error you’re getting right?