SmartThings Community

[UPDATED] Node Red Bridge for X-10 Devices (Switches, Modules, Remotes, Sensors and Security Modules)


(Johnny D) #41

I need a little step by step of what to do. I went back to your github link above and imported into the clipboard and got a second tab and both are enabled. Not sure how to disable one and use/delete the other. I was trying to view debug with the first flow. Grabbed what I thought is relevant below.
A step by step guide of what to do would be helpful. Sorry, just so new to this tool.

eventData: “{“protocol”:”",“direction”:"",“housecode”:“b”,“unitcode”:2,“state”:“on”}“
url: “"
3/1/2018, 11:33:44 PMnode: http request to STmsg : string[100]
“Warning: msg properties can no longer override set node properties. See"
3/1/2018, 11:33:45 PMnode: ef7bddaa.b975d8msg.payload : string[74]
3/1/2018, 11:33:46 PMnode: ef7bddaa.b975d8msg.payload : string[107]
"03/01 23:33:38 rcvi addr unit 2 : hu B2 (no_alias)↵03/01 23:33:38 rcvi func On : hc B↵"
3/1/2018, 11:35:38 PMnode: http request to STmsg : string[23]
“no response from server"
3/1/2018, 11:35:38 PMnode: http request to ST
msg : error
"Error: socket hang up”

(Enis Hoca) #42

You can double click on the tab and it will let you enable / disable a flow. To delete a flow have that in focus and you can delete from the Flow menu in the hamburger on right.

However this has what I need it indicates that node red is not able to make the http call.
I think at this stage best thing to do may be for you to find some node red sample that posts something to a web site. And get that debugged and working. There are plenty of getting started type things.
Once you have that working and if you have interest perhaps we can try to do some interactive screen sharing session over the weekend

(Johnny D) #43

Been spending time on this: looking at the debugs and reading a lot, but not sure I am on the right track and what i am looking for. What is wrong with your http post?

(Enis Hoca) #44

More like blind leading the blind - I went up and down scratching my head - not at home can’t test but I think I have found the problem. But this is tinkerland stuff so you get into knowing the perils.

Pretty moronic of me, but hey it is what it is.

Anyway here is what I think the problem is - look at he topmost flow which starts with startup go to the ‘http request to ST’ node double click it - you will notice that it has the url for my hub in it. You should put your ST IP address there - or delete it and make the field blank. That’s where that warning is coming from. So first hard code your IP and check if things start working. They should. Then delete the address and see if they continue to work. If they don’t then put it back again. I will test and make update the flow with the fixes once we know for sure that the problem has been resolved.

(Enis Hoca) #45

Just tested it - just delete the URL field from the “http request to ST” it should pick it up from the config file and just work.

(Johnny D) #46

I noticed it had your URL 2 days ago and I modified it to mine . That didn’t fix the issue. I had been spending a lot of time looking at the debuging and always saw my url showing up in the debug logs not yours. I think the override from the config file was always working. I just tried deleting it and ran some tests again. I see in the debug log my URL. I have been testing further, but it never works.
One problem that I have been having, when I make the change to the URL, I have chosen Deploy all. When I reboot and relaunch node-red, I don’t see that change there any longer in the node. Not sure if that is the culprit, because, like I said the debugs always show me my URL in all 3 tests: 1) if yours is in there, 2) if mine is in there or 3) if it’s blank.

I was trying to figure out what the exact syntax of the post command should be and see if I can submit it outside of node-red via a browser or command line.
I was cutting and pasting some variations of this into the browser and just get a timeout. Can you help me build that command and how to test it? Does this test make sense?
I added the slash “/” after 39500:{“protocol”:"",“direction”:"",“housecode”:“b”,“unitcode”:2,“state”:“off”}

(Enis Hoca) #47

Its a post not a get - you cant append it to the url
I you will have to use postman or some post tool to do the post - chrome has postman, but the way the code on ST is setup, it will only accept the post from the linux machine so you will need do that from that machine. what you have in the curly brackets is correct, the server is code is expecting

  1. DeviceUpdate ( just that word) in the header
  2. the stuff you have in curly brackets in the body

The node getting saved or not I think is a different problem. you may want to try a simple flow that posts something to another site just to make sure that http node is even working properly

(Johnny D) #48

I have been searching how to do a POST command from the command line. I came up with this command:

curl -i -X POST -H ‘Content-Type: application/json’ -d ‘{“protocol”:"",“direction”:"",“housecode”:“b”,“unitcode”:2,“state”:“on”}’

This is the response I get:
Connection: close

It did not trigger the X-10 device at B2 which is my X-10 lamp module. If I go to this device from my devices list I can turn it on and off. I do have node-red running.
I also tried B3 code which I have currently configured as an x10 remote/motion sensor which should trigger a zigbee bulb. It’s not working either.


Not sure where/how I was supposed to have included this in my command. Any suggestions?

(Johnny D) #49

Now you are not going to believe this, but it started working all of a sudden briefly. B3 code was turning on smartthings lamp module and b2 x-10 lamp module showing correct status. I was psyched. Only thing I did was delete your url and re-deploy which I have done before.

I tried a few mins later and now and it is no longer working. Nothing responding in When I try again This:

curl -i -X POST -H ‘Content-Type: application/json’ -d ‘{“protocol”:"",“direction”:"",“housecode”:“b”,“unitcode”:2,“state”:“on”}’
curl: (52) Empty reply from server
curl: (52) Empty reply from server
curl: (52) Empty reply from server

I tried telnet command again got this response:

telnet 39500
Connected to
Escape character is ‘^]’.
Connection closed by foreign host.
Not sure what is going on.

(Enis Hoca) #50

seems like a flaky linux/nod red build - if you can telnet to ST on that port, then even if the commands are not processed you won’t see an error on node-red.
In fact when I was initially developing it I had done the node-red side of the code then started working on the ST code, during this time http would always succeed. The way it works on the ST side is this. The samsung/ST code accepts the POST from a client and then rebroadcasts it to listener apps, more than one app can listen. It really doesn’t even matter what the content of the http call is.
not sure if you have a physical or virtual machine, but at this point I would have been very tempted to buy a $5.00 pi zero W from microcenter and stick heyu on it and be done with it.

Xiaomi devices on sale (buttons/sensors/cubes)
(Johnny D) #51

What I am not clear about is why I am getting a good response from the smartthings hub with the post command was issued, but then a little later I was getting different results. This corresponded with the setup stopped working. But telnet was giving good response.

curl -i -X POST -H ‘Content-Type: application/json’ -d ‘{“protocol”:"",“direction”:"",“housecode”:“b”,“unitcode”:2,“state”:“on”}’

This is the response I get:
Connection: close


curl -i -X POST -H ‘Content-Type: application/json’ -d ‘{“protocol”:"",“direction”:"",“housecode”:“b”,“unitcode”:2,“state”:“on”}’
curl: (52) Empty reply from server
curl: (52) Empty reply from server
curl: (52) Empty reply from server

I do have a Pi3, but was trying to cut my teeth on the linux side first. I will configure raspbian and try to install heyu and node red and go from there.

(Johnny D) #52

Not sure what to do with this?

(Enis Hoca) #53

this works for me -
curl -i -H 'X10NodeRed:DeviceUpdate' -H 'Content-Type: application/json' -H 'Connection: close' -X POST --data '{"protocol":"","direction":"","housecode":"m","unitcode":1,"state":"on"}'

had a thought if this curl works for you from command like replace the http send node with an exec node and run the curl command line, you will need to assemble it in the code node - look at how the monitor is done.

(Johnny D) #54

What would a good response to this command look like?
Should it also turn on my device if I have node-red running?

(Enis Hoca) #55

resposnse should be a 202 and whatever you have mapped to should turn on or off - you should also see activity in the smartthings IDE logs

(phil) #56

SO I ordered everything that was posted above for this project and looking forward to dusting off all my x10 devices. If there is an update on this since you have been using it for a while let me know please.

(Enis Hoca) #57

I fixed a couple of bugs we found recently - but not much more. As long as you are using mochad, you should be good.

(Enis Hoca) #58

@JohnnyD69 any luck?

(Johnny D) #59

Not seeming to work with the below command modeled after yours.

curl -i -H ‘X10NodeRed:DeviceUpdate’ -H ‘Content-Type: application/json’ -H ‘Connection: close’ -X POST --data ‘{“protocol”:"",“direction”:"",“housecode”:“m”,“unitcode”:1,“state”:“on”}’
Connection: close

curl: (52) Empty reply from server
curl: (52) Empty reply from server
curl: (52) Empty reply from server
curl: (52) Empty reply from server
After a few minute pause…

curl: (7) Failed to connect to xn–unitcode-1o3dnbt port 1: Connection timed out
curl: (52) Empty reply from server

Nothing displaying in the live logging. Modules not turning on and off. Do you see anything obvious wrong with my command?

(Johnny D) #60

No luck with the Curl command (see my previous post, maybe you can help me with that?), however node-red and your flow seem to be working correctly now. Things started working right after I removed your IP from the flow and I was able to get a successful re-deploy. I think something was weird and my changes to the flow were not being saved. I also had issued a heyu reset and heyu clear command to my CM11A. Don’t know if that helped. X-10 Modules can be turned on and off from the smartthings device or from an x-10 remote and the status updates correctly now. I also mapped an unused x-10 code to turn on a zigbee light and it works and displays status correctly. At this point I would say it is fully working with CM11A. Also, the latest update to stable release node.js became available a day or so ago and I updated it to ver 8.10.0. All is still working. I am getting about a .5 second response time with the x-10 lamp module and about a 1.5 second response time with the x-10 remote turning on a zigbee module. It’s really good! I am going to start setting up my additional X-10 devices in smartthings and test the heck out of it some more. I have a chime which I want to utilize, but may have to switch some X-10 codes around.

To finalize and publish this solution, there were a couple minor corrections we discussed in the flow and in the instructions (needing a restart so it can find smartthings).

Some other things I wanted to look into was why HEYU was not understanding the MR26A RF receiver commands, as i think the documentation listed it as supported. I see this command in the heyu help: heyu aux Start the (optional) Heyu auxiliary RF input daemon. I have not tried that yet. Don’t know how we could integrate that into the solution if it works from the command line. I didn’t find my Firecracker and test that out either. I did read that the MR26A did not support the Security system sensors, so I may not bother with it at all as I find the powerline through the CM11A more reliable. I was hoping to somehow integrate the security sensors, but not sure if it’s possible unless I had some sort of receiver that could read those signals (I am wondering if the broadlink RM- Pro can do that ).

In any event, thank you so much for your development! You have come up with a great solution for both the CM11a/heyu and CM15a/mochad users. A fantastic contribution for x-10 users.