Git Product home page Git Product logo

smartthings-mqtt-bridge's Introduction

SmartThings MQTT Bridge

System to share and control SmartThings device states in MQTT.

GitHub Tag Docker Pulls Docker Stars Wercker Status Gitter Donate

This project was spawned by the desire to control SmartThings from within Home Assistant. Since Home Assistant already supports MQTT, we chose to go and build a bridge between SmartThings and MQTT.

Architecture

Architecture

MQTT Events

Events about a device (power, level, switch) are sent to MQTT using the following format:

{PREFACE}/{DEVICE_NAME}/${ATTRIBUTE}

PREFACE is defined as "smartthings" by default in your configuration

For example, my Dimmer Z-Wave Lamp is called "Fireplace Lights" in SmartThings. The following topics are published:

# Brightness (0-99)
smartthings/Fireplace Lights/level
# Switch State (on|off)
smartthings/Fireplace Lights/switch

The Bridge also subscribes to changes in these topics, so that you can update the device via MQTT.

$ mqtt pub -t 'smartthings/Fireplace Lights/switch'  -m 'off'
# Light goes off in SmartThings

Configuration

The bridge has one yaml file for configuration:

---
mqtt:
    # Specify your MQTT Broker URL here
    host: mqtt://localhost
    # Example from CloudMQTT
    # host: mqtt:///m10.cloudmqtt.com:19427

    # 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: AzureDiamond
    # password: hunter2

    # MQTT retains state changes be default, retain mode can be disabled:
    # retain: false

# Port number to listen on
port: 8080

Installation

There are two ways to use this, Docker (self-contained) or NPM (can run on Raspberry Pi).

Docker

Docker will automatically download the image, but you can "install" it or "update" it via docker pull:

$ docker pull stjohnjohnson/smartthings-mqtt-bridge

To run it (using /opt/mqtt-bridge as your config directory and 8080 as the port):

$ docker run \
    -d \
    --name="mqtt-bridge" \
    -v /opt/mqtt-bridge:/config \
    -p 8080:8080 \
    stjohnjohnson/smartthings-mqtt-bridge

To restart it:

$ docker restart mqtt-bridge

NPM

To install the module, just use npm:

$ npm install -g smartthings-mqtt-bridge

If you want to run it, you can simply call the binary:

$ smartthings-mqtt-bridge
Starting SmartThings MQTT Bridge - v1.1.3
Loading configuration
No previous configuration found, creating one

Although we recommend using a process manager like PM2:

$ pm2 start smartthings-mqtt-bridge
[PM2] Starting smartthings-mqtt-bridge in fork_mode (1 instance)
[PM2] Done.
┌─────────────────────────┬────┬──────┬───────┬────────┬─────────┬────────┬────────────┬──────────┐
│ App name                │ id │ mode │ pid   │ status │ restart │ uptime │ memory     │ watching │
├─────────────────────────┼────┼──────┼───────┼────────┼─────────┼────────┼────────────┼──────────┤
│ smartthings-mqtt-bridge │ 1  │ fork │ 20715 │ online │ 0       │ 0s     │ 7.523 MB   │ disabled │
└─────────────────────────┴────┴──────┴───────┴────────┴─────────┴────────┴────────────┴──────────┘

$ pm2 logs smartthings-mqtt-bridge
smartthings-mqtt-bridge-1 (out): info: Starting SmartThings MQTT Bridge - v1.1.3
smartthings-mqtt-bridge-1 (out): info: Loading configuration
smartthings-mqtt-bridge-1 (out): info: No previous configuration found, creating one

$ pm2 restart smartthings-mqtt-bridge

Usage

  1. Customize the MQTT host

    $ vi config.yml
    # Restart the service to get the latest changes
    
  2. Install the Device Handler in the Device Handler IDE using "Create via code"

  3. Add the "MQTT Device" device in the My Devices IDE. Enter MQTT Device (or whatever) for the name. Select "MQTT Bridge" for the type. The other values are up to you.

  4. Configure the "MQTT Device" in the My Devices IDE with the IP Address, Port, and MAC Address of the machine running the Docker container

  5. Install the Smart App on the Smart App IDE using "Create via code"

  6. Configure the Smart App (via the Native App; on Android, this must be the Classic version) with the devices you want to share and the Device Handler you just installed as the bridge

  7. Via the Native App, select your MQTT device and watch as MQTT is populated with events from your devices

Advanced

Docker Compose

If you want to bundle everything together, you can use Docker Compose.

Just create a file called docker-compose.yml with this contents:

mqtt:
    image: matteocollina/mosca
    ports:
        - 1883:1883

mqttbridge:
    image: stjohnjohnson/smartthings-mqtt-bridge
    volumes:
        - ./mqtt-bridge:/config
    ports:
        - 8080:8080
    links:
        - mqtt

homeassistant:
    image: balloob/home-assistant
    ports:
        - 80:80
    volumes:
        - ./home-assistant:/config
        - /etc/localtime:/etc/localtime:ro
    links:
        - mqtt

This creates a directory called ./mqtt-bridge/ to store configuration for the bridge. It also creates a directory ./home-assistant to store configuration for HA.

Donate

If you use and love our bridge tool, please consider buying us a coffee by sending some Satoshi to 1sBPcBai7gZco6LipPthuyZ5rH4RKx1Bg.

Donate Bitcoin

smartthings-mqtt-bridge's People

Contributors

aceostar avatar airdrummingfool avatar b3nj1 avatar blink515 avatar gandazgul avatar jer avatar joelash avatar kdanthony avatar kenthua avatar mattsch avatar rafuz avatar scottchapman avatar sjfighter avatar stjohnjohnson avatar tobymoore avatar zifnab06 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

smartthings-mqtt-bridge's Issues

Where are the devices published?

I'm a little confused by the blog post on home-assistant.io

Replace localhost with the location of the running MQTT Broker. Devices from the MQTT Bridge are published to the path smartthings//

Where is this path?

Stops sending APP_COMMAND

I have a ST switch which I am having some trouble with. I am able to report data and state changes back into HA, but it has stopped working when I try and turn it on/off from HA>

Looking at the events for the device, the APP_COMMAND is no longer being sent to the device.

In live logging I have the following

Received device event from bridge: [name:Outlet - Cave, value:off, type:switch]
5b4c202e-aa61-4bdd-a9f4-4325f1ca38ac  5:11:59 PM: debug Parsing 'index:04, mac:B827EBCF6A7E, headers:UE9TVCAvIEhUVFAvMS4xDQpob3N0OiAxNzIuMTYuMC4yMDU6Mzk1MDANCmFjY2VwdDogYXBwbGljYXRpb24vanNvbg0KY29udGVudC10eXBlOiBhcHBsaWNhdGlvbi9qc29uDQpjb250ZW50LWxlbmd0aDogNjINCkNvbm5lY3Rpb246IGNsb3Nl, body:eyJuYW1lIjoiT3V0bGV0IC0gQ2F2ZSBIZWF0aW5nIiwidHlwZSI6InN3aXRjaCIsInZhbHVlIjoib2ZmIn0='

Any advice on where to start would be much appreciated

Cheers
Zak

Should this be included in homeassistant?

Hey all,

I'm new to the scene, but couldn't this library could be bundled with home assistant via dependencies? I realize it does lots of other things as well, but so does python-nmap and it's included. I feel like the SmartThings/HomeAssist combo is going to continue to get more popular so this would help raise adoption. Since the Raspberry Pi All in One installer sets up mosquito, you should be able to get going right out of the box once you have the SmartThings IDE set up.

Issue with Bridge

Hello,

I see traffic in the MQTT and in my smart app, but I cant control any of my lights, etc.
I see commands going to the MQTT and to my smart app (called SH) .

But what are the commands I use to get my lights recognized and functioning?

Name Value
archivable true
commandId 168907
date 2016-04-23 10:05:17.785 PM EDT (2016-04-24T02:05:17.785Z)
description
deviceId 2aa34a3b-45a3-463f-a78e-9162a27c4d17
displayed true
eventSource APP_COMMAND
hubId 5c157cfa-6335-4714-8620-6be7e072da6f
id fdcd9ba0-09c0-11e6-8947-0643aaa66965
installedSmartAppId b7eac426-6fc6-41fc-aaab-76ccd173314d
isStateChange true
isVirtualHub false
linkText MQTT Bridge
locationId 50264796-314f-48ab-bb35-900757c6e0da
rawDescription MQTT Bridge sent deviceNotification command to SH
smartAppId 55ec89dc-950c-4a00-83fd-cb7e7e5b1ee9
smartAppVersionId b472088a-36aa-4ad6-97d0-1f05c11f2e6f
translatable false
unixTime 1461463517785
value deviceNotification
viewed false

