Exemple #1
0
def send_data(data_raw):
    
    print("Unpacking raw data...")
    data = ustruct.unpack('lifff', data_raw)
    loc, sensor_type, temp, press, hum = data
    print("Location of measured reading: ", loc)
    print("Sensor type: ", sensor_dict[sensor_type])
    print("Temperature: %.2f C" % (temp))  ## Print temperature to console
    print("Pressure: %.2f hPa" % (press))  ## Print pressure to console
    print("Humidity: %.2f %%" % (hum))   ## Print humidity to console
    print("\n")
    
    print("Sending data up to MQTT server...")
    client = MQTTClient("7a9e85d9-c8ed-40fd-becb-20de9fec2fe3", "io.adafruit.com",user="******", password="******", port=1883)
    client.connect()
    print("Sending temperature...\n")
    client.publish(topic="yoplocheo/feeds/{}_{}_temperature".format(loc_dict[loc], sensor_dict[sensor_type]), msg=str(temp), retain = True)
    utime.sleep_ms(1000)
    print("Sending pressure...\n")
    client.publish(topic="yoplocheo/feeds/{}_{}_pressure".format(loc_dict[loc], sensor_dict[sensor_type]), msg=str(press), retain = True)
    utime.sleep_ms(1000)
    print("Sending hum...\n")
    client.publish(topic="yoplocheo/feeds/{}_{}_humidity".format(loc_dict[loc], sensor_dict[sensor_type]), msg=str(hum), retain = True)
    utime.sleep_ms(1000)
    print("Data sent.\n")

    gc.collect()
Exemple #2
0
class Pycom1:
    def __init__(self):
        self.x = '0'

    def sub_cb(self, topic, msg):
        self.x = str(msg)

    def wifi_enable(self):
        wlan = WLAN(mode=WLAN.STA)
        wlan.connect("thingQbator",
                     auth=(WLAN.WPA2, "C1sco12345"),
                     timeout=5000)

        while not wlan.isconnected():
            machine.idle()
        print("\nConnected to Wifi\n")

    def mqtt_enable(self):
        self.client = MQTTClient("pycom1", "173.39.91.118", port=1883)
        self.client.set_callback(self.sub_cb)
        self.client.connect()
        self.client.subscribe(topic="qbator/call_temp")

    def run(self):
        while True:
            self.client.check_msg()
            if self.x.strip("b'") == '1':
                print(self.x)
                self.client.publish(topic="qbator/temp",
                                    msg=str(int(t_sensor.temperature())))
                self.client.publish(topic="qbator/hum",
                                    msg=str(int(t_sensor.humidity())))
            else:
                continue
def send_to_thingspeak(datapoints):
    mean_data = DataPoint.mean(datapoints)

    thingspeak_data = mean_data.to_thingspeak()
    print('sending data\n{}'.format(thingspeak_data))

    success = False
    number_of_retries = 3

    while not success and number_of_retries > 0:
        try:
            client_id = binascii.hexlify(machine.unique_id())
            client = MQTTClient(client_id,
                                'mqtt.thingspeak.com',
                                user='******',
                                password=MQTT_API_KEY,
                                port=8883,
                                ssl=True)
            client.connect()
            client.publish(
                topic='channels/379710/publish/{}'.format(MQTT_WRITE_API_KEY),
                msg=thingspeak_data)
            client.disconnect()
            success = True
        except OSError as e:
            print('network error: {}'.format(e.errno))
            number_of_retries -= 1
            pass

    return success
Exemple #4
0
class PublishPeriodicly():
    """发布对象

    该类用于管理信息发布逻辑。可以通过在构造是设置interval参数,实现以一定的频率进行信息发布。

    该类的pubInfo方法是可以被连续调用. 通过内部的定时器可以实现在连续调用时以一定频率Pub。

    本质上是对数据流的降采样过程。
    """
    def __init__(self,interval=1000):
        """构造函数
        
        :param interval: 发布信息的周期, defaults to 1000
        :type interval: int, optional
        """
        self.__interval=interval
        self.__MQTTC = MQTTClient("openmv", server="ali.cnworkshop.xyz", port=20000)
        self.__MQTTC.connect()
        self.__InnerCounter=pyb.millis()
    def pubInfo(self,info):
        """发布信息

        该函数可以被重复调用。但是会按照预设的周期发布信息。在两次有效发布之间的调用会立即返回。
        
        :param info: 要发布到MQTT Broker 的信息
        :type info: str
        """
        if  pyb.millis()-self.__InnerCounter >self.__interval:
            print("pub%s"%info)
            self.__InnerCounter=pyb.millis()
            self.__MQTTC.publish("openmv/data",info)
