开源软件名称: gilhaz/HomeAssistant_SmarthThings_Homebridge开源软件地址: https://github.com/gilhaz/HomeAssistant_SmarthThings_Homebridge开源编程语言: 开源软件介绍: HomeAssistant_SmarthThings_Homebridge
My setup process to install and configuration of Hassbian to work with SmartThings and HomeBridge
Intgrate to HomeAssistant the following:
Mosquitto
Samba
SmartThings
HomeBridge
Harmony-api
⚠️ note
only tested on Raspberry Pi 3 with Hassbian after clean install and you already have home assistant up and running.
Installation Instructions
Set up your local and update
'apt-get' Update Preperations
sudo apt-get update
sudo apt-get upgrade -y
Install Avahi (HomeKit Support)
Development headers for the Avahi Apple Bonjour compatibility library
sudo apt-get install -y libavahi-compat-libdnssd-dev
Install Samba and Mosquitto with 'hassbian-config'
sudo hassbian-config install samba
sudo hassbian-config install mosquitto
Choose username and password in the mosquitto install process and wright them down! They will be use for configure mqtt.
If you use the install guide as is, the username is 'user' and password 'password'
To connect to Samba file sharing from Mac:
When on the deasktop go to > Go > Connect to Server... or press [cmd] [K]
Insert: smb://hassbian.local/homeassistant
And log in as 'gest'
Mosquitto is install through systemctl, you can use:
sudo systemctl ['start'/'stop'/'enable'/'disable'] mosquitto
configure mosquitto-mqtt in homeAssistant conf
sudo nano /home/homeassistant/.homeassistant/configuration.yaml
past this at the end of the file:
# # mosquitto mqtt server
mqtt:
broker: localhost
port: 1883
client_id: home-assistant-1
username: user
password: password
restart home-assistant
chack you can see the 'mqtt' domain in hass services
http://localhost:8123/dev-service
Install node.js 7.x and npm
Adding the NodeSource APT repository for Debian-based distributions repository AND the PGP key for verifying packages
curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
install Node.js v7.x and npm
sudo apt-get install -y nodejs
install smartthings-mqtt-bridge (link smartthings devices to hass)
Instructions here: Smarter-Smart-Things-with-MQTT-and-Home-Assistant
only the 'SMARTTHINGS DEVICE' and 'SMARTTHINGS APP' parts.
install smartthings to mqtt bridge (pull devices from SmartThing's 'MQTT Bridge' smartapp)
sudo npm install -g smartthings-mqtt-bridge
run it once
sudo smartthings-mqtt-bridge
exit with [ctrl] [c]
configure smartthings-mqtt-bridge
this file is automaticly create after first start of 'smartthings-mqtt-bridge'
config mqtt in smartthings-mqtt-bridge
host: mqtt://localhost
username: user
password: password
chack the bridge is publish events
open 2 terminal windows
first:
sudo smartthings-mqtt-bridge
second:
sudo mosquitto_sub -u user -P password -v -t ' #'
exit both with [ctrl] [c]
install homebridge (HomeKit suppoot)
sudo npm install -g --unsafe-perm homebridge
install homebridge homeassistant support plugin
sudo npm install -g homebridge-homeassistant
run once
exit with [ctrl] [c]
Configure smartthings-mqtt-bridge in homebridge
sudo nano /home/pi/.homebridge/config.json # or .homebridge/config.json
past this:
{
" bridge" :{
" name" :" Homebridge" ,
" username" :" CC:22:3D:E3:CE:30" ,
" port" :51826,
" pin" :" 031-45-154"
},
" platforms" :[
{
" platform" :" HomeAssistant" ,
" name" :" HomeAssistant" ,
" host" :" http://localhost:8123" ,
" password" : " " ,
" supported_types" :[
" binary_sensor" ,
" climate" ,
" cover" ,
" device_tracker" ,
" fan" ,
" group" ,
" input_boolean" ,
" light" ,
" lock" ,
" media_player" ,
" scene" ,
" sensor" ,
" switch"
],
" logging" :true
}
]
}
the ["password": "",] is the password you set for home assistant gui, leave blank if you didn't set one.
run homebridge and chack you get updates from '[HomeAssistant]'
Install Harmony API
install Forefer (harmony-api dependency)
sudo npm install forever -g
download harmony api from github
git clone https://github.com/maddox/harmony-api.git harmony_api
Install Harmony API
sudo harmony_api/script/bootstrap
config mqtt in harmony api
sudo nano harmony_api/config/config.json
past this:
{
" mqtt_host" : " mqtt://localhost" ,
" mqtt_options" : {
" port" : 1883,
" username" : " user" ,
" password" : " password" ,
" rejectUnauthorized" : false
}
}
Chack harmony api is discovering the hub and publish to mqtt (may take a minute to show)
open 2 terminal windows
first:
sudo harmony_api/script/server
second:
sudo mosquitto_sub -u user -P password -v -t ' #'
look for somthing like 'harmony-api/hubs/...'
exit both with [ctrl] [c]
If you can't see the hub and activities try:
From your Harmony app, go to: Menu > Harmony Setup > Add/Edit Devices & Activities > Remote & Hub > Enable XMPP.
Install pm2
install mp2 to manage the autostart on boot for the 'smartthings-mqtt-bridge', 'homebridge' and 'harmony-api' servivces
Update stuff for good practice
Configure pm2 autostart
sudo pm2 start smartthings-mqtt-bridge
sudo pm2 start harmony_api/app.js --name harmony-api
sudo pm2 ls # check everything is green
pm2 start homebridge
sudo pm2 save
pm2 save
sudo pm2 startup
pm2 startup
Check everything is working
sudo reboot
sudo mosquitto_sub -u user -P password -v -t ' #'
start an activity thru Harmony app
search for an update like: 'harmony-api/hubs/harmonylrhub/current_activity tv'
turn on a switch in SmartThings app
search for an update like: 'smartthings/Living Room Light/switch on'
Useful commands
sudo mosquitto_sub -u user -P password -v -t ' #'
sudo nano /home/homeassistant/.homeassistant/configuration.yaml
mosquitto_pub -d -u user -P password -t harmony-api/hubs/harmonylrhub/devices/tadiran-ac/command -m off
sudo pm2 start harmonyapi/app.js --name harmony-api
sudo pm2 ls
sudo dd if=/dev/disk2 of=/Users/[USERNAME]/Desktop/hassbian-backup-$( date +%Y%m%d) .img
请发表评论