SmartThings Community

A little guide on integrating smartthings and homeassistant (hassbian)


(Johan Karlquist) #21

A ok, glad it worked out for you.
if it happens again, just run these commands:

first:
pm2 restart smartthings-mqtt-bridge

then run this 3 lines one at the time:

sudo systemctl restart mosquitto.service
pm2 restart smartthings-mqtt-bridge
sudo systemctl restart home-assistant@homeassistant.service

//Regards


(carefree) #22

one nuisance is that Home Assistant uses the the key values ON/OFF for devices, while smarthings-mqtt only recognizes lower case on/off… :frowning:


(Johan Karlquist) #23

added 3 different exempel, as you can see you can name it what you like if you use pyload insteed.

device_class: door
  • platform: mqtt
    name: “Fönster Höger Ytterdörr”
    state_topic: “smartthings/Fönster Höger Ytterdörr/contact/state”
    payload_on: “open”
    payload_off: “closed”
    qos: 0
    device_class: window

  • platform: mqtt
    name: “BrandLarm KÖK”
    state_topic: “smartthings/vardag nere/smoke sensor/state”
    payload_on: “detected”
    payload_off: “clear”
    qos: 0
    device_class: smoke

  • platform: mqtt
    name: “Rörelse Föråd”
    state_topic: “smartthings/motion sensor/motion/state”
    payload_on: “active”
    payload_off: “inactive”
    qos: 0
    device_class: motion


(Jeff) #25

I’m using docker to run the bridge, posted an issue to GitHub last night linked below along with relevant screen shots, but if anyone feels like taking a crack at my issue here I’m all ears. I’d be more than happy to switch to the npm method if needed. Here’s what I posted to GitHub:

Nothing in opt/mqtt-bridge folder and I don’t see device info in HA but ST app and IDE seem to work fine.?

I’ll post more info about my setup and config ASAP but I wanted to get this posted right away because this is starting to bug me lol. Basically the title says it all, I have as much as I can configure without adding any device info to the configuration.yaml file, seems to be about the only thing I haven’t set up. The issue I believe I’m having is I need to be able to see ST device info in the home-assistant.log file and take that info and write it in the yaml file, however I don’t see any device info in the HA log at all. I was able to get everything running in the ST app and ST IDE and can see events in the ST app. Currently, I’m running Hassio 8.23 docker install on a Raspberry pi 3 with Stretch, node version 11.2.0, with the native Hassio Mosquitto addon brokering the MQTT events with the docker install method running the MQTT ST bridge. The hassio Mosquitto addon being set as broker, using the hassio internal integration setting to do so, and my enabling OAuth in the ST IDE My Smartthings, and My Devices are about the only variations to the setup procedure listed here that I performed. I want to mention that I don’t see where you can enable OAuth in the device handler and don’t know that you can, or even need to. Otherwise, the only thing I have noticed is an error in HA about the integration giving an unexpected response of none and another error that says you need an auth token for 172.xxx.x.2, an ip that I see a close relative of in the mosquitto logs, ie: 172.xxx.x.1 I believe, I’ll double check the similarities between these ip adresses soon. I’ll respond ASAP to questions as I would like to see this thing work.

Here’s a link to my GitHub post:



(Johan Karlquist) #26

are this an hass.io installation your using?

then ad vlads repro and use hiss integration of smartthings (much easier)

//Regards


(Jeff) #27

I’m loading up the vkorn addon now. I had done so in my first build that I wiped in favor of a clean install. When went to install in this time I tried to install stjohnjohnson smartthings-mqtt-bridge respiratory on its own by mistake and hassio didn’t recognize it and labeled it unknown and would not install. Thanks for reminding me about that, I completely overlooked it, I’ll see how it goes. :crossed_fingers:


(Jeff) #28

I installed the repo via Hass.io but I still don’t see much detail in the logs. I am considering a clean install to save time troubleshooting, I should delete the docker container running the bridge now that I am running the respiratory in hass.io right? Also, I noticed you can add mqtt sensors to the yaml file to “subscribe” so I am looking into that, and if it can be done before adding the json for the mqtt switches. I do see the following 2 events:

2018-12-08 02:34:41 DEBUG (MainThread) [homeassistant.components.mqtt] Subscribing to homeassistant/#

2018-12-08 02:39:25 WARNING (MainThread) [homeassistant.components.http.auth] You need to use a bearer token to access /api/ from 172.xxx.x.xx

My guess is this is not authorized because I changed the set up after installing docker at first and this is why I cannot see the mqtt events in the logs.