Exemple #5
0
    def run(self):
        # Now we setup our MQTT client
        client = MQTTClient(self.io_id,
                            "io.adafruit.com",
                            user=self.io_user,
                            password=self.io_key,
                            port=self.port)
        client.set_callback(self.message_callback)
        client.connect()
        client.subscribe(topic="{0}/feeds/sensors".format(self.io_user))

        while True:
            if self.sensor_on:
                data = self.read_data()
                print(" >", data)
                client.publish(topic="{0}/feeds/temperature".format(
                    self.io_user),
                               msg=str(data[0]))
                client.publish(topic="{0}/feeds/humidity".format(self.io_user),
                               msg=str(data[1]))
                client.publish(topic="{0}/feeds/pressure".format(self.io_user),
                               msg=str(data[2]))
                utime.sleep(self.update_frequency)
            client.check_msg()
            utime.sleep(1)  # Check messages only once per second
class IotConnection:
    def __init__(self, client_id, server):
        self.client_id = client_id
        self.client = MQTTClient(client_id, server, port=1883, keepalive=60)
        self.client.set_callback(sub_cb)
        self.client.set_last_will('backend/1/1/status/heartbeat',
                                  'down',
                                  retain=False,
                                  qos=0)
        self.client.connect()
        self.client.publish(topic='backend/1/1/status/heartbeat',
                            msg='up',
                            qos=1)

    def send_temperature(self, topic, value, unique_id):
        data = {
            "temperature": {
                "value": str(value),
                "unique_id": str(unique_id)
            }
        }
        json_data = json.dumps(data)
        print(topic, json_data)
        self.client.publish(topic=topic, msg=json_data)

    def send_humidity(self, topic, value, unique_id):
        data = {"humidity": {"value": str(value), "unique_id": str(unique_id)}}
        json_data = json.dumps(data)
        print(topic, json_data)
        self.client.publish(topic=topic, msg=json_data)
Exemple #7
0
class MessageBuffer:



    def __init__(self, broker, topic):
        #def settimeout(duration):
        #    pass
        self._broker = broker
        self._topic = topic
        self._client = MQTTClient("pytrack", self._broker, port=1883)
        #self._client.settimeout = settimeout
        self._client.connect()
        self._chrono = Timer.Chrono()
        self._chrono.start()
        print("Connected to MQTT broker %s"%self._broker)
        #self._client.publish(self._topic, "Hello!")
        #_thread.start_new_thread(self._loop, [.1]) # ever loop with small delay
        #self._alarm = Timer.Alarm(self._handler, 0.01 , periodic=True)
        pass

    def send(self, message):
            print('out->', message)
            self._client.publish(self._topic, message)

    def get_timeout(self):
        return self._chrono.read()
Exemple #8
0
class MyMqtt:
    def __init__(self):
        secrets = ujson.load(open("secret.json", "r"))
        self.secrets = secrets
        self.user = self.secrets["MQTT_USER"]
        self.password = secrets["MQTT_PASSWORD"]
        self.group = self.secrets["MQTT_GROUP"]

        self.client = MQTTClient("device_id",
                                 "io.adafruit.com",
                                 user=self.user,
                                 password=self.password,
                                 port=1883)

        self.client.set_callback(sub_cb)
        self.client.connect()
        self.client.subscribe(
            topic="{}/feeds/{}.{}".format(self.user, self.group, "led"))

    def send_value(self, value, feed="button"):
        # print('Sending {} to Adafruit or pretending to'.format(value))
        self.client.publish(topic="{}/feeds/{}.{}".format(
            self.user, self.group, feed),
                            msg='{}'.format(value))
        return value
