SmartThings integration for MyQ Garage Doors and Switches Based on ady642/HomeCloudHub
- Go to your SmartThings IDE
- Go to My SmartApps link
- Click on Settings button
- Click Add new repository
- Enter owner
aromka
, nameMyQController
, branchmaster
. - Click Save
- Click on the Update from Repo button
- Select the
MyQController (master)
repository - Check the application, check Publish, and click Execute Update
- Go to My Device Handlers
- Click on Update from Repo button and select
MyQController (master)
- Select devices that you want to install (Garage Door, Switch)
- check Publish, and click Execute Update
Prerequisites: You must have node and npm installed on your system.
- Run
git clone https://github.com/aromka/myqcontroller.git
from directory where you want the server installed - Run
npm install
- Find out the IP and Port of your SmartThings hub
- either from your router,
- or go to My Hubs in SmartThings IDE and look for
localIP
- Run the server
node server [your-localIP]
frommyqcontroller
directory, for example:node server 192.168.0.10
- Open SmartThings app
- Go to Marketplace -> SmartApps tab
- Scroll down and go to MyApps
- Select MyQ Controller
- Enter the IP of your local server
(This should be pc/mac that's running node server. You can find this out by going to Network Preferences, usually it's something like
192.168.0.5
. If you have firewall enabled, make sure to open port42457
) - Enter your MyQ username and password (Your credentials are stored in your SmartThings account, and never used or shared outside of this SmartApp)
- Press Next
- If you entered everything correctly, you should see success confirmation message
- Press Done
- Your devices should appear in My Home -> Things
- You should also see all the devices that were found, as well as any commands sent in your console running the server
Installing on a fresh copy of Raspbian NOOB on Raspberry Pi 3
You can either do this through Raspberry Pi's console, or ssh to it from your mac / pc.
If you want to ssh and run the commands from your mac, the default "Raspbian" OS will automatically broadcast its presence on your network under the mDNS name raspberrypi
. If you are using Mac or Linux, you can reach your Pi easily:
The default username for Raspbian is pi
and the password is raspberry
.
Once you login, update the system and install npm:
sudo apt-get update
sudo apt-get upgrade
sudo apt-get npm
Optionally create a folder where you want to store MyQController app
mkdir ~/Apps
cd ~/Apps
git clone https://github.com/aromka/myqcontroller.git
cd myqcontroller && npm install
Update config.json file
cd ~/Apps/myqcontroller/server/config
cp config.json.example config.json
nano config.json
And set your SmartThings Hub's IP and port. Now run the server. Find out your Raspberry Pi's IP address on your local network (you will need to set it in the app)
hostname -I
Run the server
node server
And update the IP in MyQ Controller SmartApp in the SmartThings app.
You can add a command to your /etc/rc.local
sudo nano /etc/rc.local
and add the following content right before exit 0
exec 2> /tmp/rc.local.log # send stderr from rc.local to a log file
exec 1>&2 # send stdout to the same log file
set -x # tell sh to display commands before execution
node /home/pi/Apps/myqcontroller/server [your-localIP] &
This will run the MyQController server after raspberry pi boots up, and will log the output to /tmp/rc.local.log
file.
Restart the system
sudo reboot
You can tail the logs to make sure everything works as expected.
tail -f /tmp/rc.local.log
sudo kill $(ps aux | grep [m]yq | awk '{print $2}') && sudo /etc/rc.local
- When you PC / Mac restarts when running a node server, you might get a different IP address, so app settings need to be update to assign the new IP, so you should both Raspberry PI (or your server) and SmartThing to static IP
####Setting static IP on raspberry pi
-
sudo nano /etc/dhcpcd.conf
-
interface eth0 static ip_address=192.168.1.XX/24 static routers=192.168.1.1 static domain_name_servers=192.168.1.1
-
sudo reboot
- If you run a server first time, and shortly kill it, and run it again - duplicate devices might be created, as it seems like ST doesn't return newly created devices within first few minutes. You can simply go and delete those duplicate devices to solve this.