(Nigel Williams) #29

Hi everyone

I have come across this thread as I want to evolve my home automation to massively reduce the impact of internet/cloud on it.
I do like the functionality and capabilities of the STT platform. It integrates well with many other Home Automation solutions that also depend on the internet/cloud and the Hub itself provides both zwave and zigbee hardware support. I have a V2 hub with 195 devices paired, ranging from Fibaro zwave Double switches, STT zigbee Motion Sensors v1, 2 & 3, STT Leak Detector, STT Multi-sensors, Fibaro window sensors, aeotec multi sensors and presence sensors.

As I said earlier the only drawback to STT is its dependency on the internet/cloud to operate. Why does the platform need to use the cloud to tell a local zwave switch to turn on when a local zigbee motion sensor detects motion? The performance has improved with a combination of Smart Lighting SmartApps and webCoRE but it is still dependent on a performant internet connection. It makes no sense…

I have been researching hubitat but why should I invest in additional zwave/zigbee controllers when the STT Hub provides that?

So now I have just ordered a Raspberry Pi 3b+ 32Gb kit to get using MQTT to integrate locally with the STT hub and to allow locally processed home automation use cases, possibly with Home Assistant. Thus isolating it from issues and performance of internet connection.

Is the MQTT Bridge as efficient and performant as it sounds, to exchange device state changes between STT and say Home Assistant? Is it truly local to my intranet?

Is HA a good choice over openHAB as Home Platform of choice to move forward with?
Or is there an alternative I have overlooked.

From my perspective, continuing to use my STT V2 hub would then harness the zwave/zigbee networks more efficiently already in place?

I see there is talk about Hasbian and hass.io on here.
Given it is now Dec 2019 what is the best approach to integrating STT with HA on a Pi 3b?


(Johan Karlquist) #30

hi, i think you misunderstand how it works, it doesn’t matter if you use ha or openhab if the z-wave devices still going to be connected to smartthings hub, the smartthings hub still will connect to internet to be able to control z-wave. Ha will only send the command to smartthings hub just like anything else you send on/off commands. if you like to have offline control of z-wave you need to use a z-wave stick to Ha or use vera to ha or any other z-wave controller that can be handled offline. i can’t recommend you to use a usb dongle to ha since for me its to unstable. i use a vera that i control from Ha and smartthings hub 2 for all zigbee stuff that smartthings hub can handle offline. i did use a usb dongle with ha before but it takes forever to do a restart on Ha with that, i also prefer to use a nuc for ha, its extremely much faster and you also gett to use hass.io that easier to use. if you use vera or another offline controller with ha it is very stable and reboots in seconds. (vera is very slow if you dont control it with ha) fo me im thinking of getting a Homey to pair with my ha just to test with. another tip is to use alexa as a 3 part app to control ha with vera, it’s much faster and you dont need to set up vpn or https to ha with this. it’s cool to say turn on tv or goodbye or goodnight, turn on heater and so on and ha does the rest :wink:


(Nigel Williams) #31

Hi again
I have got my pi 3b+ and setup Hassbian as well as MQTT following the instructions here and on youtube here https://youtu.be/lUsMVrs1ot0
Thanks everyone for the suggestions.

I have exposed 1 switch, 1 motion sensor and 1 contact via the SmartApp and I can see state changes in the MQTT log on the pi :wink:
smartthings/HallwayMotion1/motion active
smartthings/LandingContact/contact closed
smartthings/LandingContact/contact open
smartthings/HallwayMotion1/motion inactive
smartthings/LandingLights/switch on
smartthings/LandingLights/switch off

I have tried to configure the light switch in configuration.yaml to start but I am not seeing the state changes reflected in Overview; the device is shown but its state is not updated on the Overview. see config below -

switch:
platform: mqtt
name: “LandingLights”
state_topic: “smartthings/LandingLights/switch”
command_topic: “smartthings/LandingLights/switch”
payload_on: “on”
payload_off: “off”
retain: true

Does anyone have any advice suggestions and guidance on why this is not working?
Is it HA not connecting to MQTT?

when I check the smartthings-mqtt-bridge log I get the following -
0|smartthi | info: Incoming message from MQTT: smartthings/LandingLights/switch = off
0|smartthi | info: Skipping duplicate message from: smartthings/LandingLights/switch = off
0|smartthi | info: Incoming message from MQTT: smartthings/LandingLights/switch = off
0|smartthi | info: Skipping duplicate message from: smartthings/LandingLights/switch = off