class MQTTDevice:
    def __init__(self,
                 topic_online,
                 true_message="true",
                 false_message="false"):
        self.true_message = true_message
        self.false_message = false_message
        self.client = MQTTClient(MQTT_CLIENT_ID_RANDOM,
                                 MQTT_BROKER_ADDRESS,
                                 port=MQTT_PORT,
                                 keepalive=KEEP_ALIVE_TIME_SEC)
        self.next_scheduled_ping_time = 0
        self._client_setup(topic_online)

    def _client_setup(self, topic_online):
        self.client.set_last_will(topic_online, self.false_message)
        self.client.connect()
        self.client.publish(topic_online, self.true_message)
        self.setup_subscriptions()

    # override this method in subclass
    # set callback and subscriptions
    def setup_subscriptions(self):
        pass

    def _ping(self):
        if (self.next_scheduled_ping_time < utime.time()):
            self.client.ping()
            self.next_scheduled_ping_time = utime.time() + PING_EVERY_SEC

    #run method has to be called every execution cycle
    def run(self):
        self._ping()
        self.client.check_msg()
Exemple #10
0
def MQTTClientInit():
    global mqttmsg
    # wifi configuration
    WIFI_SSID = 'LAPTOP-BHHF3UMN 4817'
    WIFI_PASS = '******'
    def sub_cb(topic, msg):
        print(msg)
    

    wlan = WLAN(mode=WLAN.STA)
    wlan.connect(WIFI_SSID, auth=(WLAN.WPA2, WIFI_PASS), timeout=5000)

    while not wlan.isconnected():  
        machine.idle()
    print("Connected to WiFi\n")

    client = MQTTClient("lights11", "io.adafruit.com",user="******", password="******", port=1883)

    client.set_callback(sub_cb)
    client.connect()
    client.subscribe(topic="Yunwei/feeds/lights")

    while True:
        print("Sending "+mqttmsg)
        client.publish(topic="Yunwei/feeds/lights", msg=mqttmsg)
        time.sleep(5)
        #print("Sending 222")
        #client.publish(topic="Yunwei/feeds/lights", msg=mqttmsg)
        client.check_msg()
        time.sleep(5)
Exemple #11
0
class Iot(object):
    client_id = ubinascii.hexlify(machine.unique_id())
    client = None

    def __init__(self, *args, **kwargs):
        super(Iot, self).__init__(*args, **kwargs)
        try:
            print('mqtt running')
            self.client = MQTTClient(self.client_id,
                                     "mqtt.eclipse.org",
                                     keepalive=0)
            self.client.connect()
            self.client.set_callback(self.on_message)
            self.client.subscribe(b"sooko/lampu")
            while True:
                self.client.wait_msg()
        except:
            print('mqtt stoped')
            Wifi().disconnect()
            machine.reset()

    def on_message(self, topic, msg):
        print(topic, msg)
        if msg == b"on":
            self.grenn_on()
            self.client.publish(b"loger", b"saya hidup")
        elif msg == b"off":
            self.grenn_off()
            self.client.publish(b"loger", b"saya mati")

    def grenn_on(self):
        Pin(2, Pin.OUT).value(0)

    def grenn_off(self):
        Pin(2, Pin.OUT).value(1)
def setupClient():
    global client
    client = MQTTClient("Pycom",
                        "io.adafruit.com",
                        user="******",
                        password="******",
                        port=1883)
    client.connect()
Exemple #13
0
def sub_mqtt_Connect():
    client = MQTTClient("lopy", "192.168.2.1", port=1883)
    client.set_callback(sub_mqtt)
    client.connect()
    client.subscribe(topic="distancia")
    print("Suscrito...")
    while True:
        client.check_msg()
Exemple #14
0
def connect_server():
    global client
    client = MQTTClient(client_id=UBIDOTS_DEVICE_LABEL,
                        server=UBIDOTS_BROKER_URL,
                        port=UBIDOTS_BROKER_PORT,
                        user=UBIDOTS_TOKEN,
                        password=UBIDOTS_PASSWORD)
    client.connect()
Exemple #15
0
def connect_and_subscribe():
    global client_id, mqtt_server, topic_sub

    client = MQTTClient(client_id, mqtt_server)
    client.set_callback(sub_cb)
    client.connect()
    client.subscribe(topic_sub)
    print('Connected to %s MQTT broker, subscribed to %s topic' %
          (mqtt_server, topic_sub))
    return client
def sendData(data):
    client = MQTTClient(TiCo.id,
                        TiCo.broker_url,
                        user=TiCo.user,
                        password=TiCo.password,
                        port=1883)
    client.set_callback(sub_cb)
    client.connect()
    #client.subscribe(topic=TiCo.topic)
    print(data)
    client.publish(topic=TiCo.topic, msg=str(data))
