SmartThings Community

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


(Dan G) #141

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!

(Dan G) #142

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?

(Dan G) #143

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

(Enis Hoca) #144

@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.

(Dan G) #145

I am using Node Red v0.19.2

(Dan G) #146

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)?

(Blake M.) #147

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

Node-RED is version 0.19.1

(Blake M.) #148

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.

(Dan G) #149

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.

(Blake M.) #150

OK that makes a bit more sense. One question I can think of with the sync issue is if you are using an RF only receiver, are all of your x10 commands that are being sent over powerline (commands from the CM11 or other non RF keypads) being converted at some point to RF? Check to see if you see any activity on the Pi when you are sending powerline based commands. This could be a cause of sync issues as the Pi (and therefore SmartThings) never got the message that the light was turned on because the powerline commands are not being sent by RF.

(Dan G) #151

It makes sense that X10 commands sent via the power-line (using the CM11) would never reach the Pi and therefore SmartThings IF there is only a RF X10 receiver connected to the Pi as is the case when the CM19A is connected to the Pi. A CM15A, which has both RF and power-line interfaces, should stay in sync when power-line and RF X10 commands are sent. I do not have a CM15A in order to test.

What I do not understand is when using the HR12A Palm Pad Remote control to send X10 commands via RF, the SmartThings app does not reflect the correct X10 status as it does when using Google to turn on/off an X10 device. The X10 devices respond to the HR12A button presses, but the status in SmartThings does not change and becomes out of sync.

I am using the CM19A (RF only) and tested that the CM19A sends AND receives RF X10 commands. I use the Pi command line, nc localhost 1099, and press a button on the HR12A to show that the Pi/Mochad (0.1.17) is receiving X10 commands. I use echo “rf a1 on” | nc -w1 localhost 1099, where a1 is the housecode and unitcode, to transmit X10 commands from the Pi using the CM19A (RF) and this works fine. To further test, when the Pi, via CM19A (RF), sends an X10 command by using the echo command above, the X10 device responds, but the SmartThings status is not updated.

Just a thought – can the SmartThings status be ignored somehow? If the X10 command to turn on/off a device was always sent, regardless of the SmartThings status, then the X10 device would receive the code. If the X10 device was already in the state (on or off) and the command was sent, it would just stay in that state. If the X10 device was not presently in the state, it would switch when the command was received…

Any ideas are appreciated. Thank you!

(Dan G) #152

More information

*** Set-up 1: Pi3, Mochad 0.1.17, Node-Red 0.19.3 with Raspbian Jessie (updated/upgraded)

A) I run "nc localhost 1099" from the Pi command line to show X10 commands the Pi sends or receives via the CM19A RF X10 interface. This is working. I see all the X10 transmit (TX) commands when SmartThings (ST) is used to turn on/off an X10 device. I see X10 receive (RX) commands when I press a button on my HR12A (RF remote).

B) Looking at the Live Logs in the ST - I see activity when using ST to turn on/off an X10 device. I do NOT see any activity in the logs when I use the RF remote to turn on/off an X10 device. There are NO errors reported in the ST log.

It appears that, with this set-up, the X10 commands sent from the RF remote are not getting to the ST.

*** Set-up 2: Pi3, Mochad 0.1.17, Node-Red 0.19.2 with Raspbian Stretch (updated/upgraded)

Same as “A” above – works fine.

B) Looking at the Live Logs in the ST - I see activity when using ST to turn on/off an X10 device. I DO see activity in the logs when I use the RF remote to turn on/off an X10 device. There ARE errors reported in the ST log for BOTH cases when ST sends an X10 command AND when an X10 command is sent by the RF remote - java.lang.NullPointerException: Cannot invoke method toInteger() on null object @line 179 (setDeviceStatus).

*** Set-up 3: Pi3, Mochad 0.1.17, Node-Red 0.19.3 with Raspbian Stretch (updated/upgraded) – SAME RESULTS AS WHEN USING Node-Red 0-19.2

Summary based on this limited testing:

i) The system responds the same regardless of the Node-Red version (0.19.2 or 0.19.3) – out of sync.

ii) The system reports the error above (java.lang…) when an X10 RF command (from RF remote) OR from ST using Raspbian Stretch, but NOT with Raspbian Jessie. Raspbian Jessie does not report any errors, but does not work either.

I am not familiar with Java at this point to resolve. It appears there is an issue with using the theDevice.currentValue("level").toInteger() in line 179 of X-10 Node Red Switch Child. I would guess that this element of the data structure is not initialized and is Null and this is causing the error when trying to convert to an interger.

I hope this helps. Please let me know how I can help. Thank you!

Just a Button? 1 button, nothing more fancy?
(Dan G) #153

I got it working with the RF remote! In “X-10 Node Red Switch Child”, I commented out (used “//”) lines 179, 189-194. This commented-out code deals with the dimming function as it tries to use the current level and dim or brighten.

(Dan G) #154

I created an installation guide in Word that has all the steps (at least for me) to set-up a Pi from scratch (blank SD card) to use Node-Red as a bridge between X10 and SmartThings. Being in Word it is nicely indented. The downside is when you copy the text, you get the outlining level text (e.g., 3 or v or ii) when you paste it into the Pi for example.

How can I post a file on this forum?

(Enis Hoca) #155

Sorry been caught up at work haven’t had much time - Please go ahead and post I will link it to the main post - may be better you could create a gist in github, its pretty close to drag&drop and the file becomes much easier to access for everyone here how to do it

You are lucky that its stays in sync but its also mostly chance - if you recycle the system it will get out of sync. The basic reason for not being in sync is no one holds true facts in X10 - the only system of record is the device itself and it can’t be queried (well most of them anyway). So about the only that can happen is that node-red code can listen to the stream of x-10 messages and move them to ST to maintain state. If you read my original notes - maintaining dimming levels in ST is almost hopeless all you can do is dim up or down. In X-10 keypads we have dim up and down buttons in ST we have level and slider, one is fire & forget command, the other needs state.

So back to sync - I have a pretty stable system running since Dec/Jan when i did this - one thing I learnt pretty quickly was life is a lot simpler if you let ST be the master system and use X-10 devices and remotes as inputs and outputs to that system. That means - let ST be the man in the middle, instead of controlling things directly. Send palmpad/controller signals to ST virtual devices mapped to X-10 for example put a lamp on A-1 and create the device using app. Then set palmpad to house code B and map B-1 to the ST device. Now when you press B1 it will control the ST device which in turn will control A-1. A little roundabout but I don’t see an discernible delay compared to using X-10 directly. Similarly using rules in CM11 is interesting but you may want to consolidate and modernize.


You could import it to a shared Google Docs file and post the link…


Thank you for the effort you have put into this Enis! Getting everything up and running was a bit of a challenge, but the end result is a very elegant solution to breathing new life into otherwise very dated hardware. Good job sir!

(Dan Belliveau) #158

First, thanks for all the hard work on this… I have hit a road block right out of the gate and can’t get the initial blink on “a1” to work. Didn’t want to go further until that is resolved. I have tested the module and it works fine. Any tips would be appreciated… First time using raspberry pi, but seems straight forward. Is there a way to see if the pi unit is seeing the CM15A…?

(Dan G) #159

I have posted my set-up guide here: Set-up Guide

This is working well to set-up a Raspberry Pi with SmartThings and Google Assistant.

The system can get out of sync if an X10 device is controlled outside of SmartThings (e.g., pressing the button on an X10 light switch). Sending X10 commands from other devices such as a CM11 can cause the system to get out of sync - even with a CM15A connected. Not sure why this is the case as the CM15A receives all X10 commands…

(Dan Belliveau) #160

Thanks for the note… I isolated the test environment so that there isn’t any x10 devices on the circuit. Still no luck. when i check to see if pi sees the CM15A using lsusb, it sees it just fine. Could the port address, 1099, be incorrect…? Thanks in advance…