stjohnjohnson / smartthings-mqtt-bridge

Bridge between SmartThings and MQTT
https://hub.docker.com/r/stjohnjohnson/smartthings-mqtt-bridge/
MIT License
370 stars 243 forks source link

Getting this working as a addon for the new hassio homeassistant #83

Open CTLS opened 7 years ago

CTLS commented 7 years ago

I think once hass.io becomes more finalized, this will make setup of smartthings-mqtt-bridge on home assistant a lot easier. Hassio runs all addons in docker files and allows setup of the addons through the frontend. There is some more info on how to set up hassio addons at- https://home-assistant.io/hassio/addon_config/

rogersmj commented 7 years ago

100% agree! I just started playing with Hass.io and I love it, everything's so plug and play...but I can't use it yet because I completely depend on this great SmartThings MQTT bridge.

I have pretty much zero experience with docker, but if no one tackles this in the next few weeks I may try to make some time to hack away at it.

rogersmj commented 7 years ago

FYI @CTLS this was just posted: https://github.com/vkorn/hassio-addons/tree/master/smartthings

AJax2012 commented 7 years ago

@rogersmj have you gotten this working? I'm working with it and can't figure out how to connect it to SmartThings API...

mth3r commented 7 years ago

I'm looking for help too. Just a description of what each configuration item is would be helpful...something to the effect that the MQTT host Ip is the raspberrypi ip. I think it is pretty simple, but I'm obviously missing something

Darksabre commented 7 years ago

Definitely would like to get this working. I tried pasting the repo link into HASSIO, but it doesnt seem to do anything. Any help would be great!

jamescw commented 7 years ago

I got this working and it's a great solution for running the whole stack on an Rpi 3!

Firstly the addon linked above was missing a small piece of config that allows the addon to expose the port of the smartthings-bridge server. I created a small patch and submitted to the authors repo, hopefully that will get merged soon: https://github.com/vkorn/hassio-addons/pull/12

Then I used the following steps:

  1. I installed the hass.io Mosquitto broker addon with all the default settings.
  2. Installed the SmartThings addon with all the default settings but set the username and password fields to empty strings as the default config for the Mosquitto broker does not set these.
  3. Then followed all the steps here to connect SmartThings to Hass.io: https://github.com/stjohnjohnson/smartthings-mqtt-bridge#usage

Add the following config to Hass:

mqtt:
  broker: localhost
  port: 1883
  client_id: hassio
  keepalive: 60

Then define a light or sensor etc:

light:
  platform: mqtt
  name: "Lamp"
  state_topic: "smartthings/Lamp/switch/state"
  command_topic: "smartthings/Lamp/switch/cmd"
  payload_on: "on"
  payload_off: "off"

sensor:
  - platform: mqtt
    state_topic: "smartthings/Motion Sensor/temperature/state"
tielur commented 7 years ago

@jamescw You said you used all the default settings when setting up the SmartThings addon, it looks like it defaults to: "broker_host": "172.17.0.1". I assume you changed that to 127.0.0.1?

I'm having trouble getting this working following your directions.

Also is there an easy way to see messages in the queue to confirm something is working?

My Mosquitto broker logs are showing:

1508485059: New connection from 192.168.86.41 on port 1883.
1508485059: Socket error on client <unknown>, disconnecting.

Where 192.168.86.41 is my SmartThings hub

jamescw commented 7 years ago

@tielur no you don't want to change the broker host IP in the smart things bridge config.

172.17.0.1 is a special IP address that allows you to communicate with the docker daemon and another container running on same docker host, so assuming you have the Mosquitto container running on the same host (which it should if you are using the add-on), it should be able to connect to it at 172.17.0.1:1883 from the smartthings bridge container.

If you want to connect to the broker from another machine use something like MQTT.fx and use the IP or hostname of your RPi and the MQTT port to connect: hassio.local:1883

If all is well you should see messages from smartthings on the broker

tielur commented 7 years ago

@jamescw awww that address makes more sense now, I switched that back and it looks like it's working now. Thanks!

jaxbucsfan commented 6 years ago

Thank you guys for this full write up. I think I'm missing something, and i'm sure it something small at this point.

Any help or insight would be much appreciated. Clearly a Noob to Hass.io

On Hass I have two Add-Ons Mosquitto broker - Default Options SmartThingsBridge - Default Options (minus empty UN/PW) { "broker_host": "172.17.0.1", "broker_port": 8888, "preface": "smartthings", "state_suffix": "state", "command_suffix": "cmd", "login": "", "password": "", "bridge_port": 2080 }

In ST my device preferences are: MQTT Bridge IP Address: "local IP Address of Rpi" or <172.17.0.1> ??? Bridge Port: <2080> to match SmartThingsBridge info ??? MAC:

My configuration.yaml contains: mqtt: broker: localhost port: 1883 client_id: hassio keepalive: 60

My Log File outputs are as follows: Mosquito Broker: 1511909661: New connection from 172.30.32.1 on port 1883. 1511909661: New client connected from 172.30.32.1 as hassio (c1, k60)

SmartThingsBridge: info: Connecting to MQTT at mqtt://172.17.0.1:8888

cmlittle commented 6 years ago

@jaxbucsfan Try changing broker host to "localhost", your broker port to "1883" and your bridge port to "8080" in the smartthings-mqtt-bridge add-on.

cmlittle commented 6 years ago

I was able to get the the bridge working in hass.io - all switches seem to work, however, I can't get any of my temperature sensors to display correctly. A typical temperature sensor in my configuration looks like this:

I removed "state" and "cmd" from the bridge configuration, so I don't think that I need to add this at the end of "temperature" (i.e. smartthings/Garage Motion/Temperature/State). The above configuration worked just fine in my standard HomeAssistant installation, but they're not showing up now. Should "temperature" now be something else? I am able to see a power sensor, but none of my temperature or battery sensors. Anyone have any ideas?

partytimeexcellent commented 6 years ago

@cmlittle Did you ever get your ST sensors working? I'm noticing the same behavior.

vaderj commented 6 years ago

Did anyone ever get this working?

tielur commented 6 years ago

@vaderj I've been using it for months

vaderj commented 6 years ago

I just got it working. The value_templates was the last piece that I was missing.