|
17 | 17 | "stack_fqdn": "", |
18 | 18 | "https_port": 555, |
19 | 19 | "mqtt_tls_port": 8881, |
| 20 | + "advertised_https_port": 0, |
| 21 | + "advertised_mqtt_tls_port": 0, |
20 | 22 | "region": "us", |
21 | 23 | "tls_mode": "provided", |
22 | 24 | "tls_base_domain": "", |
@@ -85,6 +87,12 @@ def _as_int(value: object, *, field_name: str, default: int) -> int: |
85 | 87 | return candidate |
86 | 88 |
|
87 | 89 |
|
| 90 | +def _as_optional_port(value: object, *, field_name: str) -> int: |
| 91 | + if value in (None, "", 0, "0"): |
| 92 | + return 0 |
| 93 | + return _as_int(value, field_name=field_name, default=0) |
| 94 | + |
| 95 | + |
88 | 96 | def _require_non_empty(value: object, *, field_name: str) -> str: |
89 | 97 | text = str(value or "").strip() |
90 | 98 | if not text: |
@@ -158,6 +166,16 @@ def _render_config_toml( |
158 | 166 | raise ValueError("listener_mode='external_tls' is no longer supported") |
159 | 167 | https_port = _as_int(merged.get("https_port"), field_name="https_port", default=555) |
160 | 168 | mqtt_tls_port = _as_int(merged.get("mqtt_tls_port"), field_name="mqtt_tls_port", default=8881) |
| 169 | + advertised_https_port = _as_optional_port( |
| 170 | + merged.get("advertised_https_port"), |
| 171 | + field_name="advertised_https_port", |
| 172 | + ) |
| 173 | + advertised_mqtt_tls_port = _as_optional_port( |
| 174 | + merged.get("advertised_mqtt_tls_port"), |
| 175 | + field_name="advertised_mqtt_tls_port", |
| 176 | + ) |
| 177 | + advertised_https_port = advertised_https_port or https_port |
| 178 | + advertised_mqtt_tls_port = advertised_mqtt_tls_port or mqtt_tls_port |
161 | 179 |
|
162 | 180 | # Legacy HA options for broker selection are ignored now that the add-on |
163 | 181 | # always runs the embedded broker with the topic bridge enabled. |
@@ -218,6 +236,8 @@ def _render_config_toml( |
218 | 236 | 'bind_host = "0.0.0.0"', |
219 | 237 | f"https_port = {https_port}", |
220 | 238 | f"mqtt_tls_port = {mqtt_tls_port}", |
| 239 | + f"advertised_https_port = {advertised_https_port}", |
| 240 | + f"advertised_mqtt_tls_port = {advertised_mqtt_tls_port}", |
221 | 241 | f"region = {_toml_string(region)}", |
222 | 242 | "", |
223 | 243 | "[broker]", |
|
0 commit comments