[BETA] All NEW Insteon web socket driver

[Update Friday, August 23, 2019] We have discovered some issues with the insteonserver.js and WS Parent driver code. If you are attempting this for the first time, please note that it will be soon updated with improved instructions for Raspberry Pi users and alternate files which will temporarily remove the ability to use Insteon Keypads. We suggest waiting until this post is updated further.

I'm pleased to share news of the latest Insteon HTTP driver with web socket support by Chris Wilson - @cwwilson08.

This latest driver utilizes an updated version of Scott Kuester's Insteon Server Node.js application, which now supports Web Sockets. This new capability allows the use of Insteon door/window contact sensors, motion sensors and leak sensors, as well as instant device status updates. Insteon 8 button keypads are also now supported, and may be used to trigger HE rules, devices and scenes, in addition to Insteon devices and scenes.

Features

Ramp Rate - The Insteon device hardware Ramp Rates are supported, but user definable Ramp Rates via the driver are not. Therefore, the Duration field in the driver does not serve any purpose and must be left blank. However, by activating and deactivating Insteon Scenes, you can control ramp rate. Insteon scene can be controlled via any Insteon devices, and any device or rule on Hubitat Elevation.

Instant device status

Insteon Scene Control via HTTP Get from Button Controller or Rule Machine

Automated Child device creation and Insteon Device ID capture

Organized Parent/Child device structure

Compatible device types
Dimming Micro Modules
Door/Window contact sensors
IOLinc
In-wall dimmers
In-wall switches
Keypads
Leak sensors
Motion sensors
On/Off Micro Modules
Outlets
Plug-in dimmers
Plug-in switches

Minimum requirements

  • Insteon 2245-222 Hub (The previous 2242-222 and the newer 2243-222 HomeKit hubs are untested)
  • Dedicated computer or Raspberry Pi with Node.js installed to run the insteonserver.js and the client.js event listener applications.
  • Insteon devices

Installation

Insteon Server Node.js application

The insteon-server has been forked to Chris Wilson's repo, as it was necessary to make some changes to some of the files for HE, and the added features Chris has made possible. Please use the forked repo found here rather than the one from Scott Kuester's GitHub repository.

To install the Insteon Server Node.js application, follow these steps:

  1. Install Node.js (google search can help you with this part)
  2. Download the Insteon Server from here
  3. Click on the green Clone or Download button, then click Download ZIP
  4. Type cd /usr/local/lib/node_modules/
  5. Create the directory insteon-server inside the node_modules directory with *sudo mkdir insteon-server
  6. Type cd /usr/local/lib/node_modules/insteon-server/ and expand the ZIP archive "insteon-server-master" to the insteon-server directory.
  7. Type sudo npm -g install
  8. Once that's done, you need to add required dependencies. Type sudo npm install -g home-controller , then sudo npm install -g express, and finally, sudo npm install -g ws
  9. Copy the config-example.json file and rename it config.json.
  10. Edit the config.json file, removing any devices you do not own. The username and password from your insteon hub must replace [Insteon Hub Username] and [Insteon Hub Password] in the config.json file. Atom Text editor is highly recommended for editing on MacOS, and Nano is a very easy to use editor on the Raspbian OS.
  11. Name the devices the way you would like them to appear in your HE hub.
  12. Replace all the [Insteon Device ID] in the config.json file with the actual device ID numbers from your Insteon mobile app. This is important, as it is how the child devices will be created on the Hubitat Elevation hub. If you do not enter the Insteon Device ID numbers in the config.json file for each of your devices, its corresponding child device will not be created on your HE hub.
  13. For Keypads, the device type should be "scene".

Example: (Scroll in the window below to view the entire config.json example)

{
    "description": "Hubitat Insteon Integration",
    "accessories": [],
    "platforms": [
        {
        "platform": "InsteonLocal",
        "name": "Insteon Server",
        "user": "Banana6",
        "pass": "45QtSRC4",
        "host": "192.168.1.55",
        "port": "25105",
        "model": "2245",
        "server_port": "*3500*",
        "devices": [
          {
            "name": "Kitchen Light",
            "deviceID": "45ED1C",
            "dimmable": "no",
            "deviceType": "lightbulb"
          },
          {
            "name": "Dining Room Light",
            "deviceID": "3DED8F",
            "dimmable": "yes",
            "deviceType": "lightbulb"
          },
          {
            "name": "Front Door Sensor",
            "deviceID": "FG34E7",
            "deviceType": "contact sensor"
          },
         {
            "name": "Keypad",
            "deviceID": "[Insteon Device ID]",
            "dimmable": "yes",
            "deviceType": "scene"
         }
      ]
   }
]
 }

