mirror of
https://github.com/Luzifer/mqtt2influx.git
synced 2024-12-20 09:31:23 +00:00
Allow overriding vars in env, add info on submit
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
c3c4a0913c
commit
bb1a81005e
1 changed files with 9 additions and 8 deletions
17
main.py
17
main.py
|
@ -55,6 +55,10 @@ class MQTT2InfluxDB():
|
|||
))
|
||||
|
||||
if len(points) > 0:
|
||||
logging.info('Submitting {n} datapoints for topic {topic}'.format(
|
||||
n=len(points),
|
||||
topic=msg.topic,
|
||||
))
|
||||
self.influx.submit(points)
|
||||
|
||||
def run(self):
|
||||
|
@ -66,19 +70,16 @@ class MQTT2InfluxDB():
|
|||
mqtt_config = vault.read_data('secret/mqtt2influx/mqtt')
|
||||
|
||||
client.username_pw_set(
|
||||
self.obj_get(mqtt_config, 'user', self.obj_get(
|
||||
os.environ, 'MQTT_USER')),
|
||||
self.obj_get(mqtt_config, 'pass', self.obj_get(
|
||||
os.environ, 'MQTT_PASS')),
|
||||
self.obj_get(os.environ, 'MQTT_USER', mqtt_config['user']),
|
||||
self.obj_get(os.environ, 'MQTT_PASS', mqtt_config['pass']),
|
||||
)
|
||||
|
||||
logging.debug('Connecting to MQTT broker...')
|
||||
|
||||
client.connect(
|
||||
self.obj_get(mqtt_config, 'host', self.obj_get(
|
||||
os.environ, 'MQTT_HOST')),
|
||||
port=self.obj_get(mqtt_config, 'port', self.obj_get(
|
||||
os.environ, 'MQTT_PORT', 1883)),
|
||||
self.obj_get(os.environ, 'MQTT_HOST', mqtt_config['host']),
|
||||
self.obj_get(os.environ, 'MQTT_HOST',
|
||||
self.obj_get(mqtt_config, 'host', 1883)),
|
||||
keepalive=10,
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in a new issue