Migrate to topic prefix instead of individual topic config.

This makes the configuration easier, as well if new topics are added in
the future, there is no need to update all the configuration files
again to add the missing topic configuration.
This commit is contained in:
Orne Brocaar 2023-01-19 12:01:20 +00:00
parent b6209d760e
commit a36d323f2b
41 changed files with 260 additions and 200 deletions

View File

@ -30,11 +30,12 @@
# MQTT configuration.
[regions.gateway.backend.mqtt]
# Event topic template.
event_topic="as923/gateway/+/event/+"
# Command topic template.
command_topic="as923/gateway/{{ gateway_id }}/command/{{ command }}"
# Topic prefix.
#
# The topic prefix can be used to define the region of the gateway.
# Note, there is no need to add a trailing '/' to the prefix. The trailing
# '/' is automatically added to the prefix if it is configured.
topic_prefix="as923"
# MQTT server (e.g. scheme://host:port where scheme is tcp, ssl or ws)
server="tcp://$MQTT_BROKER_HOST:1883"

View File

@ -30,11 +30,12 @@
# MQTT configuration.
[regions.gateway.backend.mqtt]
# Event topic template.
event_topic="as923_2/gateway/+/event/+"
# Command topic template.
command_topic="as923_2/gateway/{{ gateway_id }}/command/{{ command }}"
# Topic prefix.
#
# The topic prefix can be used to define the region of the gateway.
# Note, there is no need to add a trailing '/' to the prefix. The trailing
# '/' is automatically added to the prefix if it is configured.
topic_prefix="as923_2"
# MQTT server (e.g. scheme://host:port where scheme is tcp, ssl or ws)
server="tcp://$MQTT_BROKER_HOST:1883"

View File

@ -30,11 +30,12 @@
# MQTT configuration.
[regions.gateway.backend.mqtt]
# Event topic template.
event_topic="as923_3/gateway/+/event/+"
# Command topic template.
command_topic="as923_3/gateway/{{ gateway_id }}/command/{{ command }}"
# Topic prefix.
#
# The topic prefix can be used to define the region of the gateway.
# Note, there is no need to add a trailing '/' to the prefix. The trailing
# '/' is automatically added to the prefix if it is configured.
topic_prefix="as923_3"
# MQTT server (e.g. scheme://host:port where scheme is tcp, ssl or ws)
server="tcp://$MQTT_BROKER_HOST:1883"

View File

@ -30,11 +30,12 @@
# MQTT configuration.
[regions.gateway.backend.mqtt]
# Event topic template.
event_topic="as923_4/gateway/+/event/+"
# Command topic template.
command_topic="as923_4/gateway/{{ gateway_id }}/command/{{ command }}"
# Topic prefix.
#
# The topic prefix can be used to define the region of the gateway.
# Note, there is no need to add a trailing '/' to the prefix. The trailing
# '/' is automatically added to the prefix if it is configured.
topic_prefix="as923_4"
# MQTT server (e.g. scheme://host:port where scheme is tcp, ssl or ws)
server="tcp://$MQTT_BROKER_HOST:1883"

View File

@ -30,11 +30,12 @@
# MQTT configuration.
[regions.gateway.backend.mqtt]
# Event topic template.
event_topic="au915_0/gateway/+/event/+"
# Command topic template.
command_topic="au915_0/gateway/{{ gateway_id }}/command/{{ command }}"
# Topic prefix.
#
# The topic prefix can be used to define the region of the gateway.
# Note, there is no need to add a trailing '/' to the prefix. The trailing
# '/' is automatically added to the prefix if it is configured.
topic_prefix="au915_0"
# MQTT server (e.g. scheme://host:port where scheme is tcp, ssl or ws)
server="tcp://$MQTT_BROKER_HOST:1883"

View File

@ -30,11 +30,12 @@
# MQTT configuration.
[regions.gateway.backend.mqtt]
# Event topic template.
event_topic="au915_1/gateway/+/event/+"
# Command topic template.
command_topic="au915_1/gateway/{{ gateway_id }}/command/{{ command }}"
# Topic prefix.
#
# The topic prefix can be used to define the region of the gateway.
# Note, there is no need to add a trailing '/' to the prefix. The trailing
# '/' is automatically added to the prefix if it is configured.
topic_prefix="au915_1"
# MQTT server (e.g. scheme://host:port where scheme is tcp, ssl or ws)
server="tcp://$MQTT_BROKER_HOST:1883"

View File

@ -30,11 +30,12 @@
# MQTT configuration.
[regions.gateway.backend.mqtt]
# Event topic template.
event_topic="au915_2/gateway/+/event/+"
# Command topic template.
command_topic="au915_2/gateway/{{ gateway_id }}/command/{{ command }}"
# Topic prefix.
#
# The topic prefix can be used to define the region of the gateway.
# Note, there is no need to add a trailing '/' to the prefix. The trailing
# '/' is automatically added to the prefix if it is configured.
topic_prefix="au915_2"
# MQTT server (e.g. scheme://host:port where scheme is tcp, ssl or ws)
server="tcp://$MQTT_BROKER_HOST:1883"

View File

@ -30,11 +30,12 @@
# MQTT configuration.
[regions.gateway.backend.mqtt]
# Event topic template.
event_topic="au915_3/gateway/+/event/+"
# Command topic template.
command_topic="au915_3/gateway/{{ gateway_id }}/command/{{ command }}"
# Topic prefix.
#
# The topic prefix can be used to define the region of the gateway.
# Note, there is no need to add a trailing '/' to the prefix. The trailing
# '/' is automatically added to the prefix if it is configured.
topic_prefix="au915_3"
# MQTT server (e.g. scheme://host:port where scheme is tcp, ssl or ws)
server="tcp://$MQTT_BROKER_HOST:1883"

View File

@ -30,11 +30,12 @@
# MQTT configuration.
[regions.gateway.backend.mqtt]
# Event topic template.
event_topic="au915_4/gateway/+/event/+"
# Command topic template.
command_topic="au915_4/gateway/{{ gateway_id }}/command/{{ command }}"
# Topic prefix.
#
# The topic prefix can be used to define the region of the gateway.
# Note, there is no need to add a trailing '/' to the prefix. The trailing
# '/' is automatically added to the prefix if it is configured.
topic_prefix="au915_4"
# MQTT server (e.g. scheme://host:port where scheme is tcp, ssl or ws)
server="tcp://$MQTT_BROKER_HOST:1883"

View File

@ -30,11 +30,12 @@
# MQTT configuration.
[regions.gateway.backend.mqtt]
# Event topic template.
event_topic="au915_5/gateway/+/event/+"
# Command topic template.
command_topic="au915_5/gateway/{{ gateway_id }}/command/{{ command }}"
# Topic prefix.
#
# The topic prefix can be used to define the region of the gateway.
# Note, there is no need to add a trailing '/' to the prefix. The trailing
# '/' is automatically added to the prefix if it is configured.
topic_prefix="au915_5"
# MQTT server (e.g. scheme://host:port where scheme is tcp, ssl or ws)
server="tcp://$MQTT_BROKER_HOST:1883"

View File

@ -30,11 +30,12 @@
# MQTT configuration.
[regions.gateway.backend.mqtt]
# Event topic template.
event_topic="au915_6/gateway/+/event/+"
# Command topic template.
command_topic="au915_6/gateway/{{ gateway_id }}/command/{{ command }}"
# Topic prefix.
#
# The topic prefix can be used to define the region of the gateway.
# Note, there is no need to add a trailing '/' to the prefix. The trailing
# '/' is automatically added to the prefix if it is configured.
topic_prefix="au915_6"
# MQTT server (e.g. scheme://host:port where scheme is tcp, ssl or ws)
server="tcp://$MQTT_BROKER_HOST:1883"

View File

@ -30,11 +30,12 @@
# MQTT configuration.
[regions.gateway.backend.mqtt]
# Event topic template.
event_topic="au915_7/gateway/+/event/+"
# Command topic template.
command_topic="au915_7/gateway/{{ gateway_id }}/command/{{ command }}"
# Topic prefix.
#
# The topic prefix can be used to define the region of the gateway.
# Note, there is no need to add a trailing '/' to the prefix. The trailing
# '/' is automatically added to the prefix if it is configured.
topic_prefix="au915_7"
# MQTT server (e.g. scheme://host:port where scheme is tcp, ssl or ws)
server="tcp://$MQTT_BROKER_HOST:1883"

