- Notifications
You must be signed in to change notification settings - Fork1
Connect your (Legrand Adorne) things for external (e.g. SmartThings) control
License
rtyle/connect-things
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Connect your things.
This supports a general architecture for providing connections to things.The only things realized now areSwitch and Dimmer devices reachable through a localLegrand Adorne LC7001 hub.
TheLegrand Adorne Wi-Fi Ready Switch, Dimmer Switch and Outlet devices will be discovered as device URNs
- schemas-upnp-org:device:BinaryLight:1
- schemas-upnp-org:device:DimmableLight:1
Which correspond to
The only connections realized now are aUPnP connection through a SmartThings hub and aSmartThings Cloud Connector Schema App.
This project may be used to replace SmartThings to Legrand Adorne LC7001 hub integration through Samsung’s ARTIK Cloud.Samsung has abandoned the ARTIK Cloud and Legrand has no plans to provide an alternative.This is an alternative.
connect-things is a JavaScript application that expects to be run in anodejs environment.It was developed using, at the time, theLatest LTS Version: 12.18.3 of nodejs.connect-things can be installed bygitand the Node Package Managernpm.You can use these, as a normal user, to installconnect-things with all of its dependencies:
git clone https://github.com/rtyle/connect-things(cd connect-things; npm install)
To inspect theconnect-things command line options and run it:
node . --helpnode .
This can be disabled with the--disable upnp command line option.
A companion project isupnp-connect which connects these things through a local SmartThings hub to SmartThings device types with Switch and SwitchLevel capabilities.
Since only the SmartThings hub will need access, it is recommended to exclude all others ...
node . --upnp-host smartthings.home
... wheresmartthings.home resolves to the SmartThings hub (use IP address otherwise).
This can be disabled with the--disable c2c command line option.
Assuming that SmartThings will not be able to reach theconnect-things service directly,anngrok (or equivalent) tunnel to it will be required.We assume thatngrok is used here.One side of the tunnel should target the port (default, 8081) of theconnect-things host/serviceand the other side of the tunnel should be identified reliably with your customsubdomain.For example, on the host runningconnect-things,
ngrok http -subdomain=yoursubdomainhere 8081
Replaceyoursubdomainhere (above and below) with your chosen, unique, reliable customsubdomain.Every/any time that this changes you will need to update old/invalid references (For example,Target URL andToken URI, below).That is why it is best if you can ensure that such will never change.Likewise, if you move away thengrok service (orngrok otherwise breaks old/invalid references), such will have to be updated.
TheSmartThings Developer Workspacemust be used to create aproject.Thenew projectshould be created for thisDevice Integrationwith aSmartThings Cloud Connectorof typeSmartThings Schema Connector.After naming your project, the next step will be toRegister Appof theCloud Connector.It will be aWebhook Endpointwith aTarget URLof
https://yoursubdomainhere.ngrok.io/c2c/resource
Set up thecredentials required to access the cloud which hosts the devices.Follow the instructions inetc/c2cClientLocal.jsto generate (and remember) your own unique id and secret for theconnect-things (local) clientand use these to fill in theClient IDandClient Secretfields.
TheAuthorization URIneed only be reachable from the device running the SmartThings app used to onboardconnect-things.It is most secure (and advised) if this device is reachable on the same LAN as theconnect-things host.For example ...
https://connect-things.home:8082/c2c/oauth2/authorize
- whereconnect-things.home resolves to the host runningconnect-things (use IP address otherwise),
- connect-things is running an http service on port 8081 (default)
- and an https service on the next port (8082), dedicated tophone.home, which will only be so if run with the
--c2c-auth phone.home
option wherephone.home resolves to the host running the SmartThings app (use IP address otherwise) used to onboardconnect-things.
TheToken URImust be reachable from SmartThings.
https://yoursubdomainhere.ngrok.io/c2c/oauth2/token
The optionalOAuth Scope(s)should be left empty.
Next, fill in theApp Display Namewith, sayconnect-thingsand choose a logo, sayconnect-c2c-things.png
Copythe your own unique SmartThings (remote)Client IDandClient Secretand paste (remember) them intoetc/c2cClientRemote.js.
You can thenDeploy to Test.
Runconnect-things for first-time onboarding.
cat README.certificates # and follow directionsrm -f etc/c2cCallbackAuthentication.jsonrm -f etc/c2cCallbackUrls.jsonnode . --c2c-oauth phone.home
The certificate created is used for theconnect-things https serviceand its private key is also used to sign JWT tokens.Any etc/c2cCallback*.json files are removed first because they will be overwrittenas part of establishing a new relationship with SmartThings.Old content will probably not work.
From the SmartThings app (run on phone.home),enable Developer Modethen add(+)aDevicebydevice type.Scroll to the bottom and clickMy Testing Devices.UnderMy setup apps,clickconnect-things.Select theLocationandRoomthat devices will be added to and clickNext.
The local SmartThings app will not automatically trust the self-signed certificate created above so you must tell it to.The local SmartThings app should automatically be authenticated and tokens should be exchaged betweenconnect-things and SmartThings.
Connection between SmartThings and connect-things is successfulClose this page to finish setup.
Close the page.
Successfully connected to connect-things.
ClickDone.
As there is no longer a need for authentication (access tokens have been exchanged and can be refreshed),connect-things should be restarted without the--c2c-oauth phone.home option.
node .
SmartThings will be told as new devices are discovered byconnect-things and will immediately support them.
To remove this integration, click on any of its devices to...Edit it, go toLinked Services and...Delete it (-).
From theconnect-things host, change directory to where it is installed.
One should be able to make this run automatically in most environments.It has been tested to run on Linux.
As root,
cp etc/connect-things/connect-things.service /etc/systemd/system/
Read this file for further instructions.
Googlewill offer help runningngrok automatically withsystemd.