@@ -0,0 +1,1774 @@
+#!/usr/bin/env python%0A# -*- coding: utf-8 -*-%0A%0A#%0A# Copyright 2014 Patrick Huber %3Cstackmagic@gmail.com%3E%0A#%0A# Licensed under the Apache License, Version 2.0 (the %22License%22);%0A# you may not use this file except in compliance with the License.%0A# You may obtain a copy of the License at%0A#%0A#    http://www.apache.org/licenses/LICENSE-2.0%0A#%0A# Unless required by applicable law or agreed to in writing, software%0A# distributed under the License is distributed on an %22AS IS%22 BASIS,%0A# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A# See the License for the specific language governing permissions and%0A# limitations under the License.%0A#%0A%0A#%0A# mosquitto QOS levels:%0A# - 0: The broker/client will deliver the message once, with no confirmation.%0A# - 1: The broker/client will deliver the message at least once, with confirmation required.%0A# - 2: The broker/client will deliver the message exactly once by using a four step handshake.%0A#%0A%0Aimport paho.mqtt.client as mqtt%0Aimport time%0Aimport yoctodump%0A%0Ahost = 'localhost'%0Aport = 1883%0A%0AmqttClient = mqtt.Client()%0AmqttClient.connect(host, port)%0A%0Adata = yoctodump.GetMeasurements()%0A%0Afor moduleData in data.values():%0A%0A    modName = moduleData%5B'logicalName'%5D%0A    if modName == '':%0A        modName = moduleData%5B'serialNumber'%5D.replace('-', '_')%0A%0A    for sensor in moduleData%5B'sensors'%5D.values():%0A%0A        senName = sensor%5B'functionId'%5D%0A        senVal  = sensor%5B'advertisedValue'%5D%0A        topic = 'yoctopuce/%25s/%25s' %25 (modName, senName)%0A%0A        (result, mid) = mqttClient.publish(topic, senVal)%0A        print '%3E%3E%3E %25s = %25s' %25 (topic, senVal)%0A%0A# need to sleep so messages get through%0A# all attempts at using on_publish and recording%0A# whats pending and whats been sent have failed%0Atime.sleep(1)%0A%0A# done%0AmqttClient.disconnect()%0A%0A

add script to push sensor values into an mqtt broker