View File

@ -30,11 +30,12 @@
# MQTT configuration.
[regions.gateway.backend.mqtt]
# Event topic template.
event_topic="cn470_0/gateway/+/event/+"
# Command topic template.
command_topic="cn470_0/gateway/{{ gateway_id }}/command/{{ command }}"
# Topic prefix.
#
# The topic prefix can be used to define the region of the gateway.
# Note, there is no need to add a trailing '/' to the prefix. The trailing
# '/' is automatically added to the prefix if it is configured.
topic_prefix="cn470_0"
# MQTT server (e.g. scheme://host:port where scheme is tcp, ssl or ws)
server="tcp://$MQTT_BROKER_HOST:1883"

View File

@ -30,11 +30,12 @@
# MQTT configuration.
[regions.gateway.backend.mqtt]
# Event topic template.
event_topic="cn470_1/gateway/+/event/+"
# Command topic template.
command_topic="cn470_1/gateway/{{ gateway_id }}/command/{{ command }}"
# Topic prefix.
#
# The topic prefix can be used to define the region of the gateway.
# Note, there is no need to add a trailing '/' to the prefix. The trailing
# '/' is automatically added to the prefix if it is configured.
topic_prefix="cn470_1"
# MQTT server (e.g. scheme://host:port where scheme is tcp, ssl or ws)
server="tcp://$MQTT_BROKER_HOST:1883"

View File

@ -30,11 +30,12 @@
# MQTT configuration.
[regions.gateway.backend.mqtt]
# Event topic template.
event_topic="cn470_10/gateway/+/event/+"
# Command topic template.
command_topic="cn470_10/gateway/{{ gateway_id }}/command/{{ command }}"
# Topic prefix.
#
# The topic prefix can be used to define the region of the gateway.
# Note, there is no need to add a trailing '/' to the prefix. The trailing
# '/' is automatically added to the prefix if it is configured.
topic_prefix="cn470_10"
# MQTT server (e.g. scheme://host:port where scheme is tcp, ssl or ws)
server="tcp://$MQTT_BROKER_HOST:1883"

View File

@ -30,11 +30,12 @@
# MQTT configuration.
[regions.gateway.backend.mqtt]
# Event topic template.
event_topic="cn470_11/gateway/+/event/+"
# Command topic template.
command_topic="cn470_11/gateway/{{ gateway_id }}/command/{{ command }}"
# Topic prefix.
#
# The topic prefix can be used to define the region of the gateway.
# Note, there is no need to add a trailing '/' to the prefix. The trailing
# '/' is automatically added to the prefix if it is configured.
topic_prefix="cn470_11"
# MQTT server (e.g. scheme://host:port where scheme is tcp, ssl or ws)
server="tcp://$MQTT_BROKER_HOST:1883"

View File

@ -30,11 +30,12 @@
# MQTT configuration.
[regions.gateway.backend.mqtt]
# Event topic template.
event_topic="cn470_2/gateway/+/event/+"
# Command topic template.
command_topic="cn470_2/gateway/{{ gateway_id }}/command/{{ command }}"
# Topic prefix.
#
# The topic prefix can be used to define the region of the gateway.
# Note, there is no need to add a trailing '/' to the prefix. The trailing
# '/' is automatically added to the prefix if it is configured.
topic_prefix="cn470_2"
# MQTT server (e.g. scheme://host:port where scheme is tcp, ssl or ws)
server="tcp://$MQTT_BROKER_HOST:1883"

View File

@ -30,11 +30,12 @@
# MQTT configuration.
[regions.gateway.backend.mqtt]
# Event topic template.
event_topic="cn470_3/gateway/+/event/+"
# Command topic template.
command_topic="cn470_3/gateway/{{ gateway_id }}/command/{{ command }}"
# Topic prefix.
#
# The topic prefix can be used to define the region of the gateway.
# Note, there is no need to add a trailing '/' to the prefix. The trailing
# '/' is automatically added to the prefix if it is configured.
topic_prefix="cn470_3"
# MQTT server (e.g. scheme://host:port where scheme is tcp, ssl or ws)
server="tcp://$MQTT_BROKER_HOST:1883"

