/autohubpp

C++ Home Automation Hub - Insteon PLM Support

Primary LanguageC++

autohubpp

C++ Home Automation Hub - Insteon PLM Support

Intention of Project

To create a fully customizable home automation hub.
This server software is written in C++. It was designed to provide TCP/IP support to Insteon PLM.
PLM's supported: Serial / USB and HUB
If using a HUB it must support RAW Insteon Commands via TCP/IP. My hub is version 4.8A
NO Insteon accounts are required.

This is the backend server software only. I currently run it on a Beaglebone Black.
The front end used with this project is Home Assistant. https://github.com/home-assistant/home-assistant
Any frontend GUI supporting websockets will work with this server.

A very simple python library was written for homeassistant to communicate with this server software.
Autohub components were also written for use with with Home Assistant.

  • Python library for autohub: https://github.com/gitaaronc/pyautohub
  • If there are any python developers willing to take part, please contact me.
  • HomeAssistant integration can be found in my homeassistant repo, branch autohub.

Websockets are used to interface and control autohubpp.
RAW Insteon commands are supported on port 9761. Therefor other programs like houselinc will work.

TODO:

  • Documentation

You must have all the the required dependencies to compile autohubpp.
First ensure you have at least version 1.55 of the boost libraries installed.
apt-get install libboost-all-dev

You'll also need yaml-cpp
apt-get install libyaml-cpp-dev

It's recommended to create a dev directory and clone the following repositories into it.

-dev
--websocketpp
--autohubpp

WEBSOCKETPP
git clone https://github.com/gitaaronc/websocketpp.git

AUTOHUBPP
Clone this repository.

Compiling
I compile and run everything in linux on a Beaglebone.
All of this should compile and run under windows but it hasn't been tested.
I do use Netbeans as an IDE on windows, but all compiling is done remotely on linux.

The compiler must be able to find the header files included with the above dependencies.

I create a softlink inside of /usr/include
ln -s /{GIT_REPO_ROOT}/websocketpp websocketpp

Once you have the dependencies in place and the symbolic links created you can run make.
The libraries created by the above dependencies will require placement into your /usr/lib folder.
Rather than moving or copying the required libraries, I create symbolic links using the above method.

If there are any masters of CMake out there, an automated process is needed.
If you are interested in helping with the development of this project please contact me.

Running/Configuration
A yaml configuration file must be specified on the command line. ex: autohubpp /etc/configuration.yaml
example yaml configuration file

worker_threads: 20
INSTEON:
  command_delay: 1500
  DEVICES: # You don't need to populate the device section, it will autopopulate on discovery. You can modify/customize it.
    0x0026deeb:
      properties_:
        button_on_ramp_rate: 31
        button_on_level: 255
        device_category: 1
        device_disabled: 0
        device_engine_version: 2
        device_firmware_version: 65
        device_subcategory: 14
        enable_blink_on_traffic: 0
        enable_led: 0
        enable_load_sense: 0
        enable_programming_lock: 0
        enable_resume_dim: 0
        light_status: 0
        link_database_delta: 2
        signal_to_noise_threshold: 32
        x10_house_code: 32
        x10_unit_code: 0
      device_name_: Desk Lamp
    0x0029e6cd:
      properties_:
        device_engine_version: 2
        device_category: 1
        device_subcategory: 32
        device_firmware_version: 65
        device_disabled: 0
        enable_blink_on_traffic: 0
        enable_led: 0
        enable_load_sense: 0
        enable_programming_lock: 0
        enable_resume_dim: 0
        light_status: 0
        link_database_delta: 24
      device_name_: Ceiling Light
    0x002035f6:
      device_name_: 0x002035f6
      device_disabled: 1
    0x0027ce35:
      device_name_: 0x0027ce35
      device_disabled: 1
  PLM:
    enable_monitor_mode: false
    serial_port: /dev/ttyUSB0
    type: hub #can be hub or serial, only the older hub is support at this time.
    sync_device_status: true
    hub_ip: 192.168.4.147
    baud_rate: 19200
    load_aldb: false
    hub_port: 9761
WEBSOCKET:
  listening_port: 9000
logging_mode: VERBOSE

Websocket requests are expected by the server in a json format. Responses are delivered in a json format.
A sample request:

{
   "event" : "getDeviceList"
}

The sampled response:

{
   "devices" : [
      {
         "device_address_" : 2110966,
         "device_name_" : "0x002035f6",
         "properties_" : {
            "light_status" : 0
            "device_disabled" : 1
         }
      },
      {
         "device_address_" : 2547435,
         "device_name_" : "Desk Lamp",
         "properties_" : {
            "button_on_level" : 255,
            "button_on_ramp_rate" : 31,
            "device_category" : 1,
            "device_disabled" : 0,
            "device_engine_version" : 2,
            "device_firmware_version" : 65,
            "device_subcategory" : 14,
            "enable_blink_on_traffic" : 0,
            "enable_led" : 0,
            "enable_load_sense" : 0,
            "enable_programming_lock" : 0,
            "enable_resume_dim" : 0,
            "light_status" : 0,
            "link_database_delta" : 2,
            "signal_to_noise_threshold" : 32,
            "x10_house_code" : 32,
            "x10_unit_code" : 0
         }
      },
      {
         "device_address_" : 2548930,
         "device_name_" : "Bedside Lamp",
         "properties_" : {
            "device_category" : 1,
            "device_disabled" : 0,
            "device_engine_version" : 2,
            "device_firmware_version" : 65,
            "device_subcategory" : 14,
            "enable_blink_on_traffic" : 0,
            "enable_led" : 0,
            "enable_load_sense" : 0,
            "enable_programming_lock" : 0,
            "enable_resume_dim" : 0,
            "light_status" : 255,
            "link_database_delta" : 3
         }
      }
   ],
   "event" : "deviceList"
}

Sample request:

{
   "command" : "on",
   "command_two" : 255,
   "device_id" : 2547435,
   "event" : "device"
}

Sampled Response:

 {
   "device_address_" : 2547435,
   "device_name_" : "Desk Lamp",
   "event" : "deviceUpdate",
   "properties_" : {
      "button_on_level" : 255,
      "button_on_ramp_rate" : 31,
      "device_category" : 1,
      "device_disabled" : 0,
      "device_engine_version" : 2,
      "device_firmware_version" : 65,
      "device_subcategory" : 14,
      "enable_blink_on_traffic" : 0,
      "enable_led" : 0,
      "enable_load_sense" : 0,
      "enable_programming_lock" : 0,
      "enable_resume_dim" : 0,
      "light_status" : 255,
      "link_database_delta" : 2,
      "signal_to_noise_threshold" : 32,
      "x10_house_code" : 32,
      "x10_unit_code" : 0
   }
}

Autorun in Linux
Autohubpp will need to be started after the usb/serial adapter is recognized by the operating system.
Step 1
Create a file called 95-autohubdaemon.rules in /etc/udev/rules.d folder

KERNEL=="ttyUSB0", TAG+="systemd", ENV{SYSTEMD_WANTS}="autohubdaemon.service"

Step 2
Create a file named autohubdaemon.service in /lib/systemd/system

[Unit]
Description=INSTEON serial to socket bridge
After=remote-fs.target
After=syslog.target

[Service]
ExecStart=/usr/sbin/autohubpp /etc/autohubpp.yaml
RemainAfterExit=yes
Type=forking

Step 3
The compiled autohubpp executable should be placed in /usr/sbin or create a link to its physical location

Further reading if interested: https://opensource.com/article/18/11/udev

Documenation is still required.

More C++ and Python developers required!!

Thanks.