config not saving

I am running this in docker on a qnap and if anything unexpected happens like a reboot, the config file is gone and a default one is replaced in the shared directory. None of my other docker containers have this problem. Any ideas or something to look for?

Connecting to MQTT at mqtt://mqtt

[11:50:35] pi@roosterpi1:~$ smartthings-mqtt-bridge
info: Starting SmartThings MQTT Bridge - v1.3.4
info: Loading configuration
info: Loading previous state
info: Perfoming configuration migration
info: Saving current state
info: Connecting to MQTT at mqtt://mqtt

Shouldn't this be Connecting to MQTT at mqtt://localhost..? It's not connecting. Where can I update this to point to my local server?

Thanks!

No requests coming through

I've got the device and smartapp setup, but nothing ever makes it to my mqtt bridge running in docker (watching access.log for traffic). I can manually hit ip:8080 in a browser outside my network and that shows up, but no notifications from ST.

I also see this in ST logging for the MQTT Device:
Sending '{"path":"/push","body":{"name":"Couch Lamps","value":"off","type":"switch"}}' to device

Thanks for any help!

Status Topic

I have been using this and it is incredible! Thank you very much for putting this together for us SmartThings users who like to make our own interfaces in Home Assistant.

Would it be possible to include a separate state topic for each exposed ST device?

For example, we currently get events AND send commands to smartthings/Fireplace Lights/switch.
I'd like to be able to get events at smartthings/Fireplace Lights/switch/state and send commands to smartthings/Fireplace Lights/switch/cmd. That way when I send a command, I can confirm that it worked by checking the state again.

Looking forward to your response!

doesn't pull messages from MQTT

I've finally managed to get HomeAssistant to reflect the current state of a Smartthings device. I can change the device state via Smartthings app and it updates in HA webui. The webui will also update when I send a pub directly to MQTT

What doesn't work is the bridge recognizing state changes in MQTT and sending the commands to SmartThings. I never see the "Incoming message from MQTT: " message in the output of mqtt-bridge. I've tried the mosca Docker container as well as mosquitto for the MQTT broker: same results. I also tried the Docker container for mqtt-bridge as well as the npm app. Again, same results. The bridge never picks up event requests from HA to send to ST.

I'm sure there is something small that I'm missing. Here is my config:

mqtt:
  host: mqtt://192.168.1.23:1883
  preface: smartthings

port: 8080

Unable to communicate with MQTT broker

I have the bridge installed on two Pis (test/production). Both setups are almost identical and I am using Mosquitto on both. The bridge works perfectly on the test Pi, but am not able to do the same in the other Pi. Here are the logs:

4af84553-c102-4dc1-b6a4-1a7efbfc8336  12:19:43 PM: error java.lang.NullPointerException: Cannot invoke method deviceNotification() on null object @ line 502
4af84553-c102-4dc1-b6a4-1a7efbfc8336  12:19:43 PM: debug Updating subscription: {"path":"/subscribe","body":{"devices":{"notify":["Contacts","System"],"acceleration":[],"alarm":[],"battery":[],"presence":["Alok Life360","Rashmi's Life360"],"button":[],"carbonDioxide":[],"carbonMonoxide":[],"hue":[],"saturation":[],"color":[],"colorTemperature":[],"consumable":[],"contact":[],"door":[],"energy":[],"illuminance":[],"image":[],"level":["LivingRoomSonos Sonos"],"lock":[],"activities":[],"currentActivity":[],"motion":[],"status":["LivingRoomSonos Sonos"],"trackDescription":["LivingRoomSonos Sonos"],"trackData":["LivingRoomSonos Sonos"],"mute":["LivingRoomSonos Sonos"],"pH":[],"power":[],"humidity":[],"switch":["Driveway"],"shock":[],"lqi":[],"rssi":[],"sleeping":[],"smoke":[],"sound":[],"steps":[],"goal":[],"soundPressureLevel":[],"tamper":[],"temperature":[],"heatingSetpoint":[],"coolingSetpoint":[],"thermostatSetpoint":[],"thermostatMode":[],"thermostatFanMode":[],"thermostatOperatingState":[],"threeAxis":[],"timeRemaining":[],"sessionStatus":[],"touch":[],"voltage":[],"water":[],"windowShade":[]}}}
8c9b3093-5f13-404e-b85c-fd1f968d5020  12:19:24 PM: debug Parsing 'index:17, mac:B827EB9A61AE, ip:C0A8020C, port:1F90, requestId:197d8284-40bd-4ca9-b143-2301d265d34a, headers:SFRUUC8xLjEgMjAwIE9LDQpYLVBvd2VyZWQtQnk6IEV4cHJlc3MNCkNvbnRlbnQtVHlwZTogYXBwbGljYXRpb24vanNvbjsgY2hhcnNldD11dGYtOA0KQ29udGVudC1MZW5ndGg6IDE1DQpFVGFnOiBXLyJmLURIZHBsNU0rdGdnenMzdnE5RGdVeUEiDQpEYXRlOiBUaHUsIDAxIERlYyAyMDE2IDE3OjE5OjI0IEdNVA0KQ29ubmVjdGlvbjoga2VlcC1hbGl2ZQ==, body:eyJzdGF0dXMiOiJPSyJ9'
4771e6a4-e3ee-4262-bb86-0091612e534a  12:19:23 PM: debug Updating subscription: {"path":"/subscribe","body":{"devices":{"notify":["Contacts","System"],"acceleration":[],"alarm":[],"battery":[],"presence":["Alok Life360","Rashmi's Life360"],"button":[],"carbonDioxide":[],"carbonMonoxide":[],"hue":[],"saturation":[],"color":[],"colorTemperature":[],"consumable":[],"contact":[],"door":[],"energy":[],"illuminance":[],"image":[],"level":[],"lock":[],"activities":[],"currentActivity":[],"motion":[],"status":[],"trackDescription":[],"trackData":[],"mute":[],"pH":[],"power":[],"humidity":[],"switch":["Driveway"],"shock":[],"lqi":[],"rssi":[],"sleeping":[],"smoke":[],"sound":[],"steps":[],"goal":[],"soundPressureLevel":[],"tamper":[],"temperature":[],"heatingSetpoint":[],"coolingSetpoint":[],"thermostatSetpoint":[],"thermostatMode":[],"thermostatFanMode":[],"thermostatOperatingState":[],"threeAxis":[],"timeRemaining":[],"sessionStatus":[],"touch":[],"voltage":[],"water":[],"windowShade":[]}}}
8c9b3093-5f13-404e-b85c-fd1f968d5020  12:19:24 PM: debug Sending '{"path":"/subscribe","body":{"devices":{"notify":["Contacts","System"],"acceleration":[],"alarm":[],"battery":[],"presence":["Alok Life360","Rashmi's Life360"],"button":[],"carbonDioxide":[],"carbonMonoxide":[],"hue":[],"saturation":[],"color":[],"colorTemperature":[],"consumable":[],"contact":[],"door":[],"energy":[],"illuminance":[],"image":[],"level":[],"lock":[],"activities":[],"currentActivity":[],"motion":[],"status":[],"trackDescription":[],"trackData":[],"mute":[],"pH":[],"power":[],"humidity":[],"switch":["Driveway"],"shock":[],"lqi":[],"rssi":[],"sleeping":[],"smoke":[],"sound":[],"steps":[],"goal":[],"soundPressureLevel":[],"tamper":[],"temperature":[],"heatingSetpoint":[],"coolingSetpoint":[],"thermostatSetpoint":[],"thermostatMode":[],"thermostatFanMode":[],"thermostatOperatingState":[],"threeAxis":[],"timeRemaining":[],"sessionStatus":[],"touch":[],"voltage":[],"water":[],"windowShade":[]}}}' to device
c2a22a06-2d7f-470c-94e3-6b8ffd2d6a7c  12:19:06 PM: debug Updating subscription: {"path":"/subscribe","body":{"devices":{"notify":["Contacts","System"],"acceleration":[],"alarm":[],"battery":[],"presence":["Rashmi's Life360","Alok Life360"],"button":[],"carbonDioxide":[],"carbonMonoxide":[],"hue":[],"saturation":[],"color":[],"colorTemperature":[],"consumable":[],"contact":[],"door":[],"energy":[],"illuminance":[],"image":[],"level":["LivingRoomSonos Sonos"],"lock":[],"activities":[],"currentActivity":[],"motion":[],"status":["LivingRoomSonos Sonos"],"trackDescription":["LivingRoomSonos Sonos"],"trackData":["LivingRoomSonos Sonos"],"mute":["LivingRoomSonos Sonos"],"pH":[],"power":[],"humidity":[],"switch":["Driveway"],"shock":[],"lqi":[],"rssi":[],"sleeping":[],"smoke":[],"sound":[],"steps":[],"goal":[],"soundPressureLevel":[],"tamper":[],"temperature":[],"heatingSetpoint":[],"coolingSetpoint":[],"thermostatSetpoint":[],"thermostatMode":[],"thermostatFanMode":[],"thermostatOperatingState":[],"threeAxis":[],"timeRemaining":[],"sessionStatus":[],"touch":[],"voltage":[],"water":[],"windowShade":[]}}}
49f7cb2d-84cd-4e45-ad97-4cc3d13c6598  12:19:06 PM: debug Sending '{"path":"/subscribe","body":{"devices":{"notify":["Contacts","System"],"acceleration":[],"alarm":[],"battery":[],"presence":["Rashmi's Life360","Alok Life360"],"button":[],"carbonDioxide":[],"carbonMonoxide":[],"hue":[],"saturation":[],"color":[],"colorTemperature":[],"consumable":[],"contact":[],"door":[],"energy":[],"illuminance":[],"image":[],"level":["LivingRoomSonos Sonos"],"lock":[],"activities":[],"currentActivity":[],"motion":[],"status":["LivingRoomSonos Sonos"],"trackDescription":["LivingRoomSonos Sonos"],"trackData":["LivingRoomSonos Sonos"],"mute":["LivingRoomSonos Sonos"],"pH":[],"power":[],"humidity":[],"switch":["Driveway"],"shock":[],"lqi":[],"rssi":[],"sleeping":[],"smoke":[],"sound":[],"steps":[],"goal":[],"soundPressureLevel":[],"tamper":[],"temperature":[],"heatingSetpoint":[],"coolingSetpoint":[],"thermostatSetpoint":[],"thermostatMode":[],"thermostatFanMode":[],"thermostatOperatingState":[],"threeAxis":[],"timeRemaining":[],"sessionStatus":[],"touch":[],"voltage":[],"water":[],"windowShade":[]}}}' to device
8c9b3093-5f13-404e-b85c-fd1f968d5020  12:18:11 PM: debug Parsing 'index:17, mac:B827EB9A61AE, ip:C0A8020C, port:1F90, requestId:9e2a740a-2832-4df4-bb70-e675cdcd9824, headers:SFRUUC8xLjEgMjAwIE9LDQpYLVBvd2VyZWQtQnk6IEV4cHJlc3MNCkNvbnRlbnQtVHlwZTogYXBwbGljYXRpb24vanNvbjsgY2hhcnNldD11dGYtOA0KQ29udGVudC1MZW5ndGg6IDE1DQpFVGFnOiBXLyJmLURIZHBsNU0rdGdnenMzdnE5RGdVeUEiDQpEYXRlOiBUaHUsIDAxIERlYyAyMDE2IDE3OjE4OjEwIEdNVA0KQ29ubmVjdGlvbjoga2VlcC1hbGl2ZQ==, body:eyJzdGF0dXMiOiJPSyJ9'
c2a22a06-2d7f-470c-94e3-6b8ffd2d6a7c  12:18:10 PM: debug Forwarding device event to bridge: {"path":"/push","body":{"name":"Driveway","value":"off","type":"switch"}}
49f7cb2d-84cd-4e45-ad97-4cc3d13c6598  12:18:10 PM: debug Sending '{"path":"/push","body":{"name":"Driveway","value":"off","type":"switch"}}' to device
4771e6a4-e3ee-4262-bb86-0091612e534a  12:18:10 PM: debug Forwarding device event to bridge: {"path":"/push","body":{"name":"Driveway","value":"off","type":"switch"}}
8c9b3093-5f13-404e-b85c-fd1f968d5020  12:18:10 PM: debug Sending '{"path":"/push","body":{"name":"Driveway","value":"off","type":"switch"}}' to device
4af84553-c102-4dc1-b6a4-1a7efbfc8336  12:18:10 PM: error java.lang.NullPointerException: Cannot invoke method deviceNotification() on null object @ line 549
4af84553-c102-4dc1-b6a4-1a7efbfc8336  12:18:10 PM: debug Forwarding device event to bridge: {"path":"/push","body":{"name":"Driveway","value":"off","type":"switch"}}
a0ac5fb6-7f1e-4cba-8a68-6c8c6315a30e  12:18:10 PM: trace Notify: BinaryState = off
a0ac5fb6-7f1e-4cba-8a68-6c8c6315a30e  12:18:10 PM: debug Parsing 'index:06, mac:14918247EF01, headers:Tk9USUZZIC8gSFRUUC8xLjENCkhPU1Q6IDE5Mi4xNjguMi40MjozOTUwMA0KQ09OVEVOVC1UWVBFOiB0ZXh0L3htbDsgY2hhcnNldD0idXRmLTgiDQpDT05URU5ULUxFTkdUSDogMTMyDQpOVDogdXBucDpldmVudA0KTlRTOiB1cG5wOnByb3BjaGFuZ2UNClNJRDogdXVpZDowZDk2MjE3NC0xZGQyLTExYjItYTU0MS1kNWVkYmViNmFhMjANClNFUTogNA==, body:PGU6cHJvcGVydHlzZXQgeG1sbnM6ZT0idXJuOnNjaGVtYXMtdXBucC1vcmc6ZXZlbnQtMS0wIj4KPGU6cHJvcGVydHk+CjxCaW5hcnlTdGF0ZT4wPC9CaW5hcnlTdGF0ZT4KPC9lOnByb3BlcnR5Pgo8L2U6cHJvcGVydHlzZXQ+CgoN'
a0ac5fb6-7f1e-4cba-8a68-6c8c6315a30e  12:18:10 PM: trace Got SetBinaryStateResponse = 0
a0ac5fb6-7f1e-4cba-8a68-6c8c6315a30e  12:18:10 PM: debug Parsing 'index:17, mac:14918247EF01, ip:C0A802CE, port:C001, requestId:d6e4216b-99c6-4c8a-a84f-9d423245b7d9, headers:SFRUUC8xLjEgMjAwIE9LDQpDT05URU5ULUxFTkdUSDogMzc2DQpDT05URU5ULVRZUEU6IHRleHQveG1sOyBjaGFyc2V0PSJ1dGYtOCINCkRBVEU6IFRodSwgMDEgRGVjIDIwMTYgMTc6MTc6NTggR01UDQpFWFQ6DQpTRVJWRVI6IFVuc3BlY2lmaWVkLCBVUG5QLzEuMCwgVW5zcGVjaWZpZWQNClgtVXNlci1BZ2VudDogcmVkc29uaWM=, body:PHM6RW52ZWxvcGUgeG1sbnM6cz0iaHR0cDovL3NjaGVtYXMueG1sc29hcC5vcmcvc29hcC9lbnZlbG9wZS8iIHM6ZW5jb2RpbmdTdHlsZT0iaHR0cDovL3NjaGVtYXMueG1sc29hcC5vcmcvc29hcC9lbmNvZGluZy8iPjxzOkJvZHk+Cjx1OlNldEJpbmFyeVN0YXRlUmVzcG9uc2UgeG1sbnM6dT0idXJuOkJlbGtpbjpzZXJ2aWNlOmJhc2ljZXZlbnQ6MSI+DQo8QmluYXJ5U3RhdGU+MDwvQmluYXJ5U3RhdGU+DQo8Q291bnRkb3duRW5kVGltZT4wPC9Db3VudGRvd25FbmRUaW1lPg0KPGRldmljZUN1cnJlbnRUaW1lPjE0ODA2MTI2Nzg8L2RldmljZUN1cnJlbnRUaW1lPg0KPC91OlNldEJpbmFyeVN0YXRlUmVzcG9uc2U+DQo8L3M6Qm9keT4gPC9zOkVudmVsb3BlPg=='
a0ac5fb6-7f1e-4cba-8a68-6c8c6315a30e  12:18:10 PM: debug Parsing 'index:05, mac:14918247EF01, headers:Tk9USUZZIC8gSFRUUC8xLjENCkhPU1Q6IDE5Mi4xNjguMi40MjozOTUwMA0KQ09OVEVOVC1UWVBFOiB0ZXh0L3htbDsgY2hhcnNldD0idXRmLTgiDQpDT05URU5ULUxFTkdUSDogMjE5DQpOVDogdXBucDpldmVudA0KTlRTOiB1cG5wOnByb3BjaGFuZ2UNClNJRDogdXVpZDowZDk2MjE3NC0xZGQyLTExYjItYTU0MS1kNWVkYmViNmFhMjANClNFUTogMw==, body:PGU6cHJvcGVydHlzZXQgeG1sbnM6ZT0idXJuOnNjaGVtYXMtdXBucC1vcmc6ZXZlbnQtMS0wIj4KPGU6cHJvcGVydHk+CjxDb3VudGRvd25FbmRUaW1lPjA8L0NvdW50ZG93bkVuZFRpbWU+CjwvZTpwcm9wZXJ0eT4KPGU6cHJvcGVydHk+CjxkZXZpY2VDdXJyZW50VGltZT4xNDgwNjEyNjc4PC9kZXZpY2VDdXJyZW50VGltZT4KPC9lOnByb3BlcnR5Pgo8L2U6cHJvcGVydHlzZXQ+CgoN'
a0ac5fb6-7f1e-4cba-8a68-6c8c6315a30e  12:18:09 PM: debug Using ip: C0A802CE and port: C001 for device: a0ac5fb6-7f1e-4cba-8a68-6c8c6315a30e
a0ac5fb6-7f1e-4cba-8a68-6c8c6315a30e  12:18:09 PM: debug Executing 'off'
8c9b3093-5f13-404e-b85c-fd1f968d5020  12:18:07 PM: debug Parsing 'index:17, mac:B827EB9A61AE, ip:C0A8020C, port:1F90, requestId:dea55f0f-f3a0-4851-9ded-9315f361a843, headers:SFRUUC8xLjEgMjAwIE9LDQpYLVBvd2VyZWQtQnk6IEV4cHJlc3MNCkNvbnRlbnQtVHlwZTogYXBwbGljYXRpb24vanNvbjsgY2hhcnNldD11dGYtOA0KQ29udGVudC1MZW5ndGg6IDE1DQpFVGFnOiBXLyJmLURIZHBsNU0rdGdnenMzdnE5RGdVeUEiDQpEYXRlOiBUaHUsIDAxIERlYyAyMDE2IDE3OjE4OjA2IEdNVA0KQ29ubmVjdGlvbjoga2VlcC1hbGl2ZQ==, body:eyJzdGF0dXMiOiJPSyJ9'
c2a22a06-2d7f-470c-94e3-6b8ffd2d6a7c  12:18:06 PM: debug Forwarding device event to bridge: {"path":"/push","body":{"name":"Driveway","value":"on","type":"switch"}}
4771e6a4-e3ee-4262-bb86-0091612e534a  12:18:06 PM: debug Forwarding device event to bridge: {"path":"/push","body":{"name":"Driveway","value":"on","type":"switch"}}
49f7cb2d-84cd-4e45-ad97-4cc3d13c6598  12:18:06 PM: debug Sending '{"path":"/push","body":{"name":"Driveway","value":"on","type":"switch"}}' to device
8c9b3093-5f13-404e-b85c-fd1f968d5020  12:18:06 PM: debug Sending '{"path":"/push","body":{"name":"Driveway","value":"on","type":"switch"}}' to device
4af84553-c102-4dc1-b6a4-1a7efbfc8336  12:18:06 PM: error java.lang.NullPointerException: Cannot invoke method deviceNotification() on null object @ line 549
4af84553-c102-4dc1-b6a4-1a7efbfc8336  12:18:06 PM: debug Forwarding device event to bridge: {"path":"/push","body":{"name":"Driveway","value":"on","type":"switch"}}
a0ac5fb6-7f1e-4cba-8a68-6c8c6315a30e  12:18:06 PM: trace Notify: BinaryState = on
a0ac5fb6-7f1e-4cba-8a68-6c8c6315a30e  12:18:06 PM: debug Parsing 'index:04, mac:14918247EF01, headers:Tk9USUZZIC8gSFRUUC8xLjENCkhPU1Q6IDE5Mi4xNjguMi40MjozOTUwMA0KQ09OVEVOVC1UWVBFOiB0ZXh0L3htbDsgY2hhcnNldD0idXRmLTgiDQpDT05URU5ULUxFTkdUSDogMTMyDQpOVDogdXBucDpldmVudA0KTlRTOiB1cG5wOnByb3BjaGFuZ2UNClNJRDogdXVpZDowZDk2MjE3NC0xZGQyLTExYjItYTU0MS1kNWVkYmViNmFhMjANClNFUTogMg==, body:PGU6cHJvcGVydHlzZXQgeG1sbnM6ZT0idXJuOnNjaGVtYXMtdXBucC1vcmc6ZXZlbnQtMS0wIj4KPGU6cHJvcGVydHk+CjxCaW5hcnlTdGF0ZT4xPC9CaW5hcnlTdGF0ZT4KPC9lOnByb3BlcnR5Pgo8L2U6cHJvcGVydHlzZXQ+CgoN'
a0ac5fb6-7f1e-4cba-8a68-6c8c6315a30e  12:18:06 PM: debug Parsing 'index:03, mac:14918247EF01, headers:Tk9USUZZIC8gSFRUUC8xLjENCkhPU1Q6IDE5Mi4xNjguMi40MjozOTUwMA0KQ09OVEVOVC1UWVBFOiB0ZXh0L3htbDsgY2hhcnNldD0idXRmLTgiDQpDT05URU5ULUxFTkdUSDogMjI4DQpOVDogdXBucDpldmVudA0KTlRTOiB1cG5wOnByb3BjaGFuZ2UNClNJRDogdXVpZDowZDk2MjE3NC0xZGQyLTExYjItYTU0MS1kNWVkYmViNmFhMjANClNFUTogMQ==, body:PGU6cHJvcGVydHlzZXQgeG1sbnM6ZT0idXJuOnNjaGVtYXMtdXBucC1vcmc6ZXZlbnQtMS0wIj4KPGU6cHJvcGVydHk+CjxDb3VudGRvd25FbmRUaW1lPjE0ODA2MTgwNzU8L0NvdW50ZG93bkVuZFRpbWU+CjwvZTpwcm9wZXJ0eT4KPGU6cHJvcGVydHk+CjxkZXZpY2VDdXJyZW50VGltZT4xNDgwNjEyNjc1PC9kZXZpY2VDdXJyZW50VGltZT4KPC9lOnByb3BlcnR5Pgo8L2U6cHJvcGVydHlzZXQ+CgoN'
a0ac5fb6-7f1e-4cba-8a68-6c8c6315a30e  12:18:06 PM: trace Got SetBinaryStateResponse = 1
a0ac5fb6-7f1e-4cba-8a68-6c8c6315a30e  12:18:06 PM: debug Parsing 'index:17, mac:14918247EF01, ip:C0A802CE, port:C001, requestId:49e70c5f-2b3c-461a-8904-04ada279602c, headers:SFRUUC8xLjEgMjAwIE9LDQpDT05URU5ULUxFTkdUSDogMzc2DQpDT05URU5ULVRZUEU6IHRleHQveG1sOyBjaGFyc2V0PSJ1dGYtOCINCkRBVEU6IFRodSwgMDEgRGVjIDIwMTYgMTc6MTc6NTUgR01UDQpFWFQ6DQpTRVJWRVI6IFVuc3BlY2lmaWVkLCBVUG5QLzEuMCwgVW5zcGVjaWZpZWQNClgtVXNlci1BZ2VudDogcmVkc29uaWM=, body:PHM6RW52ZWxvcGUgeG1sbnM6cz0iaHR0cDovL3NjaGVtYXMueG1sc29hcC5vcmcvc29hcC9lbnZlbG9wZS8iIHM6ZW5jb2RpbmdTdHlsZT0iaHR0cDovL3NjaGVtYXMueG1sc29hcC5vcmcvc29hcC9lbmNvZGluZy8iPjxzOkJvZHk+Cjx1OlNldEJpbmFyeVN0YXRlUmVzcG9uc2UgeG1sbnM6dT0idXJuOkJlbGtpbjpzZXJ2aWNlOmJhc2ljZXZlbnQ6MSI+DQo8QmluYXJ5U3RhdGU+MTwvQmluYXJ5U3RhdGU+DQo8Q291bnRkb3duRW5kVGltZT4wPC9Db3VudGRvd25FbmRUaW1lPg0KPGRldmljZUN1cnJlbnRUaW1lPjE0ODA2MTI2NzU8L2RldmljZUN1cnJlbnRUaW1lPg0KPC91OlNldEJpbmFyeVN0YXRlUmVzcG9uc2U+DQo8L3M6Qm9keT4gPC9zOkVudmVsb3BlPg=='
a0ac5fb6-7f1e-4cba-8a68-6c8c6315a30e  12:18:06 PM: debug Using ip: C0A802CE and port: C001 for device: a0ac5fb6-7f1e-4cba-8a68-6c8c6315a30e
a0ac5fb6-7f1e-4cba-8a68-6c8c6315a30e  12:18:06 PM: debug Executing 'on'
 12:17:58 PM: info Waiting on events...
 12:17:58 PM: info For past logs for individual things go to the My Devices section, find the device and click on the Events link on the device information page.
 12:17:58 PM: info This console provides live logging of your SmartThings.