def Conexion_MQTT():
    client_id = ubinascii.hexlify(m.unique_id())
    mqtt_server = 'broker.hivemq.com'
    port_mqtt = 1883
    user_mqtt = '' 
    pswd_mqtt = '' 
    client = MQTTClient(client_id, mqtt_server,port_mqtt,user_mqtt,pswd_mqtt) 
    client.set_callback(form_sub)
    client.connect()
    client.subscribe(topic_publish.encode())
    return client
def main(server=SERVER):
    client = MQTTClient(CLIENT_ID, server)
    client.set_callback(sub_cb)
    client.connect()
    client.subscribe(b"messages")
    adc = ADC(0)  # create ADC object on ADC pin
    while True:
        tstadc = adc.read()
        client.publish(b'messages', tstadc)
        time.sleep_ms(200)

    c.disconnect()
Exemple #19
0
class Board:
    def __init__(self):
        self.id = ubinascii.hexlify(machine.unique_id()).decode("utf-8")
        print("machine id: {}".format(self.id))
        self.mqtt = MQTTClient(self.id, MQTT_HOST, MQTT_PORT, MQTT_USER,
                               MQTT_PASSWORD)
        self.led = Led()
        self.lightsensor = Lightsensor()

        self.dispatcher = {}
        self.dispatcher["{}/led/rgb".format(
            self.id)] = lambda rgb: self.led.set_rgb(rgb["red"], rgb["green"],
                                                     rgb["blue"])
        self.dispatcher["{}/led/ping".format(
            self.id)] = lambda msg: self.led.ping()

    def process_message(self, topic, msg):
        topic_str = topic.decode("utf-8")
        msg_str = msg.decode("utf-8")
        if topic_str in self.dispatcher:
            self.dispatcher[topic_str](ujson.loads(msg_str))

    def publish_lightlevel(self, alarm):
        self.mqtt.publish(topic="lightdata",
                          msg=ujson.dumps({
                              "lightlevel":
                              self.lightsensor.get_lightlevel(),
                              "board_id":
                              self.id
                          }))

    def run(self):
        self.mqtt.set_callback(self.process_message)
        self.mqtt.connect()

        self.mqtt.subscribe("{}/led/rgb".format(self.id))
        self.mqtt.subscribe("{}/led/ping".format(self.id))

        self.mqtt.publish(topic="board_discovery",
                          msg=ujson.dumps({"id": self.id}))

        alarms = []
        alarms.append(
            Timer.Alarm(handler=self.publish_lightlevel, s=5, periodic=True))

        try:
            while True:
                self.mqtt.wait_msg()
                machine.idle()
        finally:
            for alarm in alarms:
                alarm.cancel()
            self.mqtt.disconnect()
Exemple #20
0
def main():
    if (read_config() < 1):
        base.print_error('[config.json]: no targets found in config.json file')
        exit(-1)

    mqtt = MQTTClient(config, base)
    mqtt.connect()
    scanner = Scanner(config, base)

    while (True):
        scanner.scan(config['interface'], mqtt_client=mqtt)
        time.sleep(config['interval'])