View File

@ -30,11 +30,12 @@
# MQTT configuration.
[regions.gateway.backend.mqtt]
# Event topic template.
event_topic="cn470_4/gateway/+/event/+"
# Command topic template.
command_topic="cn470_4/gateway/{{ gateway_id }}/command/{{ command }}"
# Topic prefix.
#
# The topic prefix can be used to define the region of the gateway.
# Note, there is no need to add a trailing '/' to the prefix. The trailing
# '/' is automatically added to the prefix if it is configured.
topic_prefix="cn470_4"
# MQTT server (e.g. scheme://host:port where scheme is tcp, ssl or ws)
server="tcp://$MQTT_BROKER_HOST:1883"

View File

@ -30,11 +30,12 @@
# MQTT configuration.
[regions.gateway.backend.mqtt]
# Event topic template.
event_topic="cn470_5/gateway/+/event/+"
# Command topic template.
command_topic="cn470_5/gateway/{{ gateway_id }}/command/{{ command }}"
# Topic prefix.
#
# The topic prefix can be used to define the region of the gateway.
# Note, there is no need to add a trailing '/' to the prefix. The trailing
# '/' is automatically added to the prefix if it is configured.
topic_prefix="cn470_5"
# MQTT server (e.g. scheme://host:port where scheme is tcp, ssl or ws)
server="tcp://$MQTT_BROKER_HOST:1883"

View File

@ -30,11 +30,12 @@
# MQTT configuration.
[regions.gateway.backend.mqtt]
# Event topic template.
event_topic="cn470_6/gateway/+/event/+"
# Command topic template.
command_topic="cn470_6/gateway/{{ gateway_id }}/command/{{ command }}"
# Topic prefix.
#
# The topic prefix can be used to define the region of the gateway.
# Note, there is no need to add a trailing '/' to the prefix. The trailing
# '/' is automatically added to the prefix if it is configured.
topic_prefix="cn470_6"
# MQTT server (e.g. scheme://host:port where scheme is tcp, ssl or ws)
server="tcp://$MQTT_BROKER_HOST:1883"

View File

@ -30,11 +30,12 @@
# MQTT configuration.
[regions.gateway.backend.mqtt]
# Event topic template.
event_topic="cn470_7/gateway/+/event/+"
# Command topic template.
command_topic="cn470_7/gateway/{{ gateway_id }}/command/{{ command }}"
# Topic prefix.
#
# The topic prefix can be used to define the region of the gateway.
# Note, there is no need to add a trailing '/' to the prefix. The trailing
# '/' is automatically added to the prefix if it is configured.
topic_prefix="cn470_7"
# MQTT server (e.g. scheme://host:port where scheme is tcp, ssl or ws)
server="tcp://$MQTT_BROKER_HOST:1883"

View File

@ -30,11 +30,12 @@
# MQTT configuration.
[regions.gateway.backend.mqtt]
# Event topic template.
event_topic="cn470_8/gateway/+/event/+"
# Command topic template.
command_topic="cn470_8/gateway/{{ gateway_id }}/command/{{ command }}"
# Topic prefix.
#
# The topic prefix can be used to define the region of the gateway.
# Note, there is no need to add a trailing '/' to the prefix. The trailing
# '/' is automatically added to the prefix if it is configured.
topic_prefix="cn470_8"
# MQTT server (e.g. scheme://host:port where scheme is tcp, ssl or ws)
server="tcp://$MQTT_BROKER_HOST:1883"

View File

@ -30,11 +30,12 @@
# MQTT configuration.
[regions.gateway.backend.mqtt]
# Event topic template.
event_topic="cn470_9/gateway/+/event/+"
# Command topic template.
command_topic="cn470_9/gateway/{{ gateway_id }}/command/{{ command }}"
# Topic prefix.
#
# The topic prefix can be used to define the region of the gateway.
# Note, there is no need to add a trailing '/' to the prefix. The trailing
# '/' is automatically added to the prefix if it is configured.
topic_prefix="cn470_9"
# MQTT server (e.g. scheme://host:port where scheme is tcp, ssl or ws)
server="tcp://$MQTT_BROKER_HOST:1883"

