def main(): gate = Ubigate('marmitek-gw', default_file='resources/conf.json.default') logger.info("Starting application") logger.debug('Timezone: %s' % gate.timezone) for data in mochad_reader.run(gate.timezone): if data['type'] != 'error': try: data['house'] = gate.find_house(data['sensor']) except KeyError: logger.warning("Unknown sensor: %s" % data['sensor']) else: # Appending house prefix if dealing with door sensor if data['sensorKind'] == 'door': for house in gate.config['houses']: if house['id'] == data['house']: prefix = house['prefix'] break else: prefix = '' data['sensor'] = prefix.lower() + data['sensor'] topic = "/marmitek/sensor/%s" % data['sensor'] gate.push(data['house'], topic, data)
def main(): gate = Ubigate('resources/conf.ini') log.add_logger_file('data.log', logging.WARN) logger.setLevel(logging.INFO) logger.info("Starting application") logger.info('Server: %s\n' 'Port: %s\n' 'Password: %s\n' 'House: %s\n' 'Username: %s\n' 'Timezone: %s' % (gate.config.server, gate.config.port, gate.config.password, gate.config.house, gate.config.username, gate.timezone)) for sensor, data in mochad_reader.run(gate.timezone): topic = "/marmitek/sensor/%s" % sensor data['house'] = gate.config.house gate.push(topic, data)