initial
This commit is contained in:
commit
827ee3ec77
17
.project
Normal file
17
.project
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>FridgeAlarm2</name>
|
||||||
|
<comment></comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.python.pydev.PyDevBuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>org.python.pydev.pythonNature</nature>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
8
.pydevproject
Normal file
8
.pydevproject
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<?eclipse-pydev version="1.0"?><pydev_project>
|
||||||
|
<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
|
||||||
|
<path>/${PROJECT_DIR_NAME}</path>
|
||||||
|
</pydev_pathproperty>
|
||||||
|
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.7</pydev_property>
|
||||||
|
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
|
||||||
|
</pydev_project>
|
30
FridgeAlarm.py
Normal file
30
FridgeAlarm.py
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
import pymongo
|
||||||
|
import datetime
|
||||||
|
|
||||||
|
client = pymongo.MongoClient('172.16.2.15')
|
||||||
|
db = client.iot
|
||||||
|
iot = db.iot
|
||||||
|
|
||||||
|
now1 = datetime.datetime.now()
|
||||||
|
now = now1.replace(now1.year, now1.month, now1.day, now1.hour, now1.minute, now1.second, 0)
|
||||||
|
midnight = now.replace(now.year, now.month, now.day, 0,0,0,0)
|
||||||
|
seconds = (now - midnight).seconds
|
||||||
|
intervalBegin = seconds - 15 * 60
|
||||||
|
|
||||||
|
if intervalBegin > 0:
|
||||||
|
pipeline = [
|
||||||
|
{'$match': {'metadata.device': 'ModbusHub',
|
||||||
|
'metadata.day': midnight,
|
||||||
|
'metadata.seconds': {'$gt': intervalBegin, '$lt': seconds}
|
||||||
|
}},
|
||||||
|
{'$sort': {'seconds': 1}},
|
||||||
|
{'$project': {'_id': 0, 'ts': '$metadata.timestamp', 't': '$data.t2'}}
|
||||||
|
]
|
||||||
|
cursor = iot.aggregate(pipeline, useCursor=True)
|
||||||
|
for item in cursor:
|
||||||
|
print(item)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# {'$group': {'_id': 0,
|
||||||
|
# 'avgTemp': {'$avg': '$data.t2'}}}
|
Loading…
x
Reference in New Issue
Block a user