Closed mschwartz closed 7 years ago
Yup! We do have that feature. It's turned off by default for backwards compatibility, but you just need to set the command_suffix and state_suffix: https://github.com/stjohnjohnson/smartthings-mqtt-bridge#configuration
Awesome. I'm all over that!
I changed the name to RoboDomo.
So the url is now: https://github.com/robodomo
Thanks for your work!
Sorry, the feature isn't as I want :(
smartthings/Kitchen Lights/switch/status off
Isn't want I want
I want:
smartthings/Kitchen Light/status/switch off
parsing is trivial:
const THING = 'Kitchen Lights'
const TOPIC = `smartthings/${THING}/status/'
MQTT.subscribe(TOPIC + '#')
MQTT.onMessage((topic, message) => {
const thing = topic.substr(TOPIC.length) // =-> switch, level, whatever
...
})
componentDidMount() {
MQTT.subscribe(this.status_topic + 'switch', this.onStateChange)
MQTT.subscribe(this.status_topic + 'level', this.onStateChange)
}
onStateChange(topic, newState) {
const newValue = {},
key = topic.substr(this.status_topic.length)
newValue[key] = newState
this.setState(newValue)
}
I figured out a trick. I'm hoping all this helps someone else who stumbles onto this ticket.
no state_suffix, but use a command_prefix
That JS code above that I posted works fine without the /state/ present in the topic.
To send, just MQTT.publish(this.set_topic + 'switch/set', 'on')
Not too ugly :)
Glad you found a workaround!
It seems to me the MQTT API is a bit confounding and might be done better.
Right now, you get something like
And you send the same thing to turn that switch on.
The issue is you will then receive the message you sent because you're subscribed/istening.
My suggestion is to have incoming messages something like:
For incoming messages
And you send:
To control the device.
This way, you won't get the "set" message that you sent.
This suggestion allows you to listen on
And you only get true status messages