Mqtt smartthings bridge on hassbian


(Johan Karlquist) #1

Hi am very new to this and rely need some help.
i have a smartthings hub v2 that i connected to my hassbian installation.
But it doesn’t work, if i use: sudo mosquitto_sub -u mosquitto_user -P mosquitto_password -v -t
I can see the device i added in the app change to on/off when i turn it on/off from homeassistant,
but the switch does not change in homeassistant for that device, and i can’t control the device from homeassistant, nor does it show anything when i turn the switch in home assistant, if i click the switch, it turns back to off after a second.

i followed this guide: https://www.youtube.com/watch?v=lUsMVrs1ot0

this is my conf in homeassistant.yaml

mqtt:
broker: localhost
port: 8081
protocol: 3.1
keepalive: 60
client_id: smartthings
username: not for you
password: not for you

switch:

  • platform: mqtt
    name: “Byro Stora Sovrummet”
    state_topic: “smartthings/2:Byro Stora Sovrummet/switch”
    command_topic: “smartthings/2:Byro Stora Sovrummet/switch”
    payload_on: “on”
    payload_off: “off”
    retain: true

and this is the conf from opt/mqtt-bridge/config.yml


mqtt:
# Specify your MQTT Broker’s hostname or IP address here
host: 192.168.1.194
# Preface for the topics $PREFACE/$DEVICE_NAME/$PROPERTY
preface: smartthings

# The write and read suffixes need to be different to be able to differentiate when state comes from SmartThings or wh$

# Suffix for the topics that receive state from SmartThings $PREFACE/$DEVICE_NAME/$PROPERTY/$STATE_READ_SUFFIX
# Your physical device or application should subscribe to this topic to get updated status from SmartThings
# state_read_suffix: state

# Suffix for the topics to send state back to SmartThings $PREFACE/$DEVICE_NAME/$PROPERTY/$STATE_WRITE_SUFFIX
# your physical device or application should write to this topic to update the state of SmartThings devices that suppo$
# state_write_suffix: set_state

# Suffix for the command topics $PREFACE/$DEVICE_NAME/$PROPERTY/$COMMAND_SUFFIX
# command_suffix: cmd

# Other optional settings from https://www.npmjs.com/package/mqtt#mqttclientstreambuilder-options
username: not for you
password: not for you

Port number to listen on

port: 8081

If i open a brower and go to http://192.168.1.194:8081 i gett: Cannot GET /

and when i run: pm2 start smartthings-mqtt-bridge i gett:

│ App name │ id │ mode │ pid │ status │ restart │ uptime │ cpu │ mem │ user │ watching │
├─────────────────────────┼────┼──────┼───────┼────────┼─────────┼────────┼─────┼───────────┼──────┼──────────┤
│ smartthings-mqtt-bridge │ 0 │ fork │ 11207 │ online │ 2 │ 0s │ 59% │ 13.9 MB │ pi │ disabled │

//Regards


(Duncan Smith) #2

Edit: Please ignore all the *** that have appeared in the files below

I have a similar issue having just installed Hassbian yesterday on my Pi 3B+.

Everything installed without issues (eventually) and if I add a bulb into the configuration.yaml file it shows in Home Assistant.

However if the bulb was on it doesn’t show its current state, if I try to use the switch in Home Assistant it moves and does nothing. If I use the Smartthings app on the phone to turn the device on/off it updates the switch in Home Assistant.

I am baffled as to why…

here is my configuration.yaml file

homeassistant:
** # Name of the location where Home Assistant is running**
** name: Home**
** # Location required to calculate the time the sun rises and sets**
** latitude: 51.4552**
** longitude: -2.5966**
** # Impacts weather/sunrise data (altitude above sea level in meters)**
** elevation: 10**
** # metric for Metric, imperial for Imperial**
** unit_system: metric**
** # Pick yours from here: http://en.wikipedia.org/wiki/List_of_tz_database_time_zones**
** time_zone: Europe/London**
** # Customization file**
** customize: !include customize.yaml**

