Open abdallas opened 7 years ago
This project doesn't really account for sensor data originating in the MQTT domain and flowing to (virtual) devices on the Smartthings side.
You can fake it by sending data using "command" topics, modifying the smartapp code to fully support the attributes you want to update, THEN create/modify Smartthings device handlers to accept those commands to update their state.
I'm not sure the "right" way to handle this, but one way might be support a third MQTT suffix, or perhaps simply subscribing to the "status" suffix and passing that data back to the associated device in ST if it didn't originate there.
Without digging into the Java side, my personal solution was to add a new method to the smart app:
def actionSetState(device, attribute, value) { device.set_state(attribute, value) }
...and use this actionSetState command for any sensor capabilities you want to bring in from MQTT.
Then in the device handler:
def set_state(String attrib, String attrib_value) { sendEvent(name: attrib, value: attrib_value, descriptionText: "$device.displayName $attrib is $attrib_value") }
This should work for most basic sensors as long as the topic looks like:
"\<stmqttbridge preface>/\<smartthings device name>/\<smartthings attribute>/\<stmqttbridge command_suffix>" with a payload that makes sense for that attribute in smartthings: "open", "closed", "on", "off", etc.
The only annoyance is that my MQTT broker then sees both the /command and then the /status (coming back from Smartthings) whenever there is an update.
Thanks, Will try it out.
@abdallas would this work? https://github.com/stjohnjohnson/smartthings-mqtt-bridge/pull/84
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,