Skip to content

Commit

Permalink
Merge pull request #112 from allangood/dev
Browse files Browse the repository at this point in the history
Fixed regarding TLS and the Addon-On
  • Loading branch information
allangood authored Apr 12, 2022
2 parents 31f66a6 + dcaf423 commit 8cee8ac
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ This project was created to send readings made by RTLAMR + RTL_TCP to a MQTT bro
My user case is to integrate it with Home Assistant.

### Noteworthy Updates
*2022-04-12*
- New `tls_enabled` parameter to avoid confusions
- Some fixes for the Add-On regarding the TLS configuration

*2022-04-04*
- New TLS parameters to MQTT connection
- New parameter: USB_RESET to address problem mentioned on #98
Expand Down Expand Up @@ -68,6 +72,8 @@ mqtt:
host: 192.168.1.1
# MQTT port.
port: 1883
# TLS Enabled? (False by default)
tls_enabled: false
# TLS CA certificate
tls_ca: "/etc/ssl/certs/ca-certificates.crt"
# TLS server certificate
Expand Down
4 changes: 3 additions & 1 deletion rtlamr2mqtt-addon/config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rtlamr2mqtt",
"version": "1.7.0",
"version": "1.7.1",
"slug": "rtlamr2mqtt",
"panel_icon": "mdi:gauge",
"description": "RTLAMR to MQTT Bridge",
Expand Down Expand Up @@ -31,6 +31,7 @@
"mqtt": {
"ha_autodiscovery": true,
"ha_autodiscovery_topic": "homeassistant",
"tls_enabled": false,
"tls_ca": "/etc/ssl/certs/ca-certificates.crt",
"tls_cert": "/etc/ssl/my_self_signed_cert.crt",
"tls_keyfile": "/etc/ssl/my_self_signed_cert_key.key",
Expand Down Expand Up @@ -62,6 +63,7 @@
"mqtt": {
"host": "str?",
"port": "int?",
"tls_enabled": "bool?",
"tls_ca": "str?",
"tls_cert": "str?",
"tls_keyfile": "str?",
Expand Down
12 changes: 8 additions & 4 deletions rtlamr2mqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,11 +250,11 @@ def sliding_mean(series):
if str(os.environ.get('LISTEN_ONLY')).lower() in ['yes', 'true']:
log_message('Starting in LISTEN ONLY Mode...')
log_message('!!! IN THIS MODE I WILL NOT READ ANY CONFIGURATION FILE !!!')
msgtype = os.environ.get('RTL_MSGTYPE', 'all')
msgtype = os.environ.get('RTL_MSGTYPE', 'all')
rtltcp_cmd = ['/usr/bin/rtl_tcp']
# While DEBUG mode doesn't read a config, it's still helpful to specify a specific rtl_tcp device.
# If it exists, this reads the environment variable RTL_TCP_ARGS and appends it to rtl_tcp command line.
# For example, RTL-SDR serial number 777: docker run -e LISTEN_ONLY=yes -e RTL_TCP_ARGS="-d 777" ...
# If it exists, this reads the environment variable RTL_TCP_ARGS and appends it to rtl_tcp command line.
# For example, RTL-SDR serial number 777: docker run -e LISTEN_ONLY=yes -e RTL_TCP_ARGS="-d 777" ...
if os.environ.get('RTL_TCP_ARGS'):
rtltcp_cmd.extend(os.environ.get('RTL_TCP_ARGS').split(' '))
log_message('Starting rtl_tcp with ' + str(rtltcp_cmd))
Expand Down Expand Up @@ -297,7 +297,8 @@ def sliding_mean(series):
or config['mqtt'].get('password')):
host = config['mqtt'].get('host', 'localhost')
port = config['mqtt'].get('port', 1883)
if 'tls_ca' in config['mqtt']:
tls_enabled = config['mqtt'].get('tls_enabled', False)
if tls_enabled:
tls_ca = config['mqtt'].get('tls_ca', '/etc/ssl/certs/ca-certificates.crt')
tls_cert = config['mqtt'].get('tls_cert', None)
tls_keyfile = config['mqtt'].get('tls_keyfile', None)
Expand All @@ -321,6 +322,9 @@ def sliding_mean(series):
port = d.get('port')
user = d.get('username')
password = d.get('password')
ssl = d.get('ssl', False)
if ssl:
tls = { 'ca_certs': '/etc/ssl/certs/ca-certificates.crt', 'insecure': true }
except e:
log_message("Could not fetch default MQTT configuration: %s" % e)
host = 'localhost'
Expand Down
4 changes: 3 additions & 1 deletion rtlamr2mqtt.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ general:

mqtt:
host: 127.0.0.1
# Path to CA certificate to use. Mandatory
# Use TLS with MQTT?
tls_enabled: false
# Path to CA certificate to use. Mandatory if tls_enabled = true
tls_ca: '/etc/ssl/certs/ca-certificates.crt'
# Path to certificate file to use. Optional
tls_cert: '/etc/ssl/my_self_signed_cert.crt'
Expand Down

0 comments on commit 8cee8ac

Please sign in to comment.