fixes
This commit is contained in:
parent
e14097c329
commit
22385cdef3
@ -92,7 +92,7 @@ class LEDStrip:
|
|||||||
return
|
return
|
||||||
|
|
||||||
# Check if light levels are low enough to turn on light
|
# Check if light levels are low enough to turn on light
|
||||||
collectionLight = EchoDB.EchoDB.database['LightLog']
|
collectionLight = EchoDB.EchoDB.database['LightLogs']
|
||||||
data = collectionLight.find().sort([('timestamp', -1)]).limit(1)
|
data = collectionLight.find().sort([('timestamp', -1)]).limit(1)
|
||||||
if data[0]['light_amount'] > 20:
|
if data[0]['light_amount'] > 20:
|
||||||
return;
|
return;
|
||||||
|
@ -21,7 +21,7 @@ class Sensor:
|
|||||||
return {'status': 'success', 'message': actionData['message']}, 200
|
return {'status': 'success', 'message': actionData['message']}, 200
|
||||||
|
|
||||||
if action == "get_climate_data":
|
if action == "get_climate_data":
|
||||||
collection = EchoDB.EchoDB.database['ClimateLogs']
|
collection = EchoDB.EchoDB.database['ClimateLogss']
|
||||||
data = collection.find().sort([('timestamp', -1)]).limit(1)
|
data = collection.find().sort([('timestamp', -1)]).limit(1)
|
||||||
data_json = json.loads(json_util.dumps(data))
|
data_json = json.loads(json_util.dumps(data))
|
||||||
return {'status': 'success', 'message': actionData['message'], 'data': data_json}, 200
|
return {'status': 'success', 'message': actionData['message'], 'data': data_json}, 200
|
||||||
@ -35,7 +35,7 @@ class Sensor:
|
|||||||
return {'status': 'success', 'message': actionData['message']}, 200
|
return {'status': 'success', 'message': actionData['message']}, 200
|
||||||
|
|
||||||
if action == "get_light_data":
|
if action == "get_light_data":
|
||||||
collection = EchoDB.EchoDB.database['LightLog']
|
collection = EchoDB.EchoDB.database['LightLogs']
|
||||||
data = collection.find().sort([('timestamp', -1)]).limit(1)
|
data = collection.find().sort([('timestamp', -1)]).limit(1)
|
||||||
data_json = json.loads(json_util.dumps(data))
|
data_json = json.loads(json_util.dumps(data))
|
||||||
return {'status': 'success', 'message': actionData['message'], 'data': data_json}, 200
|
return {'status': 'success', 'message': actionData['message'], 'data': data_json}, 200
|
||||||
@ -57,7 +57,7 @@ class Sensor:
|
|||||||
#
|
#
|
||||||
|
|
||||||
if action == 'climate_data':
|
if action == 'climate_data':
|
||||||
collection = EchoDB.EchoDB.database['ClimateLogs']
|
collection = EchoDB.EchoDB.database['ClimateLogss']
|
||||||
climate_data = data[2].split(',')
|
climate_data = data[2].split(',')
|
||||||
|
|
||||||
logData = {
|
logData = {
|
||||||
@ -74,7 +74,7 @@ class Sensor:
|
|||||||
#
|
#
|
||||||
|
|
||||||
if action == 'light_data':
|
if action == 'light_data':
|
||||||
collection = EchoDB.EchoDB.database['LightLog']
|
collection = EchoDB.EchoDB.database['LightLogs']
|
||||||
lightAmount = data[2]
|
lightAmount = data[2]
|
||||||
|
|
||||||
logData = {
|
logData = {
|
||||||
|
@ -52,7 +52,7 @@ class Switch:
|
|||||||
return
|
return
|
||||||
|
|
||||||
# Check if light levels are low enough to turn on light
|
# Check if light levels are low enough to turn on light
|
||||||
collectionLight = EchoDB.EchoDB.database['LightLog']
|
collectionLight = EchoDB.EchoDB.database['LightLogs']
|
||||||
data = collectionLight.find().sort([('timestamp', -1)]).limit(1)
|
data = collectionLight.find().sort([('timestamp', -1)]).limit(1)
|
||||||
if data[0]['light_amount'] > 250:
|
if data[0]['light_amount'] > 250:
|
||||||
return;
|
return;
|
||||||
|
@ -17,6 +17,6 @@ class EchoDB:
|
|||||||
database = mongo_client['Echo']
|
database = mongo_client['Echo']
|
||||||
|
|
||||||
# Create Indexes
|
# Create Indexes
|
||||||
database['MovementLog'].create_index("timestamp", expireAfterSeconds=10)
|
database['MovementLogs'].create_index("timestamp", expireAfterSeconds=3600)
|
||||||
database['ClimateLog'].create_index("timestamp", expireAfterSeconds=10)
|
database['ClimateLogs'].create_index("timestamp", expireAfterSeconds=3600)
|
||||||
database['LightLog'].create_index("timestamp", expireAfterSeconds=10)
|
database['LightLogs'].create_index("timestamp", expireAfterSeconds=3600)
|
@ -26,7 +26,7 @@ class EchoScheduler:
|
|||||||
schedule.every(1).minute.do(EchoScheduler.checkAutomaticShutdown)
|
schedule.every(1).minute.do(EchoScheduler.checkAutomaticShutdown)
|
||||||
schedule.every(1).minute.do(EchoScheduler.checkAutomaticBlinds)
|
schedule.every(1).minute.do(EchoScheduler.checkAutomaticBlinds)
|
||||||
|
|
||||||
# collection_delete = EchoDB.EchoDB.database['ClimateLogs']
|
# collection_delete = EchoDB.EchoDB.database['ClimateLogss']
|
||||||
# collection_delete.remove({})
|
# collection_delete.remove({})
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user