Esempio n. 1
0
def readWiredSensors(bmp280, hdc1080):

    # read wired sensors

    if (config.BMP280_Present):
        try:
            state.BarometricTemperature = round(bmp280.get_temperature(), 2)
            state.BarometricPressure = round(
                old_div(bmp280.get_pressure(), 1000) * 100, 5)
            state.Altitude = round(bmp280.get_altitude(), 4)
            state.BarometricPressureSeaLevel = round(
                old_div(
                    bmp280.get_sealevel_pressure(
                        config.BMP280_Altitude_Meters), 1000) * 100, 5)
        except:
            if (config.SWDEBUG):
                print(traceback.format_exc())
                print(
                    ("readWiredSensors Unexpected error:", sys.exc_info()[0]))

    #print("Looking for buildJSONSemaphore Acquire")
    state.buildJSONSemaphore.acquire()
    #print("buildJSONSemaphore Acquired")
    state.StateJSON = buildJSON.getStateJSON()
    #if (config.SWDEBUG):
    #    print("currentJSON = ", state.StateJSON)
    state.buildJSONSemaphore.release()
Esempio n. 2
0
def processF016TH(sLine):
    if (config.SWDEBUG):
        sys.stdout.write('Processing F016TH data' + '\n')
        sys.stdout.write('This is the raw data: ' + sLine + '\n')

    var = json.loads(sLine)

    state.mainID = var["device"] + var["channel"]
    state.lastIndoorReading = nowStr()

    if (state.previousIndoorReading == "Never"):
        pclogging.systemlog(config.INFO, "Indoor Weather Sensor Found")
        print("Indoor Weather Sensors Found")
        state.previousIndoorReading = state.lastIndoorReading

    state.IndoorTemperature = round(
        ((var["temperature_F"] - 32.0) / (9.0 / 5.0)), 2)
    state.IndoorHumidity = var["humidity"]
    state.lastIndoorReading = var["time"]
    state.insideID = var["channel"]

    indoorTH.addITReading(var["device"], var["channel"],
                          state.IndoorTemperature, var["humidity"],
                          var["battery"], var["time"])

    #print("looking for buildJSONSemaphore acquire")
    state.buildJSONSemaphore.acquire()
    #print("buildJSONSemaphore acquired")
    state.StateJSON = buildJSON.getStateJSON()
    #if (config.SWDEBUG):
    #    print("currentJSON = ", state.StateJSON)
    state.buildJSONSemaphore.release()
Esempio n. 3
0
def processF016TH(sLine):
    if (config.SWDEBUG):
        sys.stdout.write('Processing F016TH data'+'\n')
        sys.stdout.write('This is the raw data: ' + sLine + '\n')
    
    var = json.loads(sLine)
    
    IT = round(((var["temperature_F"] - 32.0)/(9.0/5.0)),2)

    # check for bad read (not caught by checksum for some reason)
    # may be related to low battery
    if ((IT > 100.00) or (IT < -35)):
        # bad temperatures / Humidity
        #skip read
        return

    state.mainID = var["device"] + var["channel"]
    state.lastIndoorReading = nowStr()

    if (config.MQTT_Enable == True):
         mqtt_publish_single(sLine, f"F016TH/{var['channel']}")



    if (state.previousIndoorReading == "Never"):
        pclogging.systemlog(config.INFO,"Indoor Weather Sensor Found")
        print("Indoor Weather Sensors Found")
        state.previousIndoorReading = state.lastIndoorReading

    state.IndoorTemperature = IT 
    state.IndoorHumidity = var["humidity"]
    state.lastIndoorReading = var["time"]
    state.insideID = var["channel"]



    indoorTH.addITReading(var["device"], var["channel"], state.IndoorTemperature, var["humidity"], var["battery"],  var["time"])

    #print("looking for buildJSONSemaphore acquire")
    state.buildJSONSemaphore.acquire()
    #print("buildJSONSemaphore acquired")
    state.StateJSON = buildJSON.getStateJSON()
    #if (config.SWDEBUG):
    #   print("currentJSON = ", state.StateJSON)
    #   pass
    state.buildJSONSemaphore.release()
