Skip to content

Commit

Permalink
Add option for adding newline to serial output from controller
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Bowman Mørch committed Jun 1, 2023
1 parent fa41d04 commit c79c651
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 24 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"author": {
"name": "Thomas Bowman Mørch"
},
"version": "4.1.0",
"version": "4.2.0",
"engines": {
"node": ">=16.0.0"
},
Expand Down
48 changes: 39 additions & 9 deletions src/nodes/controller.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
});
</script>

<script type="text/x-red" data-template-name="myscontroller">
<script type="text/html" data-template-name="myscontroller">
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
Expand All @@ -64,8 +64,13 @@
<input type="text" id="node-input-database" placeholder="Database">
</div>
<div class="form-row">
<label for="node-input-handleid"> Handle IDs</label>
<input type="checkbox" id="node-input-handleid">
<label><i class="fa fa-cog"></i> Options</label>
<div style="display:inline-block;" class="mysensor-options">
<div>
<label><input type="checkbox" id="node-input-handleid"> Handle IDs</label>
<label><input type="checkbox" id="node-input-addSerialNewline"> Add newline to MySerial encoded output</label>
</div>
</div>
</div>
<div class="form-row">
<label for="node-input-measurementsystem">Units</label>
Expand Down Expand Up @@ -672,13 +677,9 @@
</select>
</div>
<div class="form-tips">Timezone is used to set the timezone on I_TIME messages sent to a node, requesting time</div>
<div class="form-row">
<label for="node-input-addSerialNewline">Add newline to mysensors serial protocol output</label>
<input type="checkbox" id="node-input-add-newline">
</div>
<div class="form-row">
<label><i class="fa fa-book"></i> List of nodes</label>
<table border="1px" style="width:100%">
<table class="node-table">
<thead>
<tr>
<th>id</th>
Expand All @@ -695,7 +696,7 @@
</div>
</script>

<script type="text/x-red" data-help-name="myscontroller">
<script type="text/html" data-help-name="myscontroller">
<p>Controller node for mysensors network. It is capable of keeping track of used node IDs, and can hand out ned node IDs upon request from new nodes</p>

<h3>Input</h3>
Expand Down Expand Up @@ -723,10 +724,39 @@ <h3>Details</h3>
<dd>Sends a node ID if 'Handle IDs' is checked</dd>
</dl>
Output message is using the same format at incomming, so can be sent directly back into the mysensors network (Serial/MQTT)

If <code>Add newline to MySerial encoded output</code> is checked, then a newline is added when sending a serial type message.
</p>
<p>
The node collects data about nodes that it hears on the mysensors network, such as nodeID, sketchname, timestamp for when it was heard last etc.

the current list of nodes will be shown in the configuration panel of the controller node
</p>
</script>

<style>
.node-table {
border: 1px solid;
width: 100%;
}

.node-table th, .node-table td {
border: 1px solid;
}

.mysensor-options label {
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
vertical-align: baseline;
width: 120px !important;
white-space: nowrap;
}

.mysensor-options input {
width: auto !important;
vertical-align: baseline !important;
}
</style>
4 changes: 2 additions & 2 deletions src/nodes/decode.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
});
</script>

<script type="text/x-red" data-template-name="mysdecode">
<script type="text/html" data-template-name="mysdecode">
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
Expand All @@ -55,7 +55,7 @@
</div>
</script>

<script type="text/x-red" data-help-name="mysdecode">
<script type="text/html" data-help-name="mysdecode">
<p>
Parses either <code>msg.payload</code> from mysensors serial format, or <code>msg.topic</code> if MQTT type is chosen
</p>
Expand Down
17 changes: 11 additions & 6 deletions src/nodes/encapsulate.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<script type="text/x-red" data-template-name="mysencap">
<script type="text/html" data-template-name="mysencap">
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
Expand Down Expand Up @@ -71,7 +71,7 @@
<input type="text" id="node-input-firmwareversion">
</div>
</script>
<script type="text/x-red" data-help-name="mysencap">
<script type="text/html" data-help-name="mysencap">
<p>
Adds extra propperties to the message object, so it conforms to mysensor data. Send the resulting message through mysencode to convert
into mysensors serial / mqtt topic format, that can be sent to either a mysensors node, or sent to another controller that understands
Expand Down Expand Up @@ -209,19 +209,24 @@ <h3>References</h3>
var options = $('#'+selectTag+' option');
var arr = options.map(function(_, o) { return { t:
$(o).text(), v: o.value }; }).get();
arr.sort(function(o1, o2) { return o1.t > o2.t ? 1 : o1.t <
o2.t ? -1 : 0; });
arr.sort((o1, o2) => {
if (o1.t > o2.t) {
return 1;
}
if (o1.t < o2.t) {
return -1;
}
return 0;
});
options.each(function(i, o) {
o.value = arr[i].v;
$(o).text(arr[i].t);
// if (parseInt(arr[i].v) == parseInt(selected)) $(o).prop('selected',true);
});
$('#'+selectTag).val(selected);
}

function loadJsonTypes(type, selectId, selection) {
$.getJSON('mysensordefs/'+type, function(data) {
var index;
var html = '';
data = JSON.parse(data);
Object.keys(data).forEach((item) => {
Expand Down
4 changes: 2 additions & 2 deletions src/nodes/encode.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
});
</script>

<script type="text/x-red" data-template-name="mysencode">
<script type="text/html" data-template-name="mysencode">
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
Expand All @@ -56,7 +56,7 @@
</div>
</script>

<script type="text/x-red" data-help-name="mysencode">
<script type="text/html" data-help-name="mysencode">
<p>
Encodes messages into mysensors serial / mqtt topic compatible messages, that can be sent to either a gateway,
or a controller that understands mysensors serial protocol or mqtt topic format.
Expand Down
4 changes: 2 additions & 2 deletions src/nodes/mysdebug.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
});
</script>

<script type="text/x-red" data-template-name="mysdebug">
<script type="text/html" data-template-name="mysdebug">
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
</script>

<script type="text/x-red" data-help-name="mysdebug">
<script type="text/html" data-help-name="mysdebug">
<p>
Parses the payload of a mysensors debug message, and outputs a nicely formatted <code>msg.payload</code> usefull
for debugging the protocoll. Also, strips debug header from the payload, in case of debug string from GW
Expand Down
4 changes: 2 additions & 2 deletions src/nodes/mysensors-db.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<script type="text/x-red" data-template-name="mysensorsdb">
<script type="text/html" data-template-name="mysensorsdb">
<div class="form-row">
<label for="node-config-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-config-input-name" placeholder="Name" />
Expand All @@ -9,7 +9,7 @@
</div>
</script>

<script type="text/x-red" data-help-name="mysensorsdb">
<script type="text/html" data-help-name="mysensorsdb">
<p>
Storage for mysensors ID table, enter which context variable you want to store in,
it should probably be global and setup a persistent context store, so you do not
Expand Down

0 comments on commit c79c651

Please sign in to comment.