# Show links to resources in log and frontend

frontend:

# Enables configuration UI
config:

http:
** # Secrets are defined in the file secrets.yaml**
** # api_password: !secret http_password**
** # Uncomment this if you are using SSL/TLS, running in Docker container, etc.**
** # base_url: example.duckdns.org:8123**

# Checks for available updates
# Note: This component will send some information about your system to
# the developers to assist with development of Home Assistant.
# For more information, please see:
# https://home-assistant.io/blog/2016/10/25/explaining-the-updater/
updater:
** # Optional, allows Home Assistant developers to focus on popular components.**
** # include_used_components: true**

# Discover some devices automatically
discovery:

# Allows you to issue voice commands from the frontend in enabled browsers
conversation:

# Enables support for tracking state changes over time
history:

# View all events in a logbook
logbook:

# Enables a map showing the location of tracked devices
map:

# Track the sun
sun:

# Weather prediction
sensor:
** - platform: yr**

# Text to speech
tts:
** - platform: google**

# Cloud
cloud:

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml

mqtt:
** broker: 192.168.0.189**
** port: 1883**
** protocol: 3.1**
** keepalive: 60**
** client_id: hass-1**
** username: ***********
** password: ***********

camera lounge:
** - platform: foscam**
** ip: 192.168.0.229**
** port: 88**
** username: ************
** password: ************
** name: Lounge Camera**

camera office:
** - platform: foscam**
** ip: 192.168.0.79**
** port: 88**
** username: **********
** password: **********
** name: Office Camera**

camera bay:
** - platform: foscam**
** ip: 192.168.0.164**
** port: 88**
** username: ***********
** password: ***********
** name: Bay Window Camera**

light:
** - platform: mqtt**
** name: “Office Light”**
** state_topic: “smartthings/Office Bulb Hive Light Tunable/switch”**
** command_topic: “smartthings/Office Bulb Hive Light Tunable/switch”**
** payload_on: “on”**
** payload_off: “off”**
** retain: true**

switch:
** - platform: mqtt**
** name: “Speakers”**
** state_topic: “smartthings/Speakers/switch”**
** command_topic: “smartthings/Speakers/switch”**
** payload_on: “on”**
** payload_off: “off”**
** retain: true**
** - platform: mqtt**
** name: “Fan Switch”**
** state_topic: “smartthings/Fan Switch/switch”**
** command_topic: “smartthings/Fan Switch/switch”**
** payload_on: “on”**
** payload_off: “off”**
** retain: true**

Here is my config.yaml


mqtt:
** # Specify your MQTT Broker’s hostname or IP address here**
** host: localhost**
** # Preface for the topics $PREFACE/$DEVICE_NAME/$PROPERTY**
** preface: smartthings**

** # The write and read suffixes need to be different to be able to differentiate when state comes from SmartThings or when its coming from the physical device/application**

** # Suffix for the topics that receive state from SmartThings $PREFACE/$DEVICE_NAME/$PROPERTY/$STATE_READ_SUFFIX**
** # Your physical device or application should subscribe to this topic to get updated status from SmartThings**
** # state_read_suffix: state**

** # Suffix for the topics to send state back to SmartThings $PREFACE/$DEVICE_NAME/$PROPERTY/$STATE_WRITE_SUFFIX**
** # your physical device or application should write to this topic to update the state of SmartThings devices that support setStatus**
** # state_write_suffix: set_state**

** # Suffix for the command topics $PREFACE/$DEVICE_NAME/$PROPERTY/$COMMAND_SUFFIX**
** # command_suffix: cmd**

** # Other optional settings from https://www.npmjs.com/package/mqtt#mqttclientstreambuilder-options**
** username:xxxxxxxx**
** password: xxxxxxxx **

# Port number to listen on
port: 8080