Esempio n. 4
0
def processF020(sLine):

    if (config.SWDEBUG):
        sys.stdout.write("processing FT020T Data\n")
        sys.stdout.write('This is the raw data: ' + sLine + '\n')

    var = json.loads(sLine)

    # outside temperature and Humidity

    state.mainID = var["id"]
    state.lastMainReading = nowStr()

    if (state.previousMainReading == "Never"):
        pclogging.systemlog(config.INFO, "Main Weather Sensors Found")
        print("Main Weather Sensors Found")
        pclogging.systemlog(config.INFO, "Blynk Updates Started")
        state.previousMainReading = state.lastMainReading

    wTemp = var["temperature"]

    ucHumi = var["humidity"]

    wTemp = (wTemp - 400) / 10.0
    # deal with error condtions
    if (wTemp > 140.0):
        # error condition from sensor
        if (config.SWDEBUG):
            sys.stdout.write("error--->>> Temperature reading from FT020T\n")
            sys.stdout.write('This is the raw temperature: ' + str(wTemp) +
                             '\n')
        # put in previous temperature
        wtemp = state.OudoorTemperature
    #print("wTemp=%s %s", (str(wTemp),nowStr() ));
    if (ucHumi > 100.0):
        # bad humidity
        # put in previous humidity
        ucHumi = state.OutdoorHumidity

    state.OutdoorTemperature = round(((wTemp - 32.0) / (9.0 / 5.0)), 2)
    state.OutdoorHumidity = ucHumi

    state.WindSpeed = round(var["avewindspeed"] / 10.0, 1)
    state.WindGust = round(var["gustwindspeed"] / 10.0, 1)
    state.WindDirection = var["winddirection"]

    state.TotalRain = round(var["cumulativerain"] / 10.0, 1)
    state.Rain60Minutes = 0.0

    wLight = var["light"]
    if (wLight >= 0x1fffa):
        wLight = wLight | 0x7fff0000

    wUVI = var["uv"]
    if (wUVI >= 0xfa):
        wUVI = wUVI | 0x7f00

    state.SunlightVisible = wLight
    state.SunlightUVIndex = round(wUVI / 10.0, 1)

    if (var['batterylow'] == 0):
        state.BatteryOK = "OK"
    else:
        state.BatteryOK = "LOW"

    #print("looking for buildJSONSemaphore acquire")
    state.buildJSONSemaphore.acquire()
    #print("buildJSONSemaphore acquired")
    state.StateJSON = buildJSON.getStateJSON()
    #if (config.SWDEBUG):
    #    print("currentJSON = ", state.StateJSON)
    state.buildJSONSemaphore.release()
Esempio n. 5
0
def processFT020T(sLine, lastFT020TTimeStamp, UpdateWR2 ):

    if (config.SWDEBUG):
        sys.stdout.write("processing FT020T Data\n")
        sys.stdout.write('This is the raw data: ' + sLine + '\n')

    var = json.loads(sLine)
    if (lastFT020TTimeStamp == var["time"]):
        # duplicate
        if (config.SWDEBUG):
            sys.stdout.write("duplicate found\n")

        return ""

    lastFT020TTimeStamp = var["time"]

    if (config.MQTT_Enable == True):
        mqtt_publish_single(sLine, "FT020T")

    # now check for adding record


    # outside temperature and Humidity

    state.mainID = var["id"] 
    state.lastMainReading = nowStr()


    if (state.previousMainReading == "Never"):
        pclogging.systemlog(config.INFO,"Main Weather Sensors Found")
        print("Main Weather Sensors Found")
        pclogging.systemlog(config.INFO,"Blynk Updates Started")
        state.previousMainReading = state.lastMainReading



    wTemp = var["temperature"]

    ucHumi = var["humidity"]



    wTemp = (wTemp - 400)/10.0
    # deal with error condtions
    if (wTemp > 140.0):
        # error condition from sensor
        if (config.SWDEBUG):
            sys.stdout.write("error--->>> Temperature reading from FT020T\n")
            sys.stdout.write('This is the raw temperature: ' + str(wTemp) + '\n')
        # put in previous temperature 
        wtemp = state.OutdoorTemperature 
    #print("wTemp=%s %s", (str(wTemp),nowStr() ));
    if (ucHumi > 100.0):
        # bad humidity
        # put in previous humidity
        ucHumi  = state.OutdoorHumidity
     
    state.OutdoorTemperature = round(((wTemp - 32.0)/(9.0/5.0)),2)
    state.OutdoorHumidity =  ucHumi 

    
        
    state.WindSpeed =  round(var["avewindspeed"]/10.0, 1)
    state.WindGust  = round(var["gustwindspeed"]/10.0, 1)
    state.WindDirection  = var["winddirection"]
    


    state.TotalRain  = round(var["cumulativerain"]/10.0,1)

    wLight = var["light"]
    #if (wLight >= 0x1fffa):
    #    wLight = wLight | 0x7fff0000

    wUVI =var["uv"]
    if (wUVI >= 0xfa):
        wUVI = wUVI | 0x7f00

    state.SunlightVisible =  wLight 
    state.SunlightUVIndex  = round(wUVI/10.0, 1 )

    if (var['batterylow'] == 0):
        state.BatteryOK = "OK"
    else:
        state.BatteryOK = "LOW"

    state.SerialNumber = var['id']
    state.RSSI = var['rssi']
    state.SNR = var['snr']
    state.NOISE = var['noise']




    #print("looking for buildJSONSemaphore acquire")
    state.buildJSONSemaphore.acquire()
    #print("buildJSONSemaphore acquired")
    if (UpdateWR2):
        # now add to MWR2Array
        WeatherRack2Array.addWR2Reading(var)
    state.StateJSON = buildJSON.getStateJSON()
    #if (config.SWDEBUG):
    #    print("currentJSON = ", state.StateJSON)
    state.buildJSONSemaphore.release()
    #print("buildJSONSemaphore released")
    return lastFT020TTimeStamp