Exemple #21
0
def data(msg, PASSWD):
    import setting
    import ujson
    from mqtt import MQTTClient
    global answer
    answer = 'OK'
    IOTHUB = setting.get('iothub')
    DEVICE = setting.get('iotdevicename')
    KEY = setting.get('iotdevicesecret')
    USER = IOTHUB + '/' + DEVICE + '/api-version=2016-11-14'
    print('--------------MQTT----------')
    print('DEVICE: ', DEVICE)
    print('IOTHUB: ', IOTHUB)
    print('USER: '******'PASSWD: ', PASSWD)
    c = MQTTClient(
        DEVICE, IOTHUB, 8883, USER, PASSWD, 0, True
    )  # client_id, server, port=0, user=None, password=None, keepalive=0, ssl=False, ssl_params={})
    c.set_callback(sub_cb)
    try:
        c.connect()
        print('--------------PUBLISH----------')
        print('DEVICE: ', 'devices/' + DEVICE + '/messages/events/')
        print('MSG: ', msg)
        c.publish('devices/' + DEVICE + '/messages/events/', msg, False,
                  1)  # topic, msg, retain=False, qos=0
        c.subscribe('$iothub/twin/res/#', 1)  # topic, qos=0
        c.publish('$iothub/twin/GET/?$rid=2', '', False, 1)
        c.wait_msg()
        dictr = {}
        dictr["RSSI"] = setting.get('RSSI')
        dictr["health"] = setting.get('health')
        dictr["hwid"] = setting.get('hwid')
        dictr["VBat"] = setting.get('VBat')
        dictr["FWversion"] = setting.get('FWversion')
        dictr["FWnumber"] = setting.get('FWnumber')
        try:
            dict = ujson.loads(answer)
            print('RX TWIN MSG: ', dict)
            dict_rep = dict["reported"]
            keyp = dict_rep["keypresses"] + 1
            dictr["keypresses"] = keyp
        except:
            dictr["keypresses"] = 1
        print('TX TWIN MSG: ', dictr)
        reported = ujson.dumps(dictr)
        c.publish('$iothub/twin/PATCH/properties/reported/?$rid=1', reported,
                  False, 1)
        c.disconnect()
    except ():
        answer = 'ERROR'
    return answer
class MessageBuffer:



    def __init__(self, broker, topic):
        #def settimeout(duration):
        #    pass
        self._queue = []
        self._broker = broker
        self._topic = topic
        self._client = MQTTClient("pytrack", self._broker, port=1883)
        self._busy = False
        #self._client.settimeout = settimeout
        self._client.connect()
        self._chrono = Timer.Chrono()
        self._chrono.start()
        print("Connected to MQTT broker %s"%self._broker)
        self._client.publish(self._topic, "Hello!")
        _thread.start_new_thread(self._loop, [.001]) # ever loop with small delay
        pass

    def push(self, message):
        self._queue.append(message)
        print('in <-', message)
        pass

    def pull(self):

        global inactivity_timer

        n = len(self._queue)
        if n > 0:
            self._busy = True
            #try:
            message = self._queue.pop(0)
            print('out->', message)
            self._client.publish(self._topic, message)
            #except MQTTException:
            #    print('MQTT Exception raised')
            self._chrono.reset()
            self._busy = False

    def _loop(self, delay):
        while True:
            if not self._busy:
                self.pull()
                time.sleep(delay)


    def get_timeout(self):
        return self._chrono.read()
Exemple #23
0
def mqtt_connect():
    """Start the mqtt connection and return the connection object
	"""

    try:
        if log:
            print("starting mqtt connection to: {}:{}".format(broker, port))
        client = MQTTClient(client_id, broker, user="", password="", port=port)
        client.connect()
        if log: print("mqtt connected!")
        return client
    except BaseException as err:
        if log: print("error connecting mqtt: {}".format(err.args))
        return
Exemple #24
0
class Broker():
    def __init__(self):
        self.ip, self.client_id, self.topic, self.msg = self.getJsonInfo()
        self.client = MQTTClient(self.client_id, self.ip)
        time.sleep(3)
        self.client.connect()

    def objectDetected(self):
        self.client.publish(self.topic, self.msg)

    def getJsonInfo(self):
        with open("settings.json") as file:
            data = ujson.loads(file.read())
        return (data["brokerIp"], data["clientId"], data["topic"], data["msg"])
Exemple #25
0
def main(server=SERVER):
    client = MQTTClient(CLIENT_ID, server, port=1883)
    client.set_callback(sub_cb)
    client.connect()
    client.subscribe('messages_esp')
    adc = ADC(0)
    while True:
        client.check_msg()
        adcValue = adc.read()
        messageAdc = {"adcValue": str(adcValue)}
        client.publish('message_esp', ujson.dumps(messageAdc))
        time.sleep(2)

    client.disconnect()
Exemple #26
0
def Conexion_MQTT():
    client_id = b"Covid_" + ubinascii.hexlify(unique_id())
    #client_id = b"covid"
    mqtt_server = '10.50.1.153'
    port_mqtt = 1883
    user_mqtt = None  #Si su servidor no necesita usuario escribe None sin comillas
    pswd_mqtt = None  #Si su servidor no necesita contraseña escribe None sin comillas
    client = MQTTClient(client_id, mqtt_server, port_mqtt, user_mqtt,
                        pswd_mqtt)
    client.set_callback(form_sub)
    client.connect()
    client.subscribe(b'SAL_DA')
    print('Conectado a %s' % mqtt_server)
    return client
