X-10 Remotes, motion sensors and security devices - need JS help to clean code


I converted from X-10 a couple of years ago to Wink and just now moved to Smartthings. Physical remote controls in the X-10 world are so much cheaper and and I have a bunch of them all over the house. Looking around here couldn’t find anything code for X-10. There are a couple of threads that use Insteon, and some that can use X-10 switches, but nothing for getting signals from X-10 remotes and motion sensors.

I have written some code that uses the mochad deamon to listen RF and powerline X-10 signals and sends them to SmartThings using REST. It is working reliably and its time to share with the community. This code can handle messages from X-10 switches, remotes, motion sensors and security devices.

However I am not much of a JS programmer, and need some help in cleaning up the code on JS side. Its not a lot of code, only a few routines that parse and call ST. I will put it up along with installation instructions once the code is cleaned up.
Would greatly appreciate it if someone can help clean this up a little.

Some background

Mochad is a very stable and widely used deamon process can run on any linux system including Raspberry PI and uses CM15A or CM19A USB devices to communicate with X-10 over RF or powerline.


I have written X-10 binding for Pimatic and Openhab for doing something similar. However the Pimatic code was an adaptation of someone else’s code and was mostly Coffeescript. Also it relied on Pimatic to provide overall control. This code needs to be stanalone. I thought of going the MQTT route, however that seemed like overkill, and yet another sub-system that I would have deal with.