def __init__(self, thread_id, mqtt_config, run_event, name, address, type, interval, publish_missing_probes=False, topic="none", missing_probe_value="missing"): threading.Thread.__init__(self) self.threadID = thread_id self.name = name self.address = address self.type = type self.mqtt_client = utils.mqtt_init(mqtt_config) self.interval = interval self.run_event = run_event self.publish_missing_probes = publish_missing_probes self.missing_probe_value = missing_probe_value """ Since we're gearing to use public MQTT servers, use the device address as a topic partitioner. I'll add this to the new web based monitor to enter your address """ if (topic == "none"): self.topic = 'iGrillMon/' + address.upper() else: self.topic = topic
def main(): # Setup argument parsing parser = argparse.ArgumentParser(description='Monitor bluetooth igrill devices, and export to MQTT') parser.add_argument('-c', '--config', action='store', dest='config_directory', default='.', help='Set config directory, default: \'.\'') parser.add_argument('-l', '--log-level', action='store', dest='log_level', default='INFO', help='Set log level, default: \'info\'') parser.add_argument('-d', '--log-destination', action='store', dest='log_destination', default='', help='Set log destination (file), default: \'\' (stdout)') options = parser.parse_args() config = read_config(options.config_directory) # Setup logging log_setup(options.log_level, options.log_destination) # Get device list devices = get_devices(config['devices']) # Connect to MQTT client = mqtt_init(config['mqtt']) base_topic = config['mqtt']['base_topic'] polling_interval = config['interval'] if 'interval' in config else 15 while True: for device in devices: publish(device.read_temperature(), device.read_battery(), client, base_topic, device.name) time.sleep(polling_interval)
def __init__(self, thread_id, mqtt_config, run_event, topic, interval): threading.Thread.__init__(self) self.threadID = thread_id self.mqtt_client = utils.mqtt_init(mqtt_config) self.topic = topic self.interval = interval self.run_event = run_event
def __init__(self, thread_id, name, address, igrill_type, mqtt_config, topic, interval, run_event): threading.Thread.__init__(self) self.threadID = thread_id self.name = name self.address = address self.type = igrill_type self.mqtt_client = utils.mqtt_init(mqtt_config) self.topic = topic self.interval = interval self.run_event = run_event
def __init__(self, thread_id, mqtt_config, run_event, name, address, type, topic, interval, publish_missing_probes=False, missing_probe_value="missing"): threading.Thread.__init__(self) self.threadID = thread_id self.name = name self.address = address self.type = type self.mqtt_client = utils.mqtt_init(mqtt_config) self.topic = topic self.interval = interval self.run_event = run_event self.publish_missing_probes = publish_missing_probes self.missing_probe_value = missing_probe_value