Skip to content

RajkumarGara/homebridge-tcp-smarthome

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

About

The homebridge-tcp-smarthome plugin integrates Apple HomeKit with devices controlled via TCP commands, enabling smart home capabilities directly from your iOS device. Running on a Raspberry Pi with Homebridge, this plugin is designed to send light on/off commands suitable for LMDI-100 devices, as well as window covering commands compatible with Mechonet Network Interfaces. Operating the accessory in HomeKit triggers the command from Homebridge to tcpserver running on the Pi, which in turn sends the commands to the Pico-W TCP client. Commands are transmitted through TCP to this client, which then relays these instructions to the connected devices via RS232. This setup allows for the control of various loads, including lighting and window coverings. Multiple pico-w units can be deployed across an entire floor, ensuring comprehensive coverage and control, as long as they are connected to the same WiFi network as the Raspberry Pi. If this plugin is published to npm, then no need to follow the steps for Unpublished Plugin; instead, refer published Plugin.

Features

  1. It supports light and window covering accessories.
  2. Number of accessories can be configured. (Refer to Configure the Plugin section in Unpublished Plugin).
  3. Homebridge sends LMDI-100, Mechonet commands to the pico-w through TCP.
  4. Individual lights on/off.
  5. Individual light brightness control from 0 to 100%.
  6. Individual window covering 5-level (0%, 25%, 50%, 75%, 100%).

Installing Homebridge

  • Follow the below steps for Debian OS. Refer homebridge-installation for any other OS.

  • Add Homebridge Repository

    curl -sSfL https://repo.homebridge.io/KEY.gpg | sudo gpg --dearmor | sudo tee /usr/share/keyrings/homebridge.gpg  > /dev/null
    echo "deb [signed-by=/usr/share/keyrings/homebridge.gpg] https://repo.homebridge.io stable main" | sudo tee /etc/apt/sources.list.d/homebridge.list > /dev/null
    sudo apt-get update
    sudo apt-get install homebridge
  • Install Homebridge

    sudo apt-get update
    sudo apt-get install homebridge
  • Homebridge installation completed: Login to the Homebridge UI by going to http://<ip address of your server>:8581. To find the IP address of your server you can run:

    hostname -I

    Setup the Homebridge by entering the username and password on homebridge UI.

    Homebridge

Adding unpublished plugin to the Homebridge

  • Navigate to homebridge terminal by entering below command on your device (Raspberry Pi) terminal.

    sudo hb-shell
  • Develop the plugin: As a Homebridge user, you can create a new plugin project in a folder (the folder name doesn't have to match the plugin name). Mainly you'll need to implement two files: index.js and package.json.

    1. index.js: This is where you write the main logic of your plugin. It should export a function that Homebridge will call to register your accessory or platform.
    2. package.json: This file describes your plugin, including its name, version, and dependencies.

    For more information check homebridge-API, homebridge-plugin-template .

  • Write the homebridge config.json file according to the plugin.

    nano /var/lib/homebridge/config.json
  • Navigate to your plugin folder. Install Development Dependencies. Link to homebridge. Link your plugin to the homebridge (replace homebridge-tcp-smarthome with your plugin name). Restart the homebridge.

    cd ~/github/homebridge-tcp-smarthome
    npm install
    npm link
    npm link homebridge-tcp-smarthome
    systemctl restart homebridge

    You will be asked to enter the homebridge password.

  • Plugin successfully added. To check your plugin in Homebridge, go to the Homebridge UI and navigate to the "Plugins" section. There, you can view and manage your installed plugins.

  • Configure the Plugin: Add/remove accessories:

    1. Open the Homebridge UI and navigate to Settings > Config JSON Editor. Config JSON Editor
    2. Add your desired accessories to the configuration.
    3. Restart Homebridge for the changes to take effect.

    For example configuration, refer to config.schema.json, which includes settings for 3 lights and 1 window covering accessory.

Removing unpublished plugin from the Homebridge

  • Run below commands in homebridge terminal to remove the plugin from homebridge. Replace homebridge-tcp-smarthome with your plugin name.

    npm unlink homebridge-tcp-smarthome
    rm -rf /opt/homebridge/lib/node_modules/homebridge-tcp-smarthome
    systemctl restart homebridge

    You will be asked to enter the homebridge password.

Connecting homebirdge to homekit

Running the setup

  • Setup the Pico-W following the steps on github. Make sure the device (either LMDI-100 or Mechonet) are connected to the Pico-W.

  • Run tcpserver.js on Raspberry Pi.

    node tcpserver.js
  • Control lights or window coverings through Apple HomeKit or Homebridge Accessories. Operating a HomeKit accessory connects Homebridge to the TCP server, sends the relevant command, and then disconnects.

    HomeKit

    Homebridge Accessories

Developer Notes

  • To see which plugins are linked to Homebridge, run the following command in the homebridge terminal.
    ls /opt/homebridge/lib/node_modules

Project Gallery

  • This block diagram describes the complete project. Block diagram

  • The below screenshot shows the homebridge log when various accessories are operated in HomeKit. Homebridge log

  • This screenshot displays the TCP server running on Raspberry-Pi. TCP Server

  • This screenshot shows the commands received by Pico-W. Pico-W

Credits

Special thanks to Medical Informatics Engineering for their support throughout the development of this project, especially to Doug Horner for his invaluable guidance.

About

Control LMDI and MechoNet devices remotely with Homebridge

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published