<commit_before>#!/usr/bin/python

import paho.mqtt.client as paho
import signal
import sys
import time

from threading import Thread
from upm import pyupm_grove as grove
from upm import pyupm_biss0001 as grovemotion

luxes = grove.GroveLight(0)
motion = grovemotion.BISS0001(6)
opening = grove.GroveButton(4)
switch = grove.GroveRelay(2)

mqttserver = "iot.eclipse.org"
mqttport = 1883

# Sensor Luxes

def functionSensorLuxesData():
    value = luxes.value()
    print "Publish Sensor Luxes Data: We got %s!" % value
    return value

def functionSensorLuxes():
    mqttclient = paho.Client()
    mqttclient.connect(mqttserver, mqttport, 60)
    while True:
        data = functionSensorLuxesData()
        topic = "cochinitapibil/comino/sensor/luxes"
        mqttclient.publish(topic, data)
        time.sleep(1)

# Binary Sensor Motion
        
def functionBinarySensorMotionData():
    value = motion.value()
    if value:
        value = 1
    else:
        value = 0
    print "Publish Binary Sensor Motion Data: We got %s!" % value
    return value

def functionBinarySensorMotion():
    mqttclient = paho.Client()
    mqttclient.connect(mqttserver, mqttport, 60)
    while True:
        data = functionBinarySensorMotionData()
        topic = "cochinitapibil/comino/binarysensor/motion"
        mqttclient.publish(topic, data)
        time.sleep(1)

# Binary Sensor Opening

def functionBinarySensorOpeningData():
    value = opening.value()
    print "Publish Binary Sensor Opening Data: We got %s!" % value
    return value

def functionBinarySensorOpening():
    mqttclient = paho.Client()
    mqttclient.connect(mqttserver, mqttport, 60)
    while True:
        data = functionBinarySensorOpeningData()
        topic = "cochinitapibil/comino/binarysensor/opening"
        mqttclient.publish(topic, data)
        time.sleep(1)

# Switch

def functionSwitchData(mosq, obj, msg):
    print "Subscribe Actuator Data: We received %s!" % msg.payload
    if msg.payload == "1":
        switch.on()
    elif msg.payload == "0":
        switch.off()

def functionSwitch():
    mqttclient = paho.Client()
    mqttclient.on_message = functionSwitchData
    mqttclient.connect(mqttserver, mqttport, 60)
    mqttclient.subscribe("cochinitapibil/comino/switch", 0)
    while mqttclient.loop() == 0:
        pass
        
def functionSignalHandler(signal, frame):
    sys.exit(0)

if __name__ == '__main__':<commit_msg>Update comino.py<commit_after>#!/usr/bin/python

import paho.mqtt.client as paho
import signal
import sys
import time

from threading import Thread
from upm import pyupm_grove as grove
from upm import pyupm_biss0001 as grovemotion

luxes = grove.GroveLight(0)
motion = grovemotion.BISS0001(6)
opening = grove.GroveButton(4)
switch = grove.GroveRelay(2)

mqttserver = "iot.eclipse.org"
mqttport = 1883

# Sensor Luxes

def functionSensorLuxesData():
    value = luxes.value()
    print "Publish Sensor Luxes Data: We got %s!" % value
    return value

def functionSensorLuxes():
    mqttclient = paho.Client()
    mqttclient.connect(mqttserver, mqttport, 60)
    while True:
        data = functionSensorLuxesData()
        topic = "cochinitapibil/comino/sensor/luxes"
        mqttclient.publish(topic, data)
        time.sleep(1)

# Binary Sensor Motion
        
def functionBinarySensorMotionData():
    value = motion.value()
    if value:
        value = 1
    else:
        value = 0
    print "Publish Binary Sensor Motion Data: We got %s!" % value
    return value

def functionBinarySensorMotion():
    mqttclient = paho.Client()
    mqttclient.connect(mqttserver, mqttport, 60)
    while True:
        data = functionBinarySensorMotionData()
        topic = "cochinitapibil/comino/binarysensor/motion"
        mqttclient.publish(topic, data)
        time.sleep(1)

# Binary Sensor Opening

def functionBinarySensorOpeningData():
    value = opening.value()
    print "Publish Binary Sensor Opening Data: We got %s!" % value
    return value

def functionBinarySensorOpening():
    mqttclient = paho.Client()
    mqttclient.connect(mqttserver, mqttport, 60)
    while True:
        data = functionBinarySensorOpeningData()
        topic = "cochinitapibil/comino/binarysensor/opening"
        mqttclient.publish(topic, data)
        time.sleep(1)

# Switch

def functionSwitchData(mosq, obj, msg):
    print "Subscribe Actuator Data: We received %s!" % msg.payload
    if msg.payload == "ON":
        switch.on()
    elif msg.payload == "OFF":
        switch.off()

def functionSwitch():
    mqttclient = paho.Client()
    mqttclient.on_message = functionSwitchData
    mqttclient.connect(mqttserver, mqttport, 60)
    mqttclient.subscribe("cochinitapibil/comino/switch", 0)
    while mqttclient.loop() == 0:
        pass
        
def functionSignalHandler(signal, frame):
    sys.exit(0)

if __name__ == '__main__':
{'fraction_non_alphanumeric': 0.09776767259198016, 'fraction_numerical': 0.01364200082678793, 'mean_word_length': 3.3166815343443354, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3611960', 'n_tokens_mistral': 1675, 'n_tokens_neox': 1576, 'n_words': 384}