Ejemplo n.º 1
0
    def get(self, sensorId):
        mySensorState = sensorState()
    
        mySensorState.setSensorID(sensorId)
        # mySensorState.setSensorIP(sensorIp)
        mySensorState.setHeartbeat()

        returnString = {'state':  str(200)}

        return returnString,  200
Ejemplo n.º 2
0
def main():
    mySensorState = sensorState()
    mySensorState.setSensorID('33841b00')
    mySensorState.setSensorType('switch-user')
    mySensorState.setSensorValue(1)
    mySensorState.setSatus()

    returnString = {'state':  str(200)}

    print(json .dumps(returnString))
Ejemplo n.º 3
0
def levelStateWrite(sensorId, sensorType, sensorValue):
    mySensorState = sensorState()
    mySensorState.setSensorID(sensorId)
    mySensorState.setSensorType(sensorType)
    mySensorState.setSensorValue(sensorValue)
    mySensorState.setSatus()

    returnString = {'state': str(200)}

    return json.dumps(returnString)
Ejemplo n.º 4
0
    def get(self,  sensorId,  sensorType, sensorValue):
        mySensorState = sensorState()
    
        mySensorState.setSensorID(sensorId)
        mySensorState.setSensorType(sensorType)
        mySensorState.setSensorValue(sensorValue)
        mySensorState.setSatus()

        returnString = {'state':  str(200)}

        return returnString, 200
Ejemplo n.º 5
0
    def get(self,  sensorId,  sensorType, sensorMedium,  provider):
        mySensorState = sensorState()
    
        mySensorState.setSensorID(sensorId)
        mySensorState.setSensorType(sensorType)
        mySensorState.setSensorMedium(sensorMedium)
        mySensorState.setSensorProvider(provider)
        mySensorState.registration()

        returnString = {'state':  str(200)}

        return returnString,  200
Ejemplo n.º 6
0
def main():
    isWet = 0
    mySensorState = sensorState()

    sqlSnow = "select \"weatherTodayTypes\".weather as lweather from public.\"weatherTodayTypes\" WHERE lower(\"weatherTodayTypes\".weather) = 'snow';"
    sqlRain = "select \"weatherTodayTypes\".weather as lweather from public.\"weatherTodayTypes\" WHERE lower(\"weatherTodayTypes\".weather) = 'rain';"

    if getRowCount(sqlSnow) > 0 or getRowCount(sqlRain) > 0:
        isWet = 1

    mySensorState.setSensorID('10000001')
    mySensorState.setSensorType('weather-wet')
    mySensorState.setSensorValue(isWet)
    mySensorState.setSatus()
Ejemplo n.º 7
0
def main():
    mySensorState = sensorState()
    mySettings = settingsClass()

    sql = "SELECT * FROM public.\"sunrisesetLatestDetail\";"
    cur.execute(sql)
    rows = cur.fetchall()

    if len(rows) > 0:
        row = rows[0]
        sunrise = row[2]
        sunset = row[3]

        irrigationPeriod = mySettings.settings["pumpduration"]
        isTimeToIrrigate = 0

        nowStartTime = datetime.now()
        nowStartInt = (nowStartTime.hour * 60) + nowStartTime.minute

        nowSunriseStart = (sunrise.hour * 60) + sunrise.minute
        nowSunriseEnd = (sunrise.hour * 60) + sunrise.minute + irrigationPeriod

        nowSunsetStart = (sunset.hour * 60) + sunset.minute
        nowSunsetEnd = (sunset.hour * 60) + sunset.minute + irrigationPeriod

        if nowSunriseStart <= nowStartInt <= nowSunriseEnd:
            isTimeToIrrigate = 1
        else:
            isTimeToIrrigate = 0

        mySensorState.setSensorID('10000002')
        mySensorState.setSensorType('sun-rise')
        mySensorState.setSensorValue(isTimeToIrrigate)
        mySensorState.setSatus()

        if nowSunsetStart <= nowStartInt <= nowSunsetEnd:
            isTimeToIrrigate = 1
        else:
            isTimeToIrrigate = 0

        mySensorState.setSensorID('10000003')
        mySensorState.setSensorType('sun-set')
        mySensorState.setSensorValue(isTimeToIrrigate)
        mySensorState.setSatus()