View File

@ -30,11 +30,12 @@
# MQTT configuration.
[regions.gateway.backend.mqtt]
# Event topic template.
event_topic="cn779/gateway/+/event/+"
# Command topic template.
command_topic="cn779/gateway/{{ gateway_id }}/command/{{ command }}"
# Topic prefix.
#
# The topic prefix can be used to define the region of the gateway.
# Note, there is no need to add a trailing '/' to the prefix. The trailing
# '/' is automatically added to the prefix if it is configured.
topic_prefix="cn779"
# MQTT server (e.g. scheme://host:port where scheme is tcp, ssl or ws)
server="tcp://$MQTT_BROKER_HOST:1883"

View File

@ -30,11 +30,12 @@
# MQTT configuration.
[regions.gateway.backend.mqtt]
# Event topic template.
event_topic="eu433/gateway/+/event/+"
# Command topic template.
command_topic="eu433/gateway/{{ gateway_id }}/command/{{ command }}"
# Topic prefix.
#
# The topic prefix can be used to define the region of the gateway.
# Note, there is no need to add a trailing '/' to the prefix. The trailing
# '/' is automatically added to the prefix if it is configured.
topic_prefix="eu433"
# MQTT server (e.g. scheme://host:port where scheme is tcp, ssl or ws)
server="tcp://$MQTT_BROKER_HOST:1883"

View File

@ -30,11 +30,12 @@
# MQTT configuration.
[regions.gateway.backend.mqtt]
# Event topic template.
event_topic="eu868/gateway/+/event/+"
# Command topic template.
command_topic="eu868/gateway/{{ gateway_id }}/command/{{ command }}"
# Topic prefix.
#
# The topic prefix can be used to define the region of the gateway.
# Note, there is no need to add a trailing '/' to the prefix. The trailing
# '/' is automatically added to the prefix if it is configured.
topic_prefix="eu868"
# MQTT server (e.g. scheme://host:port where scheme is tcp, ssl or ws)
server="tcp://$MQTT_BROKER_HOST:1883"

View File

@ -30,11 +30,12 @@
# MQTT configuration.
[regions.gateway.backend.mqtt]
# Event topic template.
event_topic="in865/gateway/+/event/+"
# Command topic template.
command_topic="in865/gateway/{{ gateway_id }}/command/{{ command }}"
# Topic prefix.
#
# The topic prefix can be used to define the region of the gateway.
# Note, there is no need to add a trailing '/' to the prefix. The trailing
# '/' is automatically added to the prefix if it is configured.
topic_prefix="in865"
# MQTT server (e.g. scheme://host:port where scheme is tcp, ssl or ws)
server="tcp://$MQTT_BROKER_HOST:1883"

View File

@ -30,11 +30,12 @@
# MQTT configuration.
[regions.gateway.backend.mqtt]
# Event topic template.
event_topic="ism2400/gateway/+/event/+"
# Command topic template.
command_topic="ism2400/gateway/{{ gateway_id }}/command/{{ command }}"
# Topic prefix.
#
# The topic prefix can be used to define the region of the gateway.
# Note, there is no need to add a trailing '/' to the prefix. The trailing
# '/' is automatically added to the prefix if it is configured.
topic_prefix="ism2400"
# MQTT server (e.g. scheme://host:port where scheme is tcp, ssl or ws)
server="tcp://$MQTT_BROKER_HOST:1883"

View File

@ -30,11 +30,12 @@
# MQTT configuration.
[regions.gateway.backend.mqtt]
# Event topic template.
event_topic="kr920/gateway/+/event/+"
# Command topic template.
command_topic="kr920/gateway/{{ gateway_id }}/command/{{ command }}"
# Topic prefix.
#
# The topic prefix can be used to define the region of the gateway.
# Note, there is no need to add a trailing '/' to the prefix. The trailing
# '/' is automatically added to the prefix if it is configured.
topic_prefix="kr920"
# MQTT server (e.g. scheme://host:port where scheme is tcp, ssl or ws)
server="tcp://$MQTT_BROKER_HOST:1883"

View File

