Add clustering
This commit is contained in:
parent
1da22413c1
commit
a046bf6640
1 changed files with 25 additions and 0 deletions
25
cluster.py
Normal file
25
cluster.py
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
import paho.mqtt.subscribe as mqtt
|
||||||
|
import json
|
||||||
|
|
||||||
|
BROKER = ('homeproxy', 1883)
|
||||||
|
TOPIC_RAW = 'scalefix/raw/weight'
|
||||||
|
TOPIC_USERS = 'scalefix/users'
|
||||||
|
|
||||||
|
|
||||||
|
_users={}
|
||||||
|
|
||||||
|
def handle_weight(client, userdata, message):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def handle_user(client, userdata, message):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
TOPIC_LAST = TOPIC_USERS+'/last'
|
||||||
|
def dispatch(client, userdata, message):
|
||||||
|
if message.topic == TOPIC_RAW:
|
||||||
|
handle_weight(client, userdata, message)
|
||||||
|
elif message.topic.startswith(TOPIC_LAST):
|
||||||
|
handle_user(client, userdata, message)
|
||||||
|
|
||||||
|
mq.callback(dispatch, [TOPIC_RAW, TOPIC_LAST+'/+'], hostname=BROKER[0], port=BROKER[1])
|
Loading…
Reference in a new issue