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 </>
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.
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.
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 exceptentity_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.
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.
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?
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?