diff --git a/serial2mqtt.py b/serial2mqtt.py index 2a19e6e..3f17661 100755 --- a/serial2mqtt.py +++ b/serial2mqtt.py @@ -30,14 +30,15 @@ def parse_sensor_values(data): """ Input line: ,, Output structure: - data = { + { 'humidity': , 'temperature': , 'sound': } """ - humidity, temperature, sound = data.decode('utf-8').strip().split(',') - return {'humidity': humidity, 'temperature': temperature, 'sound': sound} + metrics = ['humidity', 'temperature', 'sound'] + values = data.decode('utf-8').strip().split(',') + return dict(zip(metrics, values)) def connect_mqtt(config):