@ -30,11 +30,12 @@
# MQTT configuration.
[regions.gateway.backend.mqtt]
# Event topic template.
event_topic="ru864/gateway/+/event/+"
# Command topic template.
command_topic="ru864/gateway/{{ gateway_id }}/command/{{ command }}"
# Topic prefix.
#
# The topic prefix can be used to define the region of the gateway.
# Note, there is no need to add a trailing '/' to the prefix. The trailing
# '/' is automatically added to the prefix if it is configured.
topic_prefix="ru864"
# MQTT server (e.g. scheme://host:port where scheme is tcp, ssl or ws)
server="tcp://$MQTT_BROKER_HOST:1883"

View File

@ -30,11 +30,12 @@
# MQTT configuration.
[regions.gateway.backend.mqtt]
# Event topic template.
event_topic="us915_0/gateway/+/event/+"
# Command topic template.
command_topic="us915_0/gateway/{{ gateway_id }}/command/{{ command }}"
# Topic prefix.
#
# The topic prefix can be used to define the region of the gateway.
# Note, there is no need to add a trailing '/' to the prefix. The trailing
# '/' is automatically added to the prefix if it is configured.
topic_prefix="us915_0"
# MQTT server (e.g. scheme://host:port where scheme is tcp, ssl or ws)
server="tcp://$MQTT_BROKER_HOST:1883"

View File

@ -30,11 +30,12 @@
# MQTT configuration.
[regions.gateway.backend.mqtt]
# Event topic template.
event_topic="us915_1/gateway/+/event/+"
# Command topic template.
command_topic="us915_1/gateway/{{ gateway_id }}/command/{{ command }}"
# Topic prefix.
#
# The topic prefix can be used to define the region of the gateway.
# Note, there is no need to add a trailing '/' to the prefix. The trailing
# '/' is automatically added to the prefix if it is configured.
topic_prefix="us915_1"
# MQTT server (e.g. scheme://host:port where scheme is tcp, ssl or ws)
server="tcp://$MQTT_BROKER_HOST:1883"

View File

@ -30,11 +30,12 @@
# MQTT configuration.
[regions.gateway.backend.mqtt]
# Event topic template.
event_topic="us915_2/gateway/+/event/+"
# Command topic template.
command_topic="us915_2/gateway/{{ gateway_id }}/command/{{ command }}"
# Topic prefix.
#
# The topic prefix can be used to define the region of the gateway.
# Note, there is no need to add a trailing '/' to the prefix. The trailing
# '/' is automatically added to the prefix if it is configured.
topic_prefix="us915_2"
# MQTT server (e.g. scheme://host:port where scheme is tcp, ssl or ws)
server="tcp://$MQTT_BROKER_HOST:1883"

View File

@ -30,11 +30,12 @@
# MQTT configuration.
[regions.gateway.backend.mqtt]
# Event topic template.
event_topic="us915_3/gateway/+/event/+"
# Command topic template.
command_topic="us915_3/gateway/{{ gateway_id }}/command/{{ command }}"
# Topic prefix.
#
# The topic prefix can be used to define the region of the gateway.
# Note, there is no need to add a trailing '/' to the prefix. The trailing
# '/' is automatically added to the prefix if it is configured.
topic_prefix="us915_3"
# MQTT server (e.g. scheme://host:port where scheme is tcp, ssl or ws)
server="tcp://$MQTT_BROKER_HOST:1883"

View File

@ -30,11 +30,12 @@
# MQTT configuration.
[regions.gateway.backend.mqtt]
# Event topic template.
event_topic="us915_4/gateway/+/event/+"
# Command topic template.
command_topic="us915_4/gateway/{{ gateway_id }}/command/{{ command }}"
# Topic prefix.
#
# The topic prefix can be used to define the region of the gateway.
# Note, there is no need to add a trailing '/' to the prefix. The trailing
# '/' is automatically added to the prefix if it is configured.
topic_prefix="us915_4"
# MQTT server (e.g. scheme://host:port where scheme is tcp, ssl or ws)
server="tcp://$MQTT_BROKER_HOST:1883"

View File

