Skip to content

Commit

Permalink
Merge pull request lumapu#152 from ngt-github/add_TLS_option
Browse files Browse the repository at this point in the history
Added options for TLS usage for MQTT client and insecure certificate …
  • Loading branch information
lumapu authored Aug 14, 2022
2 parents e1c713f + 616e889 commit 3c24542
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tools/rpi/ahoy.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 5 additions & 0 deletions tools/rpi/hoymiles/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,11 @@ def mqtt_on_command(client, userdata, message):
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()
Expand Down

0 comments on commit 3c24542

Please sign in to comment.