def _get_mqtt_settings(self): logger.info('loading mqtt settings') settings = self._get_default_mqtt_settings() config_parser = config.SafeConfigParser(allow_no_value=False) with open('radiator.cfg') as config_file: config_parser.readfp(config_file) settings['enabled'] = config_parser.getboolean('general', 'mqtt', fallback=False) if settings['enabled'] and 'mqtt' in config_parser.sections(): mqtt = config_parser['mqtt'] settings['host'] = mqtt.get('host', '') settings['port'] = mqtt.getint('port', 0) settings['username'] = mqtt.get('username', '') settings['password'] = mqtt.get('password', '') settings['online_topic'] = mqtt.get('online_topic', '') settings['marquee_topic'] = mqtt.get('marquee_topic', '') return settings
def main(): tpin = rasp_get_id() + '/m2s' tpout = rasp_get_id() + '/s2m' mqtt = MQTT('iot.eclipse.org', 1883, tpin, tpout) msg = '' while True: msg = mqtt.get() if (msg != ''): print(msg) mqtt.send_frame('USER1', 'CONTROL', 'LED', 'NONE', 'ON') msg = '' mqtt.run()