mqtt: settings refactoring & custom topics

- customize will topic qos and retain, ref. #2616
- allow to fully replace will and json topics.
  empty string means the default <root>/<name>
  replacement is taken as-is, after applying placeholders
- validate will and data topic structure before connecting
- validate {suf,post}fix as {suf,post}fix, not as topic
This commit is contained in:
Maxim Prokhorov
2024-09-08 01:09:51 +03:00
parent 919d348199
commit 1f93ce4f29
4 changed files with 376 additions and 153 deletions

View File

@@ -106,6 +106,42 @@
</div>
</fieldset>
<fieldset>
<legend>Status &amp; Will</legend>
<div class="pure-control-group">
<label>Topic</label>
<input name="mqttWill" type="text" >
<span class="pure-form-message">
Status payload will be sent to this topic. When empty, defaults to <strong>&lt;root&gt;/&lt;status&gt;</strong>
</span>
</div>
<div class="pure-control-group">
<label>Retain flag</label>
<input class="checkbox-toggle" type="checkbox" name="mqttWillRetain">
</div>
<div class="pure-control-group">
<label>QoS</label>
<select class="pure-input-2-3" name="mqttWillQoS">
<option value="0">0: At most once</option>
<option value="1">1: At least once</option>
<option value="2">2: Exactly once</option>
</select>
</div>
<div class="pure-control-group">
<label>Online payload</label>
<input name="mqttPayloadOnline" type="text" required >
</div>
<div class="pure-control-group">
<label>Offline payload</label>
<input name="mqttPayloadOffline" type="text" required >
</div>
</fieldset>
<fieldset>
<legend>JSON</legend>
@@ -120,10 +156,10 @@
</div>
<div class="pure-control-group">
<label>Topic name</label>
<input type="text" name="mqttJson" required >
<label>Topic</label>
<input type="text" name="mqttJson" >
<span class="pure-form-message">
JSON message will be sent to <strong>&lt;root&gt;/&lt;name&gt;</strong> topic (<strong>data</strong> by default).
JSON message will be sent to this topic. When empty, defaults to <strong>&lt;root&gt;/&lt;data&gt;</strong>
</span>
</div>