@edgepi-cloud/node-red-edgepi-thermocouple
Version:
A node-red node for EdgePi thermocouple module
131 lines (121 loc) • 3.43 kB
HTML
<script type="text/javascript">
RED.nodes.registerType("thermocouple", {
category: "EdgePi",
color: "#f391aa",
defaults: {
name: { value: "" },
transport: { value: "Local" },
tcpAddress: { value: "" },
tcpPort: { value: "" },
},
inputs: 1,
outputs: 1,
icon: "font-awesome/fa-thermometer-2",
label: function () {
return this.name || "thermocouple";
},
oneditprepare: function () {
const transportType = document.getElementById("node-input-transport");
const tcpTransportInputs = document.querySelector(".form-row.tcp");
function updateEditor() {
if (transportType.value === "Network") {
tcpTransportInputs.style.display = "flex";
} else {
tcpTransportInputs.style.display = "none";
}
}
updateEditor();
transportType.addEventListener("change", updateEditor);
},
});
</script>
<script type="text/html" data-template-name="thermocouple">
<style>
* {
box-sizing: border-box ;
}
.form-row {
display: flex;
align-items: center;
}
.form-row > label {
margin-top: auto;
margin-bottom: auto;
}
.form-row.tcp {
flex-direction: row;
align-items: center;
margin-top: -5px;
margin-bottom: 10px;
}
.tcp-address-input {
width: 160px ;
margin-left: 100px ;
}
.tcp-port-input {
width: 60px ;
}
.tcp-port-label {
width: 5px ;
margin: auto 5px;
}
</style>
<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>
<div class="form-row transport">
<label for="node-input-transport">RPC Server:</label>
<select id="node-input-transport">
<option value="Local">Local</option>
<option value="Network">Network</option>
</select>
</div>
<div class="form-row tcp">
<input
class="tcp-address-input"
type="text"
id="node-input-tcpAddress"
placeholder="IP Address/ Hostname"
/>
<label class="tcp-port-label" for="node-input-tcpPort">:</label>
<input
class="tcp-port-input"
type="text"
id="node-input-tcpPort"
placeholder="Port"
/>
</div>
</script>
<script type="text/html" data-help-name="thermocouple">
<p>Reads the temperature from a thermocouple connected to the EdgePi.</p>
<h3>Properties</h3>
<dl class="message-properties">
<dt>RPC Server</dt>
<dd>
The connection to your EdgePi's RPC Server. Use <strong>Local</strong> if
node-red is running on EdgePi. Otherwise use the
<strong>Network</strong> option and enter EdgePi's IP address / Hostname.
</dd>
<dt>Output</dt>
<dd>What temperature reading(s) will be be sent out through the flow.</dd>
</dl>
<h3>Inputs</h3>
<dl class="message-properties">
<dd>Any message can be used to trigger this node.</dd>
</dl>
<h3>Outputs</h3>
<dl class="message-properties">
<dt>payload <span class="property-type">number</span></dt>
<dd>TC temperature reading.</dd>
</dl>
<h3>References</h3>
<ul>
<li>
<a href="https://github.com/edgepi-cloud/node-red-edgepi-thermocouple"
>GitHub</a
>
-the node's github repository
</li>
</ul>
</script>