Skip to content

Instantly share code, notes, and snippets.

@dmarlow
Created July 22, 2014 17:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmarlow/fe4bdc40cfb36c178048 to your computer and use it in GitHub Desktop.
Save dmarlow/fe4bdc40cfb36c178048 to your computer and use it in GitHub Desktop.
SMS2MQTT Python - Responding
def on_message(mosq, obj, msg):
m = msg.payload.decode("utf-8")
print(msg.topic + " " + str(msg.qos) + " " + m)
obj = json.loads(m)
client.publish("weather-app/reply", (json.dumps({"cmdId": obj["cmdId"], "body": obj["body"]})), 2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment