Skip to content

Commit

Permalink
Autodiscovery: add "mqtt retain" config flag
Browse files Browse the repository at this point in the history
  • Loading branch information
pbkhrv committed May 25, 2021
1 parent 39cead5 commit 41b6e03
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
4 changes: 4 additions & 0 deletions rtl_433_mqtt_autodiscovery/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## [0.1.8] - 2021-05-24

- Add "MQTT retain" flag

## [0.1.7] - 2021-03-17

- Remove old `device_class` `"moisture"`, `"safety"` and `"depth"` from whatever devices are still using them
Expand Down
1 change: 1 addition & 0 deletions rtl_433_mqtt_autodiscovery/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ To install this Home Assistant add-on you need to add the rtl_433 add-on reposit
* `mqtt_port`
* `mqtt_user`
* `mqtt_password`
* `mqtt_retain`: MQTT broker will retain configuration topics between restarts if this is set to true. Default is `false`.
* `rtl_topic`: MQTT topic where rtl_433 is publishing its output. Default is "rtl_433".
* `discovery_prefix`: MQTT topic prefix where Home Assistant is [looking for discovery information](https://www.home-assistant.io/docs/mqtt/discovery/#discovery_prefix). Default is "homeassistant".
* `discovery_interval`: how often to publish discovery information, in seconds. Default is 600.
Expand Down
4 changes: 3 additions & 1 deletion rtl_433_mqtt_autodiscovery/config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rtl_433 MQTT Auto Discovery",
"version": "0.1.7",
"version": "0.1.8",
"slug": "rtl433mqttautodiscovery",
"description": "Automatic discovery of rtl_433 device information via MQTT",
"url": "https://github.com/pbkhrv/rtl_433-hass-addons/tree/main/rtl_433_mqtt_autodiscovery",
Expand All @@ -12,6 +12,7 @@
"mqtt_port": 1883,
"mqtt_user": "",
"mqtt_password": "",
"mqtt_retain": false,
"rtl_topic": "rtl_433/+/events",
"discovery_prefix": "homeassistant",
"discovery_interval": 600
Expand All @@ -21,6 +22,7 @@
"mqtt_port": "int",
"mqtt_user": "str",
"mqtt_password": "str",
"mqtt_retain": "bool",
"rtl_topic": "str",
"discovery_prefix": "str",
"discovery_interval": "int"
Expand Down
7 changes: 6 additions & 1 deletion rtl_433_mqtt_autodiscovery/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,10 @@ RTL_TOPIC=$(bashio::config "rtl_topic")
DISCOVERY_PREFIX=$(bashio::config "discovery_prefix")
DISCOVERY_INTERVAL=$(bashio::config "discovery_interval")

OTHER_ARGS=""
if bashio::config.true "mqtt_retain"; then
OTHER_ARGS="${OTHER_ARGS} --retain"
fi

echo "Starting rtl_433_mqtt_hass.py..."
python3 /rtl_433_mqtt_hass.py -d -u $MQTT_USER -P $MQTT_PASS -H $MQTT_HOST -p $MQTT_PORT -R "$RTL_TOPIC" -D "$DISCOVERY_PREFIX" -i $DISCOVERY_INTERVAL
python3 /rtl_433_mqtt_hass.py -d -u $MQTT_USER -P $MQTT_PASS -H $MQTT_HOST -p $MQTT_PORT -R "$RTL_TOPIC" -D "$DISCOVERY_PREFIX" -i $DISCOVERY_INTERVAL $OTHER_ARGS

0 comments on commit 41b6e03

Please sign in to comment.