Browse Source
Merge pull request #152 from ngt-github/add_TLS_option
Added options for TLS usage for MQTT client and insecure certificate …
pull/157/head
lumapu
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
7 additions and
0 deletions
-
tools/rpi/ahoy.yml.example
-
tools/rpi/hoymiles/__main__.py
|
|
@ -16,6 +16,8 @@ ahoy: |
|
|
|
port: 1883 |
|
|
|
user: 'username' |
|
|
|
password: 'password' |
|
|
|
useTLS: False |
|
|
|
insecureTLS: False #set True for e.g. self signed certificates. |
|
|
|
|
|
|
|
# Influx2 output |
|
|
|
influxdb: |
|
|
|
|
|
@ -226,6 +226,11 @@ if __name__ == '__main__': |
|
|
|
mqtt_config = ahoy_config.get('mqtt', []) |
|
|
|
if not mqtt_config.get('disabled', False): |
|
|
|
mqtt_client = paho.mqtt.client.Client() |
|
|
|
|
|
|
|
if mqtt_config.get('useTLS',False): |
|
|
|
mqtt_client.tls_set() |
|
|
|
mqtt_client.tls_insecure_set(mqtt_config.get('insecureTLS',False)) |
|
|
|
|
|
|
|
mqtt_client.username_pw_set(mqtt_config.get('user', None), mqtt_config.get('password', None)) |
|
|
|
mqtt_client.connect(mqtt_config.get('host', '127.0.0.1'), mqtt_config.get('port', 1883)) |
|
|
|
mqtt_client.loop_start() |
|
|
|