There are couple of errors for device 4af84553-c102-4dc1-b6a4-1a7efbfc8336, but am not sure how to resolve the same. Other than the errors in the log....there are no errors elsewhere (including in the app). I will appreciate any help/guidance...thanks!

Need integration tests

This includes:

  • Create the Docker container
  • Start it up
  • Subscribe to events
  • Send messages from SmartThings
  • Send messages from MQTT

We should test the following configs:

  • No existing config
  • Existing config before 1.1.0
  • Existing config after 1.1.0

Request: option for periodic push of current states

I update and reboot every Monday morning and HA loses / forgets the state of majority of the sensors from ST until the device updates and sends to Mqtt. Would be nice to be able to set a periodic push from ST of all current states

Brightness issue

Having trouble adjusting brightness levels for switches/lights within HomeAssistant.

It will adjust the level, but only seems to work sometimes. Also, if I increase brightness in either smartthings or home-assistant, it will not update the other? Not sure if there is a template to use. I think part of the problem is home-assistant uses 1-255 for level, while smartthings seems to use 1-99.

light 2:
platform: mqtt
name: "Living Room Lamp"
state_topic: "smartthings/Living Room Lamp/switch"
command_topic: "smartthings/Living Room Lamp/switch"
brightness_state_topic: "smartthings/Living Room Lamp/level"
brightness_command_topic: "smartthings/Living Room Lamp/level"
payload_on: "on"
payload_off: "off"
retain: true

