node-red-contrib-power-saver
Version:
A module for Node-RED that you can use to turn on and off a switch based on power prices
76 lines (71 loc) • 2.67 kB
HTML
<script type="text/javascript">
RED.nodes.registerType("ps-elvia-add-tariff", {
category: "Power Saver",
color: "#a6bbcf",
defaults: {
name: { value: "Add Elvia Grid Tariff" },
elviaConfig: { value: "", type: "ps-elvia-config" },
tariffKey: { value: "", required: true },
},
inputs: 1,
outputs: 1,
icon: "elvia_hvite.svg",
color: "#FFCC66",
label: function () {
return this.name || "Add Elvia Grid Tariff";
},
oneditprepare: function () {
const readTariffTypes = function () {
const configId = $("#node-input-elviaConfig").val();
if (configId === "_ADD_") {
$("#keyMessage").hide();
return;
}
$.getJSON("elvia-tariff-types?configId=" + configId, function (data) {
if (!data.tariffTypes) {
return;
}
$("#keyMessage").hide();
$("#node-input-tariffKey").typedInput({
types: [
{
value: "tariffkeys",
options: data.tariffTypes.map((k) => {
return { value: k.tariffKey, label: k.title };
}),
},
],
});
});
};
$("#node-input-elviaConfig").on("change", function () {
$("#keyMessage").show();
readTariffTypes();
});
readTariffTypes();
},
});
</script>
<script type="text/html" data-template-name="ps-elvia-add-tariff">
<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" style="width: 300px" />
</div>
<div class="form-row">
<label for="node-input-elviaConfig"><i class="fa fa-tag"></i> Elvia config</label>
<input type="text" id="node-input-elviaConfig" placeholder="Elvia config" style="width: 300px" />
</div>
<div class="form-row">
<label for="node-input-tariffKey"><i class="fa fa-tag"></i> Tariff key</label>
<input type="text" id="node-input-tariffKey" placeholder="Tariff" style="width: 300px" />
</div>
<div id="keyMessage" class="form-row">
<p>When Subscription key is set in the Elvia config,<br />you must deploy once to get the list of tariff keys.</p>
</div>
</script>
<script type="text/markdown" data-help-name="ps-elvia-add-tariff">
# Elvia Add Tariff
A node to get the tariff from Elvia and add it to the price before it is sent to the power saver strategy nodes.
Use this node between the receive-price node and any of the strategy nodes.
Please read more in the [node documentation](https://powersaver.no/nodes/ps-elvia-add-tariff)
</script>