diff --git a/README.md b/README.md index 4646736..983d8cb 100644 --- a/README.md +++ b/README.md @@ -85,6 +85,10 @@ Auth-token mode is easy install by default: - Signing key is pulled from the connected node via `export_private_key()`. - If private key export is disabled/blocked on firmware, auth-token upload cannot start. +Support for MQTT brokers that serve MQTT over a different path than / + +- Example: EMQX requires the path to be /mqtt + ## Map Auto Uploader (map.meshcore.io) When enabled (off by default), the integration automatically uploads repeater and room server adverts to [map.meshcore.io](https://map.meshcore.io) when your Companion hears them. A standalone alternative is [map.meshcore.io-uploader](https://github.com/recrof/map.meshcore.io-uploader). Enable in Global Settings if you want Map Auto Uploader. diff --git a/custom_components/meshcore/config_flow.py b/custom_components/meshcore/config_flow.py index 6f77580..62bf5db 100644 --- a/custom_components/meshcore/config_flow.py +++ b/custom_components/meshcore/config_flow.py @@ -1099,6 +1099,7 @@ async def async_step_mqtt_broker(self, user_input=None): "owner_email": user_input.get("owner_email", ""), "topic_status": user_input.get("topic_status", DEFAULT_MQTT_TOPIC_STATUS), "topic_events": user_input.get("topic_events", DEFAULT_MQTT_TOPIC_EVENTS), + "ws_path": user_input.get("ws_path", "/"), "iata": user_input.get("iata", legacy_global_iata), "token_ttl_seconds": user_input.get("token_ttl_seconds", legacy_global_ttl), "payload_mode": user_input.get("payload_mode", "packet"), @@ -1134,6 +1135,7 @@ async def async_step_mqtt_broker(self, user_input=None): ): vol.All(cv.positive_int, vol.Range(min=60, max=86400)), vol.Optional("topic_status", default=broker.get("topic_status", DEFAULT_MQTT_TOPIC_STATUS)): str, vol.Optional("topic_events", default=broker.get("topic_events", DEFAULT_MQTT_TOPIC_EVENTS)): str, + vol.Optional("ws_path", default=broker.get("ws_path", "/")): str, vol.Optional("iata", default=broker.get("iata", legacy_global_iata)): str, }) diff --git a/custom_components/meshcore/mqtt_uploader.py b/custom_components/meshcore/mqtt_uploader.py index b0d159f..56fdb19 100644 --- a/custom_components/meshcore/mqtt_uploader.py +++ b/custom_components/meshcore/mqtt_uploader.py @@ -74,6 +74,7 @@ class BrokerConfig: client_id_prefix: str topic_status: str topic_packets: str + ws_path: str = "/" @property def name(self) -> str: @@ -304,6 +305,9 @@ def _load_brokers(self) -> list[BrokerConfig]: ), iata, ), + ws_path=str( + broker_settings.get("ws_path", "/") or "/" + ).strip(), ) if broker.is_letsmesh and iata in placeholder_iata_values: @@ -426,7 +430,7 @@ async def _async_create_client(self, broker: BrokerConfig): ) if broker.transport == "websockets": - client.ws_set_options(path="/", headers=None) + client.ws_set_options(path=broker.ws_path, headers=None) self.logger.info( "[%s] Ready (status_topic=%s packets_topic=%s auth_token=%s)",