Here are all the steps I did to try to get this working. Would someone mind telling me what I did wrong?
(Also please note that, as I am based in the UK, I use the graph-eu01-euwest1
SmartThings API.)
Setup
I started off by installing the sd card flashed with the Hassbian image.
Then I did:
sudo apt-get update
sudo apt-get upgrade
Then to install MQTT:
sudo ./hassbian-scripts/install_mosquitto.sh
I entered a username ‘pi’ and a password ‘secret’ when prompted.
I then installed node.js
wget https://nodejs.org/dist/v4.3.2/node-v4.3.2-linux-armv6l.tar.gz
tar -xvf node-v4.3.2-linux-armv6l.tar.gz
cd node-v4.3.2-linux-armv6l
sudo cp -R * /usr/local/
Then installed smarthings-mqtt-bridge via NPM
sudo apt-get install npm
sudo npm install -g smartthings-mqtt-bridge
And then installed pm2 via NPM
sudo npm install pm2 -g
I then edited the smartthings-mqtt-bridge config
sudo cp /usr/local/lib/node_modules/smartthings-mqtt-bridge/_config.yml ~/config.yml
sudo nano ~/config.yml
---
mqtt:
# Specify your MQTT Broker's hostname or IP address here
host: 192.168.1.25
# Preface for the topics $PREFACE/$DEVICE_NAME/$PROPERTY
preface: smartthings
# Suffix for the state topics $PREFACE/$DEVICE_NAME/$PROPERTY/$STATE_SUFFIX
# state_suffix: state
# Suffix for the command topics $PREFACE/$DEVICE_NAME/$PROPERTY/$COMMAND_SUFF$
# command_suffix: cmd
# Other optional settings from https://www.npmjs.com/package/mqtt#mqttclients$
username: pi
password: secret
# Port number to listen on
port: 8080
I then setup the Device Handler and SmartApp following: GitHub - stjohnjohnson/smartthings-mqtt-bridge: Bridge between SmartThings and MQTT
Device Settings
IP: 192.168.1.25
MAC: ma:ca:dr:es:s
Port: 8080
And then added this to the HA configuration.yaml
mqtt:
broker: 192.168.1.25
port: 1883
client_id: home-assistant-1
username: pi
password: secret
And then added a switch to the configuration.yaml
switch:
- platform: mqtt
name: "MQTT Left Lamp"
state_topic: "smartthings/Left Lamp/switch"
command_topic: "smartthings/Left Lamp/switch"
payload_on: "on"
payload_off: "off"
retain: true
Then
pm2 restart smartthings-mqtt-bridge
sudo systemctl restart home-assistant.service
I also did a reboot at the end and checked that both services were running
Logs
So here are the SmartThings logs when the switch is turned on (the smarttapp logs):
653e9a65-edb7-4603-b11e-6476d4a52d09 12:41:58 PM: debug Forwarding device event to bridge: {"path":"/push","body":{"name":"Left Lamp","value":"on","type":"switch"}}
653e9a65-edb7-4603-b11e-6476d4a52d09 12:41:57 PM: debug Forwarding device event to bridge: {"path":"/push","body":{"name":"Left Lamp","value":"turningOn","type":"switch"}}
And here are the SmartThings logs when the switch is turned on (the device logs):
a61bb2ab-d453-471b-8d20-f0a187df4895 12:41:58 PM: debug Sending '{"path":"/push","body":{"name":"Left Lamp","value":"on","type":"switch"}}' to device
a61bb2ab-d453-471b-8d20-f0a187df4895 12:41:57 PM: debug Sending '{"path":"/push","body":{"name":"Left Lamp","value":"turningOn","type":"switch"}}' to device
The HA log:
17-03-11 12:35:36 WARNING (Thread-11) [homeassistant.components.recorder] Ended unfinished session (id=6 from 2017-03-11 11:04:59.344912)
17-03-11 12:35:36 WARNING (Thread-11) [homeassistant.components.recorder] Found unfinished sessions
And the pm2 logs:
pm2 logs smartthings-mqtt-bridge
[PM2] Spawning PM2 daemon with pm2_home=/home/pi/.pm2
[PM2] PM2 Successfully daemonized
[TAILING] Tailing last 15 lines for [smartthings-mqtt-bridge] process (change the value with --lines option)
[STREAMING] Now streaming realtime logs for [smartthings-mqtt-bridge] process
So what should I do to fix this?
I see the switch in the HA UI but turning it on or off does nothing (same if I turn it on or off via the SmartThings app)
As I already said at the begging: as I am based in the UK, I use the graph-eu01-euwest1
smartthings api. So if any of the scripts use the datbase I might need to change the api?
Also there is no portforwarding to do if I am correct?