From 72cd4bb0ea28977f72894b7ce52d71218add44a7 Mon Sep 17 00:00:00 2001 From: Roman Bazalevskiy Date: Wed, 3 Jan 2018 22:11:44 +0300 Subject: [PATCH 1/1] =?utf8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?utf8?q?=D0=B5=D0=BD=D0=B0=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D0=B0=20?= =?utf8?q?=D0=BF=D1=80=D0=B8=20=D0=BF=D1=83=D1=81=D1=82=D0=BE=D0=BC=20(?= =?utf8?q?=D0=BD=D0=BE=20=D0=BD=D0=B5=20null)=20=D0=B8=D0=BC=D0=B5=D0=BD?= =?utf8?q?=D0=B8=20=D1=82=D0=BE=D0=BF=D0=B8=D0=BA=D0=B0.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- weathermon-mqtt | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/weathermon-mqtt b/weathermon-mqtt index f288f51..c6b6a82 100755 --- a/weathermon-mqtt +++ b/weathermon-mqtt @@ -14,24 +14,27 @@ def on_message(mosq, obj, msg): payload=json.loads(msg.payload) timestamp=tparser.parse(payload['Time']) for sensor_type in payload: - if sensor_type != 'Time': + if sensor_type != 'Time' and sensor_type != 'TempUnit': sensor_data=payload[sensor_type] for param in sensor_data: try: value=sensor_data[param] - c = database.cursor() - c.execute('CALL meteo.submit_mqtt(%s,%s,%s,%s,NULL)', (topic,sensor_type,param,value)) - database.commit() - print topic,sensor_type,param,value + try: + c = database.cursor() + c.execute('CALL meteo.submit_mqtt(%s,%s,%s,%s,NULL)', (topic,sensor_type,param,value)) + database.commit() + print topic,sensor_type,param,value + except: + print "Failed to submit data" except: - print "Failed to submit data" + None def Topics(): c = database.cursor() c.execute( ''' - select topic from mqtt_topics + select topic from mqtt_topics where topic<>"" ''' ) -- 2.34.1