Beispiel #1
0
def get_temperature(ser):
    # Get the temperature value
    send_packet_param(ser, 0x06, 0x000C, [0x00])
    buff = read_packet(ser)
    temperature = get_value_data_packet(buff)
    # Convert to celsius and return
    return ((temperature - 100) / 10.0)
Beispiel #2
0
def get_humidity(ser):
    # Get the humidity value
    send_packet_param(ser, 0x06, 0x000D, [0x00])
    buff = read_packet(ser)
    humidity = get_value_data_packet(buff)
    # Convert to a percentage and return it
    return humidity * 10.0
Beispiel #3
0
def get_mains_on_off(ser):
    # Get the on/off indication
    send_packet_param(ser, 0x06, 0x001F, [0x00])  # mains on/off
    buff = read_packet(ser)
    mainstatus = get_value_data_packet(buff)
    return mainstatus
Beispiel #4
0
def get_air_quality(ser):
    # Get the air quality value
    send_packet_param(ser, 0x06, 0x000F, [0x00])
    buff = read_packet(ser)
    air_quality = get_value_data_packet(buff)
    return air_quality
Beispiel #5
0
                    baudrate=9600,
                    bytesize=8,
                    parity='N',
                    stopbits=1,
                    timeout=None,
                    xonxoff=0,
                    rtscts=0)

try:
    if not ser.isOpen():
        ser.open()


    print "=================================================="
    print "Turning light off..."

    send_packet_param(ser, 0x06, 0x0006, [0x04])


    print "=================================================="



    ser.flush()
    ser.close()
except:
    ser.flush()
    ser.close()
    raise