UNPKG

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

147 lines (143 loc) 5.35 kB
<script type="text/javascript"> RED.nodes.registerType("ps-strategy-best-save", { category: "Power Saver", color: "#a6bbcf", defaults: { name: { value: "Best Save" }, maxHoursToSaveInSequence: { value: 3, required: true, validate: RED.validators.number(), }, minHoursOnAfterMaxSequenceSaved: { value: 2, required: true, validate: RED.validators.number(), }, minSaving: { value: 0.01, required: true, validate: RED.validators.number(), }, sendCurrentValueWhenRescheduling: { value: true, required: true, align: "left", }, outputValueForOn: { value: true, required: true, validate: RED.validators.typedInput("outputValueForOntype", false), }, outputValueForOff: { value: false, required: true, validate: RED.validators.typedInput("outputValueForOfftype", false), }, outputValueForOntype: { value: "bool", required: true, }, outputValueForOfftype: { value: "bool", required: true, }, outputIfNoSchedule: { value: "true", required: true, align: "left" }, contextStorage: { value: "default", required: false, align: "left" }, }, inputs: 1, outputs: 3, icon: "font-awesome/fa-bar-chart", color: "#FFCC66", label: function () { return this.name || "Best Save"; }, outputLabels: ["on", "off", "schedule"], oneditprepare: function () { $("#node-input-outputIfNoSchedule").typedInput({ types: [ { value: "onoff", options: [ { value: "true", label: "On" }, { value: "false", label: "Off" }, ], }, ], }); $("#node-input-contextStorage").typedInput({ types: [ { value: "storages", options: RED.settings.context.stores.map((s) => ({ value: s, label: s })), }, ], }); $("#node-input-outputValueForOn").typedInput({ default: "bool", typeField: $("#node-input-outputValueForOntype"), types: ["bool", "num", "str"], }); $("#node-input-outputValueForOff").typedInput({ default: "bool", typeField: $("#node-input-outputValueForOfftype"), types: ["bool", "num", "str"], }); }, }); </script> <script type="text/html" data-template-name="ps-strategy-best-save"> <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: 240px"> </div> <h3>Rules</h3> <div class="form-row"> <label for="node-input-maxHoursToSaveInSequence"><i class="fa fa-arrows-h"></i> Max per sequence</label> <input type="text" id="node-input-maxHoursToSaveInSequence" style="width: 80px" placeholder="Max hours to save in sequence"> </div> <div class="form-row"> <label for="node-input-minHoursOnAfterMaxSequenceSaved"><i class="fa fa-ellipsis-h"></i> Min recover</label> <input type="text" id="node-input-minHoursOnAfterMaxSequenceSaved" style="width: 80px" placeholder="Min hours on after a max sequence"> </div> <div class="form-row"> <label for="node-input-minSaving"><i class="fa fa-eur"></i> Min saving</label> <input type="text" id="node-input-minSaving" placeholder="Minimum to save for turning off" style="width: 80px"> </div> <h3>Output</h3> <div class="form-row"> <div class="form-row"> <label for="node-input-outputValueForOn">Output value for on</label> <input type="text" id="node-input-outputValueForOn" style="text-align: left; width: 120px"> <input type="hidden" id="node-input-outputValueForOntype"> </div> <div class="form-row"> <label for="node-input-outputValueForOff">Output value for off</label> <input type="text" id="node-input-outputValueForOff" style="text-align: left; width: 120px"> <input type="hidden" id="node-input-outputValueForOfftype"> </div> <label for="node-input-sendCurrentValueWhenRescheduling" style="width:240px"> <input type="checkbox" id="node-input-sendCurrentValueWhenRescheduling" style="display:inline-block; width:22px; vertical-align:top;" autocomplete="off"><span>Send when rescheduling</span> </label> </div> <div class="form-row"> <label for="node-input-outputIfNoSchedule">If no schedule, send</label> <input type="text" id="node-input-outputIfNoSchedule" style="width: 80px"> </label> </div> <h3>Context storage</h3> <div class="form-row"> <label for="node-input-contextStorage"><i class="fa fa-archive"></i> Context storage</label> <input type="text" id="node-input-contextStorage" style="width: 160px"> </div> </script> <script type="text/markdown" data-help-name="ps-strategy-best-save"> A node you can use to save money by turning off and on a switch based on power prices. Please read more in the [node documentation](https://powersaver.no/nodes/ps-strategy-best-save) </script>