-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcustom_store.py
42 lines (35 loc) · 1.09 KB
/
custom_store.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
################################################################
# @Bevywise.com IOT Initiative. All rights reserved
# www.bevywise.com Email - [email protected]
#
# custom_store.py
#
# The custom data store hook for storing MQTT Payload in MongoDB.
# The Custom data hook can be enabled in the broker.conf
# inside conf/ folder.
#
# The parameter data will be in dict format and the keys are 'sender','topic', 'message', 'unixtime', 'timestamp'
#
################################################################
import os, sys
from pathlib import Path
current_path = Path(os.getcwd())
plugin_path = os.path.join(current_path.parent.absolute(),'extensions','mongo')
sys.path.append(plugin_path)
conf_path = os.path.join(plugin_path, './plugin.conf')
from mongo import Mongo
global Mon_inst
Mon_inst = Mongo(conf_path)
def handle_Received_Payload(data):
#
# Write your code here. Use your connection object to
#
#
# finish your code here.
#
# Send data to your data store
try:
result = Mon_inst.data_consumer(data)
# if result is none then write failed
except Exception as e:
print(e)