def get_temperature_and_humidity(sensor, name): data = [] humid, temp = sensor.readings() reading = {} reading['measurement'] = 'temperature' reading['tags'] = { 'sensorName': name, 'sensorLocation': 'Wellhouse', 'sensorType': 'SHTC3' } reading['fields'] = {'tempc': temp, 'tempf': round(conv.c_to_f(temp), 2)} data.append(reading) reading = {} reading['measurement'] = 'humidity' reading['tags'] = { 'sensorName': name, 'sensorLocation': 'Wellhouse', 'sensorType': 'SHTC3' } reading['fields'] = {'humidity': round(humid, 2)} data.append(reading) return data
def get_1w_temperature(device): reading = {} client = Ownet(device['host']) temp = client.read(device['device']) name = client.device_name(device['device']) reading['measurement'] = 'weathermon' reading['tags'] = {'sensorName': name, 'sensorLocation': 'Ourhouse'} reading['fields'] = {'tempc': temp, 'tempf': round(conv.c_to_f(temp), 2)} return reading
def get_temperature_and_humidity(sensor, name): reading = {} humid, temp = sensor.readings() reading['measurement'] = 'weathermon' reading['tags'] = {'sensorName': name, 'sensorLocation': 'Ourhouse'} reading['fields'] = { 'tempc': temp, 'tempf': round(conv.c_to_f(temp), 2), 'humidity': round(humid, 2) } return reading
def get_1w_temperature(device): reading = {} client = Ownet(device['host']) try: temp = client.read(device['device']) except: print("Error reading {}.".format(device['device'])) return reading if temp > 75.0: return reading name = client.device_name(device['device']) location = 'Greenhouse' if name == 'Wellhouse': location = name reading['measurement'] = 'temperature' reading['tags'] = { 'sensorName': name, 'sensorLocation': location, 'sensorType': device['type'] } reading['fields'] = {'tempc': temp, 'tempf': round(conv.c_to_f(temp), 2)} return reading
def get_readings(device): data = [] try: device.connect() sensor_data = device.read() device.disconnect() except: return False # Get the humidity reading from AirThings reading = {} reading['measurement'] = 'humidity' reading['tags'] = { 'sensorName': 'AirThings', 'sensorLocation': 'Basement', 'sensorType': 'WavePlus' } reading['fields'] = {'humidity': round(sensor_data.sensor_data[0], 2)} data.append(reading) # Get the temperature reading from AirThings reading = {} reading['measurement'] = 'temperature' reading['tags'] = { 'sensorName': 'AirThings', 'sensorLocation': 'Basement', 'sensorType': 'WavePlus' } reading['fields'] = { 'tempc': round(sensor_data.sensor_data[3], 2), 'tempf': round(conv.c_to_f(sensor_data.sensor_data[3]), 2) } data.append(reading) # Get the radon readings from AirThings reading = {} reading['measurement'] = 'radon' reading['tags'] = { 'sensorName': 'AirThings', 'sensorLocation': 'Basement', 'sensorType': 'WavePlus' } reading['fields'] = { 'short_term_radon': sensor_data.sensor_data[1], 'long_term_radon': sensor_data.sensor_data[2], 'short_term_radon_us': round(sensor_data.sensor_data[1] / 37.0, 1), 'long_term_radon_us': round(sensor_data.sensor_data[2] / 37.0, 1) } data.append(reading) # Get the CO2 readings from AirThings reading = {} reading['measurement'] = 'co2' reading['tags'] = { 'sensorName': 'AirThings', 'sensorLocation': 'Basement', 'sensorType': 'WavePlus' } reading['fields'] = {'carbon_dioxide': sensor_data.sensor_data[5]} data.append(reading) # Get the VOC readings from AirThings reading = {} reading['measurement'] = 'voc' reading['tags'] = { 'sensorName': 'AirThings', 'sensorLocation': 'Basement', 'sensorType': 'WavePlus' } reading['fields'] = {'voc': sensor_data.sensor_data[6]} data.append(reading) return data