Skip to content

Instantly share code, notes, and snippets.

@achterberg
Created February 21, 2015 05:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save achterberg/cbd46bc3b9cdb391eed7 to your computer and use it in GitHub Desktop.
Save achterberg/cbd46bc3b9cdb391eed7 to your computer and use it in GitHub Desktop.
(Indigodomotics) Send messages from Indigo to Slack
import urllib2
theVar = indigo.variables[1234567890]
text = "%s set to %sK" % (theVar.name, theVar.value)
# theVar = indigo.devices[1234567890]
# text = "Device %s is now %s" % (theVar.name, theVar.onState)
# theVar = indigo.schedules[1234567890]
# text = "%s" % theVar.name
channel = "#indigo"
username = "indigo"
icon = ":indigo:"
url = 'https://hooks.slack.com/services/yourSlackTokenHere'
data = 'payload={"channel": "%s", "username": "%s", "text": "%s", "icon_emoji": "%s"}' % (channel, username, text, icon)
req = urllib2.Request(url, data)
f = urllib2.urlopen(req)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment