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

I have this situation. Running cast-web-api device handler on the same linux box as my node-red/mochad setup. What is the solution to this? If I change the cast-web-api’s network id in smartthings device, it stops working. Is it possible to run the Node Red Bridge on the same server as other Smartthings bridges?

No idea - sorry try the Node Red forum - could be a Node-Red version thing, don’t know what version they are on now

It’s smartthings limitation - only solution I know of is get another device I have 3-4 Raspberry pi zero w’s I use, they are only $5.00 plus a microsd and a micro-usb charger

1 Like

Interesting I wrote an update yesterday but it never submitted it lol

I wanted to update as I have done some more troubleshooting - its working “sort of” (in a hacky band-aid sort of way)

I discovered that I was able to send 1 command when mochad would first start, but any more commands after that would fail with the “TypeError” message above. If I unplugged the CM15A from the pi and plugged it back in (basically restarting the mochad service and killing any connections to it) I could send 1 more command (and again any after that would fail).

I first changed the tcp request node return property to “immediately - don’t wait for a reply” which then made all the commands sent from smart things to mochad work, however if you used a x10 remote to turn off the module smart things would become out of sync due to the connection being closed.

So in a hacky attempt to fix I added another tcp request node and connected it to the Rate Limiter (but not receiving input from the “/push” node). This node is connected to same localhost 1099 but the return property is set to “never - keep connection open”. This seems to have resolved the sync issue as it is able to relay the x10 commands back to smartthings.

Being a noob to node-red and mochad I’m sure that I have overlooked something in the original flow, or have done something wrong to cause this, or my noob hacky fix will undoubtedly cause me some other headache down the road (LOL) so any advice/guidance is appreciated!

Don’t know why you are having the original problem - what are you running this on? There is echo suppression issue inherent in this solution that is related to timing its worked for most people but in your case its acting up.

Can you upload your flow here or as a git gist - Actually doing a second listener on 1099 is brilliant as long as you don’t listen when you are sending out the command yourself, and having a secondary listener it may make it easier to control as you have done.

This is running on a Raspberry Pi 3 Model B running Raspbian Stretch (9.4)

I am running version 0.1.17 of MOCHAD (due to the fact that there were changes in the recent versions of Raspbian that changed how background services are managed. .17 fixed the issue I had that MOCHAD wasn’t starting when ever the CM15A was plugged in. I did try reverting back to .16 to see if that was the issue but it made no difference)

Node-RED is version 0.19.1

So far the 2 listeners seem to be working well - below is the flow I am currently running:

I think I am getting close…

Step 3 of the instructions states to install all 5 SmartApps. In the Git repository there are only 4 SmartApps. If I copy the SmartApp codes from above for the 5 SmartApps, I receive an error message when I try to create the last one - No signature of method error. Therefore, I installed the 4 SmartApps from GitHub and then I install the SmartApp on my phone, setting IP/port. I then try to add an X-10 device. When I select “Save” to add the X-10 device, the SmartThings app (both versions: the Classic and the new one) run for a moment and then come back with “An unexpected error occured”.

Any idea what may be causing this error? Is it related to me installing only 4 out of the 5 SmartApps? If so, where do I find a working version of the “missing” SmartApp?

Could you please let me know what are the next steps to integrate with my Google Home?

Thank you!

That is because the last one is not a SmartApp its Device Type Handler. Instructions say that

You need to create a Device Hanlder - the code is in github the link here points to it

Hello Enis - Thank you for the help! I created the DTH and I can now add an X10 device without error.

I added this new X10 device to ST - the ST web app shows this device connected to the ST hub. In the iOS ST app, I tap “Automation” -> Google -> Switches -> Select this X10 device. Now I can ask Google (Hey Google) to turn this X10 device X10 light switch) on or off and Google confirms turning on/off, but the light does not turn on/off. Other non-X10 lights work fine.

I edit the X10 device in the ST web app and I see the Type * is set to “X-10 Node Red Device”. I also can SSH into the Pi and use the nc commend to turn this X10 device on/off - so this is working. Any ideas or help is greatly appreciated.

Thank you!

More info - I look at Live Logging in ST and I see the following error message under F-8 Dan Light where Dan Light is the X10 device at F8:

java.lang.NullPointerException: Cannot invoke method toInteger() on null object @line 179 (setDeviceStatus)

Looks like the error occurs here in “X-10 Node Red Switch Child”:
def setDeviceStatus(deviceString, status) {
log.debug “Child setDeviceStatus deviceString:[${deviceString}] state.deviceString:[${state.deviceString}]”
def theDevice = getDevicebyNetworkId(getX10DeviceID())
if ((theDevice) && (deviceString= state.deviceString)) { // The switch already exists
int level = theDevice.currentValue(“level”).toInteger() <<<< this is line 179 - ERROR
switch (status) {
case “on”:
theDevice.on()
//log.trace (“Turning on”)

can you turn the device on/off from the ST app? try if that works, if not delete everything in Smartthings app/web gui and start over. Looks like the device wasn’t created properly, hard to say why that would be but that what it seems like. May be side-effect of what you were doing before.

I could not control the X10 device from anything besides the X10 remote control or the Pi running Mochad. I deleted my ST hub and did a factory reset on the ST hub. I deleted everything for my ST account and started over, but no difference. I can ask Google to turn on/off this device and it thinks it is doing so (verbally says it is doing so), but the X10 device does not turn on/off - the X10 works from the Pi or the X10 remote.

Reviewing the logs and I can see commands for X-10 Node Red Bridge, Google, C-1 Test and Test - all “looks” ok, but something must not be so. When I re-created the ST set-up, I named my X10 device Test and it is at C1 (House code/unit code).

P.S. I only receive this error when I use the X10 remote control OR the Pi to turn on/off the X10 device:
java.lang.NullPointerException: Cannot invoke method toInteger() on null object @line 179 (setDeviceStatus)

As always, I appreciate any help you can provide. I think it is very close to working 0 hopefully.

Thank you!

I reinstalled Node-Red (to try something else). I enabled debug messages in Node-Red. When I turn on/off the X10 device from ST or Google (which uses ST), I receive the following error in the Node-Red debug:
“TypeError: Invalid data, chunk must be a string or buffer, not object”

I am not certain where this is occuring. Any ideas?

This solution from StonegateGuy above - post 135 (replacing the Node-Red flow) worked!

@dgruen45 Which version of Node Red are you running ?

@StonegateGuy you?

Sounds like Node Red has changed that object type in an update. I will play with it next weekend…
Thanks for sticking with it and finding the solution, maybe it will help someone else out.

I am using Node Red v0.19.2

To clarify: when using the solution form StoneGateGuy above - his flow - I still receive the error below in the ST logs when the X10 device “locally” (see below for definition). The X10 devices turn on and off with ST or Google, but they get out of sync if I control them “locally” by using the X10 remote, the switch on the X10 device (for light switches) or an X10 controller (e.g., CM11A) to control the X10 devices. I need to turn them on and off a couple of times with ST/Google and then they are back in sync until the X10 device is controlled again “locally”.

java.lang.NullPointerException: Cannot invoke method toInteger() on null object @line 179 (setDeviceStatus)

I am using Node Red v0.19.2 on a Pi 3 B (not a 3 B+) running Raspbian Stretch. StoneGateGuy stated he is using Node Red v0.19.1.

Any ideas? Is there an updated flow for Node Red (updated from the flow StoneGateGuy posted)?

Sorry work has been a bit busy lately, and I haven’t had a chance to reply.

Node-RED is version 0.19.1

Also of note I am using a CM15A …. I noticed dgruen45 is using the CM11A. Could this be part of the issue/differences? I do not seem to have the sync issues he is experiencing after altering the flow with the 2nd listener. I can use the x10 keypads to turn on and off lights and I see the state of the light update in smartthings.

To clarify - I am using a CM19A (RF) connected to the Pi to control the X10 devices via Google or ST. The CM11 is running macros and timers to control X10 devices independently of the CM19A/Pi/Node Red. I am still having the sync issue.