@ -30,11 +30,12 @@
# MQTT configuration.
[regions.gateway.backend.mqtt]
# Event topic template.
event_topic="us915_5/gateway/+/event/+"
# Command topic template.
command_topic="us915_5/gateway/{{ gateway_id }}/command/{{ command }}"
# Topic prefix.
#
# The topic prefix can be used to define the region of the gateway.
# Note, there is no need to add a trailing '/' to the prefix. The trailing
# '/' is automatically added to the prefix if it is configured.
topic_prefix="us915_5"
# MQTT server (e.g. scheme://host:port where scheme is tcp, ssl or ws)
server="tcp://$MQTT_BROKER_HOST:1883"

View File

@ -30,11 +30,12 @@
# MQTT configuration.
[regions.gateway.backend.mqtt]
# Event topic template.
event_topic="us915_6/gateway/+/event/+"
# Command topic template.
command_topic="us915_6/gateway/{{ gateway_id }}/command/{{ command }}"
# Topic prefix.
#
# The topic prefix can be used to define the region of the gateway.
# Note, there is no need to add a trailing '/' to the prefix. The trailing
# '/' is automatically added to the prefix if it is configured.
topic_prefix="us915_6"
# MQTT server (e.g. scheme://host:port where scheme is tcp, ssl or ws)
server="tcp://$MQTT_BROKER_HOST:1883"

View File

@ -30,11 +30,12 @@
# MQTT configuration.
[regions.gateway.backend.mqtt]
# Event topic template.
event_topic="us915_7/gateway/+/event/+"
# Command topic template.
command_topic="us915_7/gateway/{{ gateway_id }}/command/{{ command }}"
# Topic prefix.
#
# The topic prefix can be used to define the region of the gateway.
# Note, there is no need to add a trailing '/' to the prefix. The trailing
# '/' is automatically added to the prefix if it is configured.
topic_prefix="us915_7"
# MQTT server (e.g. scheme://host:port where scheme is tcp, ssl or ws)
server="tcp://$MQTT_BROKER_HOST:1883"

View File

@ -542,9 +542,7 @@ impl Default for Region {
backend: GatewayBackend {
enabled: "mqtt".into(),
mqtt: GatewayBackendMqtt {
event_topic: "eu868/gateway/+/event/+".into(),
command_topic: "eu868/gateway/{{ gateway_id }}/command/{{ command }}"
.into(),
topic_prefix: "eu868".into(),
..Default::default()
},
},
@ -621,6 +619,7 @@ pub struct GatewayBackend {
#[derive(Serialize, Deserialize, Clone)]
#[serde(default)]
pub struct GatewayBackendMqtt {
pub topic_prefix: String,
pub event_topic: String,
pub command_topic: String,
pub server: String,
@ -639,6 +638,7 @@ pub struct GatewayBackendMqtt {
impl Default for GatewayBackendMqtt {
fn default() -> Self {
GatewayBackendMqtt {
topic_prefix: "".into(),
event_topic: "".into(),
command_topic: "".into(),
server: "tcp://127.0.0.1:1883/".into(),

View File

@ -85,7 +85,19 @@ impl<'a> MqttBackend<'a> {
) -> Result<MqttBackend<'a>> {
// topic templates
let mut templates = Handlebars::new();
templates.register_template_string("command_topic", &conf.command_topic)?;
templates.register_template_string(
"command_topic",
if conf.command_topic.is_empty() {
let command_topic = "gateway/{{ gateway_id }}/command/{{ command }}".to_string();
if conf.topic_prefix.is_empty() {
command_topic
} else {
format!("{}/{}", conf.topic_prefix, command_topic)
}
} else {
conf.command_topic.clone()
},
)?;
// get client id, this will generate a random client_id when no client_id has been
// configured.
@ -211,7 +223,16 @@ impl<'a> MqttBackend<'a> {
// (Re)subscribe loop.
tokio::spawn({
let region_config_id = region_config_id.to_string();
let event_topic = conf.event_topic.clone();
let event_topic = if conf.event_topic.is_empty() {
let event_topic = "gateway/+/event/+".to_string();
if conf.topic_prefix.is_empty() {
event_topic
} else {
format!("{}/{}", conf.topic_prefix, event_topic)
}
} else {
conf.event_topic.clone()
};
let client = b.client.clone();
let qos = conf.qos as i32;