Created
November 30, 2016 07:44
-
-
Save stigtsp/fd7160850df4f26a13fd693f6d009af4 to your computer and use it in GitHub Desktop.
Is anyone at Dim Sum labs? This Bitbar scripts will tell you if the lights are on, and what rgb value the light has.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/python | |
# -*- coding: utf-8 -*- | |
import paho.mqtt.client as mqtt | |
import json | |
import struct | |
def on_connect(client, userdata, flags, rc): | |
client.subscribe("dsl/enviro") | |
def on_message(client, userdata, msg): | |
s = json.loads(str(msg.payload)) | |
col = struct.pack('BBB',*s['rgb']).encode('hex') | |
lights="💤" | |
if s['helios']>0: lights ="💡" | |
print "DSL"+lights+" | color: #" + col | |
exit() | |
client = mqtt.Client() | |
client.on_connect = on_connect | |
client.on_message = on_message | |
client.connect("iot.eclipse.org", 1883, 60) | |
client.loop_forever() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment