add AwsPublish
This commit is contained in:
@ -24,22 +24,22 @@ class RePublisher(threading.Thread):
|
||||
def run(self):
|
||||
client = mqtt.Client()
|
||||
client.connect(self.broker, 1883, 60)
|
||||
client.loop_start()
|
||||
client.loop_start()
|
||||
|
||||
while True:
|
||||
try:
|
||||
msg = self.queue.get()
|
||||
dataBlock = msg['data']
|
||||
if 'decodedTelegram' in dataBlock:
|
||||
del dataBlock['decodedTelegram']
|
||||
if 'telegram' in dataBlock:
|
||||
del dataBlock['telegram']
|
||||
if 'decodedTelegram' in dataBlock:
|
||||
del dataBlock['decodedTelegram']
|
||||
if 'telegram' in dataBlock:
|
||||
del dataBlock['telegram']
|
||||
metadataBlock = msg['metadata']
|
||||
if 'Slave' in metadataBlock:
|
||||
if metadataBlock['Slave'] == 'Thermometer' and metadataBlock['device'] == 'ModbusHub':
|
||||
metadataBlock['name'] = 'FridgeThermometer'
|
||||
topic = "IoT/ParsedData/%s" % metadataBlock['name']
|
||||
if 'Slave' in metadataBlock:
|
||||
if metadataBlock['Slave'] == 'Thermometer' and metadataBlock['device'] == 'ModbusHub':
|
||||
metadataBlock['name'] = 'FridgeThermometer'
|
||||
topic = "IoT/ParsedData/%s" % metadataBlock['name']
|
||||
client.publish(topic, json.dumps(msg, cls=MyEncoder))
|
||||
Logger.log("RePublisher has sent data")
|
||||
Logger.log("RePublisher has sent data")
|
||||
except Exception, e:
|
||||
Logger.log("Unexcepted exception %s in RePublisher: %s" % (e.__class__.__name__, str(e)))
|
||||
|
Reference in New Issue
Block a user