add seconds of today
This commit is contained in:
		| @@ -11,11 +11,15 @@ import datetime | ||||
|  | ||||
| def on_message(client, userdata, msg): | ||||
|     j = json.loads(msg.payload) | ||||
|     now = datetime.datetime.now() | ||||
|     midnight = now.replace(now.year, now.month, now.day, 0,0,0,0) | ||||
|     seconds = (now - midnight).seconds | ||||
|     j['metadata']['timestamp'] = datetime.datetime.now() | ||||
|     j['metadata']['seconds'] = seconds | ||||
|     print(j) | ||||
|     mongoClient = pymongo.MongoClient('localhost') | ||||
|     db = mongoClient.iot | ||||
|     r = db.iot.insert(j) | ||||
|     r = db.iot.insert_one(j) | ||||
|  | ||||
|  | ||||
| if __name__ == '__main__': | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Wolfgang Hottgenroth
					Wolfgang Hottgenroth