cannot get home assistant to control ST outlet thru MQTT bridge

I need help :(

I cannot get home assistant to control my ST outlet (the only ST device I have). HASS does accurately show the state of the switch (on/off) when I control it through ST. However, when I try to turn it off or on thru HASS, it never makes it to ST.

I followed the guide here. I used Docker for all things and I'm running them individually. I verified that the network ID and MAC address match in the ST IDE. What else am I missing? What can I look at to troubleshoot the issue?

Light will turn off but not on

Hi,
I'm able to publish to turn a light off but not on or adjust the light level. I'll post my findings below. The light started on, set by the Smartthings app.

Commands:
mosquitto_pub -t 10.0.0.2 -p 1883 -t "smartthings/Living Room Light/switch" -m off
mosquitto_pub -t 10.0.0.2 -p 1883 -t "smartthings/Living Room Light/switch" -m on
mosquitto_pub -t 10.0.0.2 -p 1883 -t "smartthings/Living Room Light/level" -m 50

Live log from Smartthings:
c4615387-8aaf-4ebb-b4db-42336cf0f094 7:45:48 PM: debug Received device event from bridge: [name:Living Room Light, value:50, type:level]
c4615387-8aaf-4ebb-b4db-42336cf0f094 7:45:40 PM: debug Received device event from bridge: [name:Living Room Light, value:100, type:level]
c4615387-8aaf-4ebb-b4db-42336cf0f094 7:45:36 PM: debug Received device event from bridge: [status:OK]
c4615387-8aaf-4ebb-b4db-42336cf0f094 7:45:35 PM: debug Forwarding device event to bridge: {"path":"/push","body":{"name":"Living Room Light","value":"off","type":"switch"}}
c4615387-8aaf-4ebb-b4db-42336cf0f094 7:45:34 PM: debug Received device event from bridge: [name:Living Room Light, value:off, type:switch]

Log from mqtt bridge:
2016-05-14T23:48:27.101Z - info: Incoming message from MQTT: smartthings/Living Room Light/switch = off
2016-05-14T23:48:28.361Z - info: Incoming message from SmartThings: smartthings/Living Room Light/switch = off
2016-05-14T23:48:28.363Z - info: Incoming message from MQTT: smartthings/Living Room Light/switch = off
2016-05-14T23:48:28.363Z - info: Skipping duplicate message from: smartthings/Living Room Light/switch = off
2016-05-14T23:48:30.105Z - info: Incoming message from MQTT: smartthings/Living Room Light/switch = on
2016-05-14T23:48:30.105Z - info: Passing level instead of switch on
2016-05-14T23:48:32.616Z - info: Incoming message from MQTT: smartthings/Living Room Light/level = 50
2016-05-14T23:48:32.616Z - info: Skipping duplicate message from: smartthings/Living Room Light/level = 50

Debugging assistance

So are there any suggestions for debugging this bridge? I have it set up as described running in a docker container on a Synology NAS. As far as I can tell I don't have anything flowing through it yet. Using mosquitto_sub I don't see any messages related to this bridge. The events.log file has nothing interesting in it. It would be nice if there were a simple way to enable some debugging logging.

-tl

MQTT to Smartthings

Just setup my Smartthings to MQTT gateway. Messages are being sent and accepted for smartthing type devices (presence sensor, switch, GE Link bulb etc...) I have setup some temp sensors (DS18B20) using an Arduino, The Arduino posts temp readings to the MQTT bridge. I would like to incorporate these temp sensors into Smartthings and have the MQTT bridge update the value.
I created a Custom device handler in smartthings and the MQTT bridge sees it. I linked it and when I manually post a message the Bridge picks it up and I see the the message arrive at the smartapp.
However the Smartapp does not update the value for the device. Any help will be greatly appreciated.

Thanks.
entry from event.log:
2016-11-19T13:40:06.849Z - info: Incoming message from MQTT: smartthings/Garage Attic Temp/temperature = 74.2

entry from smartapp log:
fe0d6774-06c3-4fad-b1e5-3b0cf68d4624 7:29:54 AM: debug Received device event from bridge: [name:Garage Attic Temp, value:74.2, type:temperature]
3f30d2f6-fc80-458a-970c-00fb66c466c7 7:29:54 AM: debug Parsing 'index:06, mac:002170ADDB5E,

Battery not sent (ever?)

I'm not receiving battery levels (multi-sensor) even though they appear fine in graph.api.smartthings.com. I have a sneaking suspicion it is because it only triggers when the level changes but I would love a way to enable it to be sent at a more common interval.

bridge does not pass data

Please see the details below. I believe I have everything set up correctly and have validated:

  • smartthings sends events to bridge
  • bridge is connected to broker (mosquitto)
  • home assistant is connected to broker
    But: (i) no events are found in the bridge log nor (ii) are any events passed from bridge to broker.

Is there any way I can debug the bridge itself? I guess I could put a network sniffer on but is there a debugging mode for the bridge where I could monitor the events more detailed than inspecting the events.log file? I should comment that I am assuming that the smartthings is not going outside the network to deliver the events.

Please see more detailed evidence below...

  1. smartthings-mqtt-bridge configuration

mqtt:
host: mqtt://192.168.1.100:1883
preface: smartthings
port: 8080

  1. Smartthings configuration

Name Type Value
ip string 192.168.1.100
mac string aa:bb:cc:dd:ee:ff
port string 8080

  1. smartthings-mqtt-bridge connects to mosquitto:

1482027047: New client connected from 192.168.1.100 as mqttjs_6c170d31 (c1, k10).
1482027047: Sending CONNACK to mqttjs_6c170d31 (0, 0)
...
1482027057: Received PINGREQ from mqttjs_6c170d31
1482027057: Sending PINGRESP to mqttjs_6c170d31

  1. hass connects to mosquitto:

1482026247: New connection from 192.168.1.100 on port 1883.
1482026247: New client connected from 192.168.1.100 as hass (c1, k60).
1482026247: Sending CONNACK to hass (0, 0)
1482026247: Received SUBSCRIBE from hass
1482026247: smartthings/Water Leak Sensor/battery (QoS 0)
1482026247: hass 0 smartthings/Water Leak Sensor/battery
1482026247: Sending SUBACK to hass
1482026247: Received SUBSCRIBE from hass
1482026247: smartthings/Water Leak Sensor/temperature (QoS 0)
1482026247: hass 0 smartthings/Water Leak Sensor/temperature
1482026247: Sending SUBACK to hass
1482026247: Received SUBSCRIBE from hass
1482026247: smartthings/Water Leak Sensor/water (QoS 0)
1482026247: hass 0 smartthings/Water Leak Sensor/water
1482026247: Sending SUBACK to hass
1482026247: Received SUBSCRIBE from hass
1482026247: hellomqtt/topic (QoS 0)
1482026247: hass 0 hellomqtt/topic
1482026247: Sending SUBACK to hass
...
1482026307: Received PINGREQ from hass
1482026307: Sending PINGRESP to hass

  1. hass understands mqtt requests:

mosquitto_pub -d -t "smartthings/Water Leak Sensor/temperature" -m '{"temperature":"32"}'

Client mosqpub/10493-extra sending CONNECT
Client mosqpub/10493-extra received CONNACK
Client mosqpub/10493-extra sending PUBLISH (d0, q0, r0, m1, 'smartthings/Water Leak Sensor/temperature', ... (20 bytes))
Client mosqpub/10493-extra sending DISCONNECT

and in the HASS log:

16-12-17 20:03:19 INFO (MainThread) [homeassistant.core] Bus:Handling <Event mqtt_message_received[L]: qos=0, payload={"temperature":"32"}, topic=smartthings/Water Leak Sensor/temperature>

  1. events are being sent (see live log on smartthings)

597a1453-dfc5-477c-94a3-24122d86e349 8:10:54 PM: debug Forwarding device event to bridge: {"path":"/push","body":{"name":"Water Leak Sensor","value":"70","type":"temperature"}}

But:

  • no events from smartthings in events.log
  • no outputs from smartthings-mqtt-bridge

Support CloudMQTT

How hard would it be to allow for a remote mqtt broker like CloudMQTT?

Can't get this working

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: https://github.com/stjohnjohnson/smartthings-mqtt-bridge

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?

Bridge stopped working

I have my smartthings mqtt bridge working for months, but the other day it just stopped working. When I trigger an event in HA I can see a mqtt message broadcast, but I don't see anything happen in Smartthings. I took a look at my bridge log and see this error.

smartthings-mqtt-bridge-0 SyntaxError: Unexpected identifier
smartthings-mqtt-bridge-0 at exports.runInThisContext (vm.js:53:16)
smartthings-mqtt-bridge-0 at Module._compile (module.js:414:25)
smartthings-mqtt-bridge-0 at Object.Module._extensions..js (module.js:442:10)
smartthings-mqtt-bridge-0 at Module.load (module.js:356:32)
smartthings-mqtt-bridge-0 at Function.Module._load (module.js:311:12)
smartthings-mqtt-bridge-0 at Function._load (/usr/lib/node_modules/pm2/node_modules/pmx/lib/transaction.js:62:21)
smartthings-mqtt-bridge-0 at Module.require (module.js:366:17)
smartthings-mqtt-bridge-0 at require (module.js:385:17)
smartthings-mqtt-bridge-0 at Object. (/usr/lib/node_modules/smartthings-mqtt-bridge/node_modules/send/index.js:21:12)
smartthings-mqtt-bridge-0 at Module._compile (module.js:435:26)

This just repeats over and over again whether I am trying to turn something on/off or not. I also do not see port 8080 listed as listening using netstat.

MQTT Garage Door Issues

I am able to create a Garage Door component and successfully open the door and keep track of its open/closed state. However, I am not able to shut the door from Home Assistant. Here's the yaml in question. Any advice would be greatly appreciated.

garage_door:
  - platform: mqtt
    name: 'Garage Door'
    state_topic: 'smartthings/Garage Door/door'
    command_topic: 'smartthings/Garage Door/door'  
    optimistic: false
    qos: 0
    retain: true
    state_open: 'STATE_OPEN'
    state_closed: 'STATE_CLOSED'
    service_open: 'SERVICE_OPEN'
    service_close: 'SERVICE_CLOSE'

Presence Not Updating

events.log
2016-04-18T16:57:42.226Z - info: Incoming message from MQTT: smartthings/Mike_Phone/presence = not present 2016-04-18T16:57:50.308Z - info: Incoming message from MQTT: smartthings/Mike_Phone/presence = present

Smartthings Log
f78cb95f-c930-44b1-83d7-541b176fada4 11:57:50 AM: debug Received device event from bridge: [name:Mike_Phone, value:present, type:presence] f78cb95f-c930-44b1-83d7-541b176fada4 11:57:42 AM: debug Received device event from bridge: [name:Mike_Phone, value:not present, type:presence]

Sending level instead of switch "on" does not turn on the lights

I'm using the latest smartthings-mqtt bridge and my lights won't turn on - they will turn off, but not on.

I commented the part of the code that intercepts "on" and change it to level. And it now works.

Latest Homeassistant + latest smartthings-mqtt + GE Smartbulbs.

Auto-generate HA Config

Do you have any plans to automatically generate a config file (or set of includes) based on the information about the devices and their capabilities for the smart apps?

I rebuilt the functionality of your bridge in Node Red to learn it (and run the bridge on a Pi), and figured I would create a flow to automatically update the HA config file and optionally restart HA when new devices are found. Here's my ugly mustache template to give an idea of what I've hacked together so far:

{{#payload.capabilities.Switch}}
{{^payload.capabilities.SwitchLevel}}
switch {{payload.id}}-switch:
{{/payload.capabilities.SwitchLevel}}
{{#payload.capabilities.SwitchLevel}}
light {{payload.id}}-light:
{{/payload.capabilities.SwitchLevel}}
  platform: mqtt
  name: {{parts.key}}
  state_topic: "{{preface}}/{{parts.key}}/switch/{{state_suffix}}"
  command_topic: "{{preface}}/{{parts.key}}/switch/{{command_suffix}}"
  payload_on: "on"
  payload_off: "off"
{{#payload.capabilities.SwitchLevel}}
  brightness_state_topic: "{{preface}}/{{parts.key}}/level/{{state_suffix}}"
  brightness_command_topic: "{{preface}}/{{parts.key}}/level/{{command_suffix}}"
  brightness_scale: 99
{{/payload.capabilities.SwitchLevel}}
  optimistic: false
  qos: 0
  retain: true
{{/payload.capabilities.Switch}}

{{#payload.capabilities.MotionSensor}}
binary_sensor {{payload.id}}-motion:
  platform: mqtt
  name: {{parts.key}}
  state_topic: "{{preface}}/{{parts.key}}/motion/{{state_suffix}}"
  payload_on: "active"
  payload_off: "inactive"
  sensor_class: motion
  qos: 0
{{/payload.capabilities.MotionSensor}} 

Aeon Minimote Button Pushed

I just started messing with this to figure out how to get which button was pressed/held.

I added evt.description to the json being sent to the bridge. Line 546 of the smartapp. From there I'm a bit lost.

I have 2 mini remotes and they both give the same text in the description so I was thinking it could just be parsed out to send the MQTT as smartthings/Remove1/button1, smartthings/Remove1/button2...

Button1 - {"path":"/push","body":{"name":"M","value":"pushed","type":"button","description":"zw device: 02, command: 2001, payload: 01"}}
Button2 - {"path":"/push","body":{"name":"M","value":"pushed","type":"button","description":"zw device: 02, command: 2001, payload: 29"}}
Button3 - {"path":"/push","body":{"name":"M","value":"pushed","type":"button","description":"zw device: 02, command: 2001, payload: 51"}}
Button4 - {"path":"/push","body":{"name":"M","value":"pushed","type":"button","description":"zw device: 02, command: 2001, payload: 79"}}

I think it'd just need the payload parsed out and appended to button In case they come up with different numbers for different versions of the remote.

Color change via MQTT publish fails

I've found that when publishing to the hue or color topics of devices that support such things (in my case a Zipato RGBW lightbulb and the Fibaro RGBW controller) messages related to color/hue are seen as far as the MQ but never have any effect on the devices.

When changing a bulb via the smartthings app:

smartthings-mqtt-bridge-0 info: Incoming message from MQTT: smartthings/Studio.Ambient/hue = 44.37908
smartthings-mqtt-bridge-0 info: Incoming message from MQTT: smartthings/Studio.Notification/saturation = 100
smartthings-mqtt-bridge-0 info: Incoming message from MQTT: smartthings/Studio.Notification/color = #FF9700
smartthings-mqtt-bridge-0 info: Incoming message from SmartThings: smartthings/Studio.Ambient/level = 97

So one would think (assuming the MQ is working, mine is) that the following would accomplish the same (after, of course, changing the hue/color via the ST app):

mosquitto_pub -h localhost -t "smartthings/Studio.Ambient/hue" -m "44.37908"
mosquitto_pub -h localhost -t "smartthings/Studio.Ambient/saturation" -m "100"
mosquitto_pub -h localhost -t "smartthings/Studio.Ambient/color" -m "#FF9700"
mosquitto_pub -h localhost -t "smartthings/Studio.Ambient/level" -m "97"

But despite being seen on the MQ and in the logs of the mqtt-bridge they seem to have no effect.

smartthings-mqtt-bridge-0 info: Incoming message from MQTT: smartthings/Studio.Ambient/hue = 44.37908
smartthings-mqtt-bridge-0 info: Incoming message from MQTT: smartthings/Studio.Notification/saturation = 100
smartthings-mqtt-bridge-0 info: Incoming message from MQTT: smartthings/Studio.Ambient/color = #FF9700
smartthings-mqtt-bridge-0 info: Incoming message from MQTT: smartthings/Studio.Ambient/level = 99

Bridge restart causes dimmers to turn on

Looks like when we restart, we resubscribe to all events. We get the following events back for a dimmer lamp:

  • switch: off
  • level: 50

We then forward both of these to SmartThings. SmartThings ignores the switch off (as the lamp is already off) but sees the level 50 as a "turn on and go to 50%"

Connection to MQTT:MQTT 2

Hi,

Since my other post was closed, I figured I would explain where I am now. The read.me is not clear and the code example in the config.yml is not working for me.

After trying to use the instructions that was linked to, that I saw before, it still doesn't work. All I changed was the host to localhost, IP address, and neither worked and the HA wouldn't even start up. I put the code in my main configuration.yaml file.

mqtt:
# Specify your MQTT Broker's hostname or IP address here
host: 192.168.1.206
# 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_SUFFIX
# command_suffix: cmd
# Other optional settings from https://www.npmjs.com/package/mqtt#mqttclientstreambuilder-options
# username: AzureDiamond
# password: hunter2

Port number to listen on

port: 8080

So after researching, I found Bruh's MQTT setting that seem to work except it still wants to connect to MQTT:MQTT instead of my localhost. I start it by using PM2 start smartthings-mqtt-bridge. Check the status and it's there. If I run smartthings-mqtt-bridge I get:
info: Starting SmartThings MQTT Bridge - v1.3.4
info: Loading configuration
info: Loading previous state
info: Perfoming configuration migration
info: Saving current state
info: Connecting to MQTT at mqtt://mqtt
Connecting to MQTT at mqtt://mqtt

Here is my configuration.yaml MQTT section.
mqtt:
broker: 192.168.1.206
port: 1883
client_id: home-assistant-1
username: pi
password: xxxxxxxx
birth_message:
topic: 'homeassistant/status'
payload: 'online'
qos: 1
retain: true
will_message:
topic: 'homeassistant/status'
payload: 'offline'
qos: 1
retain: true

HA seems to like this and I can toggle the switch back and forth and can see the messages being received by subbing to the it using
mosquitto_sub -d -u pi -P xxxxxxxxx -t smartthings/#, it just doesn't know about connecting to the localhost.

The link you sent, is it suppose to exist as a separate yaml file? Am I not supposed to use the MQTT section in my main configuration.yaml?

bridge never sends SUBSCRIBE to broker

Home Assistant properly subscribes and publishes when changes are made but I am not getting the message from the bridge.

1474179285: New connection from 192.168.1.188 on port 1883.
1474179285: New client connected from 192.168.1.188 as home-assistant (c1, k60).
1474179285: Sending CONNACK to home-assistant (0, 0)
1474179285: Received SUBSCRIBE from home-assistant
1474179285: smartthings/Eave Lights/switch (QoS 0)
1474179285: home-assistant 0 smartthings/Eave Lights/switch
1474179285: Sending SUBACK to home-assistant
1474179285: Received SUBSCRIBE from home-assistant
1474179285: smartthings/Front door/lock (QoS 0)
1474179285: home-assistant 0 smartthings/Front door/lock
1474179285: Sending SUBACK to home-assistant
1474179286: Received PINGREQ from mqttjs_d23c7feb
1474179286: Sending PINGRESP to mqttjs_d23c7feb
1474179296: Received PINGREQ from mqttjs_d23c7feb
1474179296: Sending PINGRESP to mqttjs_d23c7feb
1474179306: Received PINGREQ from mqttjs_d23c7feb
1474179306: Sending PINGRESP to mqttjs_d23c7feb
1474179311: Received PUBLISH from home-assistant (d0, q0, r1, m0, 'smartthings/Eave Lights/switch', ... (2 bytes))
1474179311: Sending PUBLISH to home-assistant (d0, q0, r0, m0, 'smartthings/Eave Lights/switch', ... (2 bytes))
1474179316: Received PINGREQ from mqttjs_d23c7feb
1474179316: Sending PINGRESP to mqttjs_d23c7feb
1474179326: Received PINGREQ from mqttjs_d23c7feb
1474179326: Sending PINGRESP to mqttjs_d23c7feb
1474179336: Received PINGREQ from mqttjs_d23c7feb
1474179336: Sending PINGRESP to mqttjs_d23c7feb

Skipping duplicate message appearing in output

So i have a fresh install of rasbian on a rpi3 and newly configured mosquito (base config nothing added), smartthings-mqtt-bridge running on node v4.4.7 installed using nvm.

I successfully able to see sensors from ST publish sensor messages to the mqtt broker and i'm able to subscribe to them and see updates. Now I also see the message "Skipping duplicate message .... " appear a lot. Is this normal? What is the reason for this?

an example of this is when I send a on or off payload to one of my switches I see the same message 4 times with one skipped:

info: Incoming message from MQTT: smartthings/Outdoor Back Light/switch = on
info: Incoming message from SmartThings: smartthings/Outdoor Back Light/switch = on
info: Incoming message from MQTT: smartthings/Outdoor Back Light/switch = on
info: Skipping duplicate message from: smartthings/Outdoor Back Light/switch = on
info: Incoming message from MQTT: smartthings/Outdoor Back Light/switch = off
info: Incoming message from SmartThings: smartthings/Outdoor Back Light/switch = off
info: Incoming message from MQTT: smartthings/Outdoor Back Light/switch = off
info: Skipping duplicate message from: smartthings/Outdoor Back Light/switch = off

Everything works though so it seems. I just see a lot of messages.

Just want to know if this is as expected.

Support button devices with multiple buttons

Button controllers like the Aeon Labs Minimote and the Enerwave ZWN-SC7 have several buttons on them which can send individual events. Testing the MQTT bridge with the ZWN-SC7 device using the community-created device handler returns a "button" event with a message of "button 1" or whatever which is what I would expect, like this:

topic: smartthings/Enerwave ZWN-SC7/button
message: button 1

The Aeon Labs Minimote with the SmartThings-provided device handler returns a "button" event without indicating the specific button. It does correctly report "pressed" or "held", but with no indication of which button has been activated, like this:

topic: smartthings/Aeon Minimote/button
message: pushed

The SmartApp logs the following event in the IDE when I press button 1:

Forwarding device event to bridge: {"path":"/push","body":{"name":"Aeon Minimote","value":"pushed","type":"button"}}

The Device Handler logs the following event in the IDE from the same event:

Sending '{"path":"/push","body":{"name":"Aeon Minimote","value":"pushed","type":"button"}}' to device

From my own SmartApp testing, the Aeon Labs Minimote event looks like this:

evt.name: button
evt.displayName: Aeon Minimote
evt.value: pushed
evt.jsonData.buttonNumber: 1

The working test case with the Enerwave ZWN-SC7 looks like this:

evt.name: button
evt.displayName: Enerwave ZWN-SC7
evt.value: button 1
evt.jsonData.buttonNumber: 1

Running MQTT Bridge on Raspberry Pi 3.

Ok so I thought I could figure this out on my own, with the help of a few of the write ups I've found, but I can't seem to make it work.

One of the write ups talking about it : [https://home-assistant.io/blog/2016/02/09/smarter-smart-things-with-mqtt-and-home-assistant/]

I am new to the RPi world, most of my projects have been Arduino so far. Anyway, I have successfully got Moqsuitto running on my Pi, and am trying to get the Bridge running, but am kind of lost. I have docker installed, and tried running the following.

Edit, the code didn't format this the same, but I did enter is as separate lines

$ docker run \ -d \ --name="mqtt-bridge" \ -v /opt/mqtt-bridge:/config \ -p 8080:8080 \ stjohnjohnson/smartthings-mqtt-bridge

The first time it went through and dowloaded a bunch of stuff but eventually gave an error

Error response from daemon: Cannot restart container mqtt-bridge: rpc error: code = 2 desc = "oci runtime error: exec format error"

I don't even know where to start troubleshooting. Am I way off on how to do this?

My end goal is to use MQTT with ESP8266's to talk to Smartthings. I think I will be able to figure that part out once I can get this working.

Thanks for the help, I'm trying to learn!

MQTT Bridge issues

Hello,

I am not sure that my issues is with the MQTT, it seems to be running, but how do I tell it is communicating to my hub?

Command topic for ST socket switch

I'm trying to work with the ST branded socket switch. I can read the state with smartthings/Device Name/switch, which returns on/off.

But I'm not sure of the topic to set the switch on/off from hass.

I'm using v1.2.0, and the config looks like...

switch:
  platform: mqtt
  name: "Device Name"
  state_topic: "smartthings/Device Name/switch"
  command_topic: "smartthings/Device Name/switch"
  payload_on: "on"
  payload_off: "off"
  retain: true

Error from SmartThings Hub

This has been happening the last couple of days. Seems to happen when I send an MQTT message to the bridge.

error: Error from SmartThings Hub: Error: connect ETIMEDOUT 192.168.1.2:39500
error: {
"code": "ETIMEDOUT",
"errno": "ETIMEDOUT",
"syscall": "connect",
"address": "192.168.1.2",
"port": 39500
}
error: undefined

I haven't changed anything in the last few days. Any suggestions? Thanks

New Device in ST not showing in MQTT

I added a new contact sensor to ST's and it's working correctly there. I updated the MQTT-Bridge smartapp, to include the new sensor, but I'm not seeing any updates to the device when I subscribe to the smartthings topic, or just #.

In the SmartThings IDE, under livelogging, I see this under my SmartApp:

720f430e-2c55-4f16-81b5-e0b299b51b1d 11:29:32 PM: debug Forwarding device event to bridge: {"path":"/push","body":{"name":"Sliding Door","value":"closed","type":"contact"}} 720f430e-2c55-4f16-81b5-e0b299b51b1d 11:29:32 PM: debug Forwarding device event to bridge: {"path":"/push","body":{"name":"Sliding Door","value":"open","type":"contact"}} 720f430e-2c55-4f16-81b5-e0b299b51b1d 11:29:19 PM: debug Forwarding device event to bridge: {"path":"/push","body":{"name":"Sliding Door","value":"open","type":"contact"}} 720f430e-2c55-4f16-81b5-e0b299b51b1d 11:29:18 PM: debug Forwarding device event to bridge: {"path":"/push","body":{"name":"Sliding Door","value":"closed","type":"contact"}} 720f430e-2c55-4f16-81b5-e0b299b51b1d 11:29:18 PM: debug Forwarding device event to bridge: {"path":"/push","body":{"name":"Sliding Door","value":"open","type":"contact"}}

any idea as to why these events wouldn't be showing in MQTT when subscribed?

Not seeing commands from SmartThings.

I have HA setup and my devices are listed. I have 2 OSRM bulbs I can control using Smartthings and also Google Home + IFTTT.

I got the smarthings-mqtt-bridge running on my HA pi3.
Sub to it using:
mosquitto_sub -d -u pi -P xxxxx -t smartthings/#
and have the code in my configuration.yaml:

switch:
  platform: mqtt
  name: "RonsLivingRoomLamp"
  state_topic: "smartthings/RonsLivingRoomLamp/switch"
  command_topic: "smartthings/RonsLivingRoomLamp/switch"
  brightness_state_topic: "smartthings/RonsLivingRoomLamp/level"
  brightness_command_topic: "smartthings/RonsLivingRoomLamp/level"
  payload_on: "on"
  payload_off: "off"
  retain: true

When I click the switch on the HA, I see the messages in MQTT

Client mosqsub/13417-roosterpi received PUBLISH (d0, q0, r0, m0, 'smartthings/RonsLivingRoomLamp/switch', ... (2 bytes))
on
Client mosqsub/13417-roosterpi received PUBLISH (d0, q0, r0, m0, 'smartthings/RonsLivingRoomLamp/switch', ... (3 bytes))
off

In Smarthings IDE, I setup the MQTT Bridge Device Handler and setup the device per the instructions. for the IP address in the preferences, do I put the local internal address to the HA server running the MQTT bridge, or an external(duckdns)? I have tried both ways and when I turn the bulb on using the HA Switch, I see the command in the MQTT, but it doesn't do anything to the lamp. I also don't see anything the reverse way whten I trigger the bulb using the smartthings app on my phone. I don't see it.

It's like Smartthings and the MQTT are not connected somehow.

I have ports 1883 and 8080 open on my router.

Am I missing something?

Can support be added for Netamo connect sensor data C02, noise level and pressure?

I have added a Netamo weather station to smartthings and am only getting temperature data from it on my MQTT server over via this bridge. I really want to get the carbonDioxide (stuffiness), the noise and room pressure. Can anyone help? I would be happy do some work to help add these things if you point me in the right directed e.g. the Current States for smartthings shows data like this...

temperature: 23.3 C
humidity: 33
carbonDioxide: 695
noise: 53
pressure: 1013.4

PS Many thanks for sharing this bridge on github!

Contact Sensor with Temperature

In Smartthings, I have a contact sensor that also reports temperature.

I've tried to pull the temperature into HA as my first test of this bridge but I'm not having any luck.

this is what I have in the configuration.yaml, and I get a little temperature indicator in HA, but it is not getting a value, it just reports unknown.

any help would be appreciated.

In SmartThings, it gives the following states:

Current States:
temperature: 57
battery: 77
contact: closed

sensor:
platform: mqtt
state_topic: "smartthings/Back Door/temperature"
name: "Back Door Temperature"
qos: 0
unit_of_measurement: "∞F"
value_template: '{{ value.x }}'

self signed certs are not supported

I've been able to get mqtt-bridge to work with CloudMQTT but would like to setup my own private broker behind my firewall, with SSL enabled. Is this possible with mqtt-bridge? This is the error I get. Thanks.

ctalbot@homeassistant:~$ smartthings-mqtt-bridge
info: Starting SmartThings MQTT Bridge - v1.2.0
info: Loading configuration
info: Loading previous state
info: Perfoming configuration migration
info: Saving current state
info: Connecting to MQTT at mqtts://192.168.1.52:8883

events.js:72
throw er; // Unhandled 'error' event
^
Error: SELF_SIGNED_CERT_IN_CHAIN
at SecurePair. (tls.js:1370:32)
at SecurePair.EventEmitter.emit (events.js:92:17)
at SecurePair.maybeInitFinished (tls.js:982:10)
at CleartextStream.read as _read
at CleartextStream.Readable.read (_stream_readable.js:320:10)
at EncryptedStream.write as _write
at doWrite (_stream_writable.js:223:10)
at writeOrBuffer (_stream_writable.js:213:5)
at EncryptedStream.Writable.write (_stream_writable.js:180:11)
at write (_stream_readable.js:583:24)

contents of /opt/mqtt-bridge/config.yaml:


mqtt:
# Specify your MQTT Broker's hostname or IP address here
host: mqtts://192.168.1.52:8883
# Preface for the topics $PREFACE/$DEVICE_NAME/$PROPERTY
preface: smartthings
username: smartmqtt
password: XXXXXXXX

port: 8080

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.