What is this about duplicate message? Can anyone explain please?

Here is my mqtt entry in configuration -
mqtt:
broker: localhost
port: 1883
keepalive: 60
client_id: smartthings
username: ***
password: *********
Is the client id relevant and what does have to match to in the MQTT configuration itself?

how to configure these 3 devices within Home Assistant please?
I am looking for examples to learn from…


(Nigel Williams) #34

Okies just to let you all know, I have now got it working all ok.
I have added the switch to the configuration.yaml
switch:
platform: mqtt
name: “Landing Lights”
state_topic: “smartthings/LandingLights/switch”
command_topic: “smartthings/LandingLights/switch”
payload_on: “on”
payload_off: “off”
retain: true

and it know works. I think the issue was between HA & MQTT.
Anycase, does anyone know of a way of keeping the mosqutto.service and smartthings-mqtt-bridge running after rebooting Raspbian?

Has anyone got example configurations of devices? I am looking to model contact [Open | Close] and a motion sensor [active | inactive] to start…


(Johan Karlquist) #35

Japp, here you got some examples
this need to be placed under binary_sensor:
if you have temperature and battery sensor they need to be placed under sensor (added exempel in the bottom)

binary_sensor:
- platform: mqtt
name: “motion sensor server”
state_topic: “smartthings/Rörelse sensor föråd/motion/state”
payload_on: “active”
payload_off: “inactive”
qos: 0
device_class: motion

and for smoke alarms

  • platform: mqtt
    name: “BrandLarm KÖK”
    state_topic: “smartthings/vardag nere/smoke/state”
    payload_on: “detected”
    payload_off: “clear”
    qos: 0
    device_class: smoke

And for open close window

  • platform: mqtt
    name: “window parking”
    state_topic: “smartthings/Kök Fönster parkering/contact/state”
    payload_on: “open”
    payload_off: “closed”
    qos: 0
    device_class: window

And for doors:

  • platform: mqtt
    name: “Main door”
    state_topic: “smartthings/main door/contact/state”
    payload_on: “open”
    payload_off: “closed”
    qos: 0
    device_class: door

Here are 1 example for adding sensors from 1 of the above devices.
it’s the same way for all others.

sensor:

  • platform: mqtt
    name: “Main door temperature”
    state_topic: “smartthings/Main door sensor/temperature/state”
    qos: 0
    device_class: temperature
    unit_of_measurement: “°C”
  • platform: mqtt
    name: “Main door Battery”
    state_topic: “smartthings/Main door sensor/battery/state”
    unit_of_measurement: “%”
    device_class: battery
    retain: true

//Hope it helps


(Nigel Williams) #36

Many thanks

I have tried to configure a motion sensor but it doesnt seem to update when the motion sensor is activated.
Here is a snippet from the mosquitto_log
smartthings/HallwayMotion1/motion active
smartthings/HallwayMotion1/motion inactive

binary_sensor:

  • platform: mqtt
    name: “Hallway”
    state_topic: “smartthings/HallwayMotion1/motion”
    payload_on: “active”
    payload_off: “inactive”
    qos: 0
    device_class: motion

Can someone point out what I am doing wrong please? Do I need the /state as I dont see them in the mosquitto log?


(David Proffer) #37

A couple things I noted as I set up the smartthings mqtt bridge

  1. I was a bit confused at first about the ‘port’ parameter. This is a TCP port that will be used to communicate between the SmartThings Hub and the smartthings mqtt bridge software. Nothing to do with the mqtt port. The smartthings mqtt bridge software uses the default port for the mosquitto configuration unless you change that in the config files for mosquitto and smarthings mqtt bridge. The port selected in the ‘port’ parameter must not be used by any other service on the machine with the smarthings mqtt bridge software. This port number is defined at the bottom config.yml file (described below) and in the device driver in the SmartThings console. The mqtt address and port? is defined at the top of the config.yml file.

  2. I am not a node software expert, but it appears the best practice for installing the smartthings mqtt bridge software is to do this as the root user.

  3. The mqtt bridge software appears to store it’s configuration information in a rather generically named file ‘config.yml’ in the home directory of the user you launch the app as. Make sure your instance is using the correct ‘config.yml’ and this file does not conflict with some other software that puts it file in same place and name.


(Simon Tether) #38

Smartthings integration is coming to Home Assistant soon in v0.87:


(Amauri Viguera) #39
  1. No brokers, bridges, or additional dependencies.

That’s almost worth looking into it right there.