NOTE: There is no need to change the deviceType from "Lightbulb", regardless of whether or not it actually is a lightbulb, dimmer or switch. However, you must set "dimmable": "no" in the config.json file if the device type is a switch, a non-dimmable outlet, ON/OFF Micro Module, or an IOLinc.

  1. Save the config.json file and start the Insteon Server node.js application by typing node insteonserver.js. You should see the following in your shell or terminal window:

Connecting to Insteon Model 2245 Hub...
Initiating websocket...
Connected to Insteon Model 2245 Hub...

  1. Open a second shell window (Raspbian) or terminal window (Mac OS), then cd to /usr/local/lib/node_modules/insteon-server/ and type node client.js to start the client event listener. You should see the following in the client.js shell or terminal window:

Connected to Insteon Server

WARNING: If you don't start the client.js application, you won't be able to generate the child devices, get device status updates, or use Insteon motion, contact and leak sensors.

Insteon WS Parent and Child device drivers
Difference between this driver and the previous drivers

• It is no longer necessary to install multiple drivers for your Insteon devices. The Parent driver in HE only occupies one HE device network ID, and the Child devices are automatically generated from the data entered into your config.json file.
• There is no need to enter your device network ID numbers in HE. They will be captured and utilized from the values entered in your config.json file.
• Through the use of web sockets, this new driver will update status immediately, and will capture the status of Insteon input devices such as contact, motion, and leak sensors. Any periodic refresh rules used with the previous driver should be removed.

Adding the Insteon driver code to Hubitat Elevation

  1. Copy the parent driver code from here. Refer to the Hubitat docs for installing devices drivers if you have never done this before.
  2. Copy each of the child device driver code from here. Be sure to click the link for the child driver, then click the RAW button at the top right of the driver code window. This will ensure you have all the correct code, without any missing elements or accidentally included special characters.
  3. Choose Select All on the RAW code window, then Copy and Paste the code into a new driver code window in HE and click SAVE
  4. Repeat until you have added each of the child device drivers from Chris' repo.

Installing the Insteon WS Parent driver

  1. Refer to the Hubitat Elevation device driver documentation if you have never installed a device driver before.
  2. Give your Parent device driver a name, and set the type to Insteon WS Parent
  3. Click the Save Device button
  4. Configure the driver as follows:

  1. Click the Save Preferences button, then scroll down and click Save Device button again.
  2. Click the Initialize button. You should see Connected under the Current States field. If you do not see connected. ensure that both the insteonserver.js application and client.js application have been started on your node.js server.
  3. Your child device ID numbers (Insteon Device ID numbers) should all show up in the State Variables field.
  4. In your HE devices list, you should see the Insteon WS Parent app with the name you gave it, and all of your Insteon devices with the names you assigned to each device in the config.json file.

You may now include your Insteon devices in Hubitat Elevation automations, just as you would any Zigbee or Z-Wave device, but without the need for concern about devices dropping off the network, or a weak mesh. I have personally been running this new driver with all my Insteon devices since the end of June, and it has performed perfectly. Very fast. Zero issues or conflicts of any kind.

Controlling Insteon Scenes

This can be done by sending HTTP request directly to the Insteon hub. With this, you can control the ramp rate of Insteon devices per button, rule action, switch, mode change, etc.

Example:

ON group 11 (scene 1)
http://[username]:[password]@[insteon hub IP]:25105/0?1111=I=0
OFF group 11 (scene 1)
http://[username]:[password]@[insteon hub IP]:25105/0?1311=I=0

Once you have the credentials and Insteon hub IP info, it's just copy past from then on. It's only the last four digits before =I=0 that change depending on the state or the scene group ID number. So in the above example, 1111 is ON for Group ID 11 and 1311 is OFF for Group ID 11

We need testers and feedback from users!

Testers are welcome. The following devices are untested. If you own these devices and can offer feedback, there's no promise of added compatibility, but without testing, there is a 100% guarantee of no compatibility support.

Looking for more feedback on Keypads. At present, you cannot select an Insteon scene from the Insteon Keypad driver. But you can send HTTP Get from Button Controller and Rule Machine. So technically you can control an Insteon Scene via the Insteon Keypad, or anything on HE, therefor is it important to have it in the driver, or not that big of a deal to just use the HTTP Get request when needed?

Currently untested

2242-222 Hub
2243-222 Hub (HomeKit Edition)
6 button dimming keypad
6 button on/off keypad
Ceiling fan/light module
Mini remotes 1, 4 & 8 scene
Siren
Smoke bridge
Thermostat

Thanks go to Chris Wilson - @cwwilson08 for the tremendous amount of work and dedication to putting this new driver together, and a special thanks to Scott Kuester for creating the Insteon-Server app and adding the support for web sockets.

4 Likes

I'm still learning but kinda lost right now Capture

1 Like

Welcome to the Hubitat Community!

Looks like you're inside Node.js. You have to install it, but then you need to be at a unix or linux command prompt to install the rest of the bits. Type process.exit()