Exemple #27
0
def mqtt_connect():
    global client
    try:
        tools.debug("Connecting MQTT", "v")
        client = MQTTClient("gtw001_" + str(int(utime.time())),
                            globalVars.mqtt_url,
                            user=globalVars.mqtt_user,
                            password=globalVars.mqtt_psw,
                            port=1883)
        client.set_callback(response_callback)
        client.connect()
        client.subscribe(topic=globalVars.mqtt_topic)
        return client
    except BaseException as e:
        checkError("Error connecting to MQTT", e)
Exemple #28
0
def Conexion_MQTT():
    #client_id = b"Covid" + ubinascii.hexlify(machine.unique_id())
    client_id = b"prueba"
    mqtt_server = '10.50.1.153'
    #mqtt_server = 'mantenimiento.elite.local'
    port_mqtt = 1883
    user_mqtt = None #Si su servidor no necesita usuario escribe None sin comillas
    pswd_mqtt = None #Si su servidor no necesita contraseña escribe None sin comillas
    client = MQTTClient(client_id, mqtt_server,port_mqtt,user_mqtt,pswd_mqtt)
    client.set_callback(form_sub)
    client.connect(True)
    client.subscribe(b'SAL_DA')
    print('Conectado a %s' % mqtt_server)
    client.set_last_will(b'SAL_DA',b'Desconexión Inesperada')
    return client
Exemple #29
0
def connect_mqtt():
    """Connect to MQTT server and subscribe to command topics"""

    client = MQTTClient(config.MQTT_CLIENT,
                        config.MQTT_SERVER,
                        user="",
                        password="",
                        port=config.MQTT_PORT)
    client.set_callback(subscribe_commands)
    client.connect()
    print("Connected MQTT server at {}:{}".format(config.MQTT_SERVER,
                                                  config.MQTT_PORT))
    client.subscribe(topic=config.TOPIC_COMMANDS)
    print("Listening on topic '{}'".format(config.TOPIC_COMMANDS))
    return client
Exemple #30
0
def publish_thingsboard(token, UNIQUE_ID, data, password=''):
    from mqtt import MQTTClient
    import gc
    import json
    import machine
    import utime
    client = MQTTClient(UNIQUE_ID,
                        "iot.ier.unam.mx",
                        port=1883,
                        user=token,
                        password=password)
    client.settimeout = settimeout
    client.connect()
    print(json.dumps(data))
    client.publish('v1/devices/me/telemetry', json.dumps(data))
    client.disconnect()
def main(server="test.mosquitto.org"):
    c = MQTTClient("umqtt_clientc", server)
    c.set_callback(sub_cb)
    c.connect()
    c.subscribe(b"mhermans/lights/#")
    while True:
        if True:
            # Blocking wait for message
            c.wait_msg()
        else:
            # Non-blocking wait for message
            c.check_msg()
            # Then need to sleep to avoid 100% CPU usage (in a real
            # app other useful actions would be performed instead)
            time.sleep(1)

    c.disconnect()
Exemple #32
0
# MQTT Example.
# This example shows how to use the MQTT library.
#
# 1) Copy the mqtt.py library to OpenMV storage.
# 2) Install the mosquitto client on PC and run the following command:
#    mosquitto_sub -h test.mosquitto.org -t "openmv/test" -v
#
import time, network
from mqtt import MQTTClient

SSID='mux' # Network SSID
KEY='j806fVnT7tObdCYE'  # Network key

# Init wlan module and connect to network
print("Trying to connect... (may take a while)...")

wlan = network.WINC()
wlan.connect(SSID, key=KEY, security=wlan.WPA_PSK)

# We should have a valid IP now via DHCP
print(wlan.ifconfig())

client = MQTTClient("openmv", "test.mosquitto.org", port=1883)
client.connect()

while (True):
    client.publish("openmv/test", "Hello World!")
    time.sleep(1000)
from mqtt import MQTTClient


#c = MQTTClient("huzzah", "broker.hivemq.com", port=1883)
c = MQTTClient("huzzah", "test.mosquitto.org", port=1883)

c.connect()
c.publish(b"mhermans/lights/1", b"0,0,0")
c.disconnect()