You may need to install NPM too, depending on your system. What are you installing on?
For example. I'm on a Mac at the moment, and my Insteon server also runs on a Mac, but a Linux computer or a Raspberry Pi running Raspbian OS (a flavor of Debian Linux) will work too.

If you type npm -v and then press enter, what is the result? Here's what I get.

22%20PM

How's your unix skills? Not trying to be snarky, honest. Google is an excellent teacher. I'm OK at Unix, but get rusty and will google how to do things all the time. There's also manual pages, but they might be confusing if you're just learning unix or linux. To get to them, you just type man and the thing you want to know more about how to use. So for example man pwd, will show you the options available to use with pwd. To exit the manual pages, just type q

To install Insteon Server, you need to be at the directory where you expanded the zip file. Type pwd (Print Working Directory) and enter to see your current directory location. cd .. to go back one directory level, and cd / to go to the root directory.

The path may be different on various systems. If you type cd /usr/local/lib/node_modules/insteon-server/, does that return an error, or does it take you to the path you need to be at? Does that directory exist? You need to create it yourself. If it's not there, but if /usr/local/lib/node_modules/ is there, then type cd /usr/local/lib/node_modules to change to that directory, and then at the prompt, type mkdir insteon-server. Next copy the downloaded zip file to that directory, and then at the prompt, type unzip insteon-server-master.zip

Once the files are expanded there, then type sudo npm -g install

Any luck?

AHHH.. i just ordered a pi so i'll try again in a few days...i use to be ok with unix but honestly haven't used it in many years so i'm very rusty. i was trying on a old pc but i'd rater use a pi anyways..i'm currently able to control insteon switches and dimmers with @cwwilson08 handler but what i'm hoping to accomplish is get my motion, door, and leak senors to work and also 2 way communication (manual switching to show up on my dashboard). i don't know if that's a possibility. i don't know if there is a easier way to do this but i'm open to suggestions

With a Pi3 or later, and the Insteon Server and WS Client software loaded, using this new driver you can do all that.

ok got a pi 3, installed node got up to step 12 running insteonserver.js, it pops up with home insteon 2245 hub initiating websocket and just sits there. but i think my problem is a few steps before that where it talks about permissions to access

thoughts?

Looks like you have the server running. Now need to connect to it from hubitat.

Have added the WS parent code to hubitat?

Edit. You are right. Actually looks like some needed dependencies are not installed.

Insteon server seems to be running fine. WS client has an issue. Try CD to that directory. Then node client.jsfrom the prompt.

i am in the client.js folder on that picture ..I've tried from the root, and folder directory .. i'm pretty convened its something i'm doing wrong with the home controller or the pi ...i'm using
Raspbian Buster with desktop and recommended software is that ok as a OS. i started with the lite version and soon resized i didn't know how to DL without a web browser lol

Never used that. I use the standard Debian with command line on a pi. Will try to look deeper into it tomorrow.

[Edit] Oh, :rofl: It's called Buster now! I get it. Sorry, haven't loaded up Raspbian on a Pi for quite some time. It was Stretch last time I used it. No matter. Should work just the same. I do use the lite version though. I typically download elsewhere and then copy to the SD card directly. Much easier when you can't remember how to do it.

Just a thought, that maybe you don't have the WS dependency. Looking back through early conversations when this was in development, I needed to install the dependency myself.

Try sudo npm install -g ws, then try node client.js

BTW, whatever progress you make that are the result of missing steps (like possibly having to install the WS dependency), please let me know so I can improve the directions.

did you mean sudo npm install -g ws ...i did that and i got this.

.same thing as pic with client.js..i really appreciate your help, i'm learning alot everyday

This is something different that you’re showing in this screen image. In this photo, your issue is formatting in the config.json file.

You can pm me your config.json file content if you want, and I’ll look into the latest issue for you. You can also use this online validatior to check the file yourself.

However I personally prefer to keep unencrypted files with personal information, local. Feel free to obfuscate the username and password in the config.json if you do decide to PM it to me.

you are correct! i had a comma out of place when i edited some names but now i am back to the last problem in the 1st picture where it just sits at initiating websocket. when i type sudo install -g ws i get missing file operand. when i type sudo npm install -g ws it adds 2 packages ( just want to make sure that part is correct or if i need the rpm left off and directory changed)

Great. No that’s a typo on my part. Forgot npm.

The Insteon server won’t show anything. That’s working as it should. It’s the client where you’re going to see updates.

Sounds like you did need the WS node module. So now, start Insteon server, then in another shell, cd to /usr/local/lib/node_modules/insteon-server/ and then type node client.js

Better or still an error?

1 Like

Here's where i'm at

Open the insteonserver.js file in a text editor.

Line 19. Has port 9095 or some such. Change it to 8080. Save. Then restart the insteon server.

on a side note is there a good way to screen shot lol!!

Do you have another program using port 3500?