UNPKG

node-red-contrib-tibber-api

Version:

Node Red module for integrating with Tibber api

252 lines (246 loc) 11.7 kB
<script type="text/javascript"> RED.nodes.registerType('tibber-feed', { category: 'Tibber API', color: '#23B8CC', defaults: { name: { value: '', }, active: { value: true, }, apiEndpointRef: { value: null, type: 'tibber-api-endpoint' }, homeId: { value: '', required: true, validate: function (v) { if (v === '') { return false; } return true; }, }, timestamp: { value: '1', }, power: { value: '1', }, lastMeterConsumption: { value: '1', }, accumulatedConsumption: { value: '1', }, accumulatedProduction: { value: '1', }, accumulatedConsumptionLastHour: { value: '1', }, accumulatedProductionLastHour: { value: '1', }, accumulatedCost: { value: '1', }, accumulatedReward: { value: '1', }, currency: { value: '1', }, minPower: { value: '1', }, averagePower: { value: '1', }, maxPower: { value: '1', }, powerProduction: { value: '1', }, minPowerProduction: { value: '1', }, maxPowerProduction: { value: '1', }, lastMeterProduction: { value: '1', }, powerFactor: { value: '1', }, voltagePhase1: { value: '1', }, voltagePhase2: { value: '1', }, voltagePhase3: { value: '1', }, currentL1: { value: '1', }, currentL2: { value: '1', }, currentL3: { value: '1', }, signalStrength: { value: '1', }, reconnectDelay: { value: 5000, type: 'number', }, }, inputs: 0, outputs: 1, icon: 'feed.png', label: function () { return this.name || 'tibber-feed'; }, // Use function and not arrow function to access the correct context oneditprepare: function () { // Set the default value for the reconnectDelay input field if (!this.reconnectDelay) { $("#node-input-reconnectDelay").val(5000); } $("#node-input-reconnectDelay").typedInput({ type:"num", }) }, }); </script> <script type="text/x-red" data-template-name="tibber-feed"> <div class="form-row" style="white-space: nowrap;"> <label style="white-space: nowrap;" for="node-input-active"><i class="icon-tag"></i> Active</label> <input type="checkbox" id="node-input-active" value="1"> </div> <div class="form-row" style="white-space: nowrap;"> <label style="white-space: nowrap; width: 120px;" for="node-input-apiEndpointRef"><i class="icon-tag"></i> API Endpoint</label> <input type="text" id="node-input-apiEndpointRef" placeholder="API Endpoint"> </div> <div class="form-row" style="white-space: nowrap;"> <label style="white-space: nowrap; width: 120px;" for="node-input-homeId"><i class="icon-tag"></i> Home id</label> <input type="text" id="node-input-homeId" placeholder="Home id"> </div> <div class="form-row" style="white-space: nowrap;"> <label style="white-space: nowrap; width: 120px;" for="node-input-name"><i class="icon-tag"></i> Name</label> <input type="text" id="node-input-name" placeholder="Name"> </div> <div class="form-row" style="white-space: nowrap;"> <label style="white-space: nowrap; width: 120px;" for="node-input-reconnectDelay"><i class="icon-tag"></i> Reconnect delay</label> <input type="text" id="node-input-reconnectDelay" placeholder="Delay (ms)" style="width: 100px;"><span> ms</span> </div> <hr> <div class="form-row" style="white-space: nowrap;"> <label style="white-space: nowrap;" for="node-input-timestamp"><i class="icon-tag"></i> Timestamp</label> <input type="checkbox" id="node-input-timestamp" value="1"> </div> <div class="form-row" style="white-space: nowrap;"> <label style="white-space: nowrap;" for="node-input-power"><i class="icon-tag"></i> Power</label> <input type="checkbox" id="node-input-power" value="1"> </div> <div class="form-row" style="white-space: nowrap;"> <label style="white-space: nowrap;" for="node-input-lastMeterConsumption"><i class="icon-tag"></i> Last meter consumption</label> <input type="checkbox" id="node-input-lastMeterConsumption" value="1"> </div> <div class="form-row" style="white-space: nowrap;"> <label style="white-space: nowrap;" for="node-input-accumulatedConsumption"><i class="icon-tag"></i> Accumulated consumption</label> <input type="checkbox" id="node-input-accumulatedConsumption" value="1"> </div> <div class="form-row" style="white-space: nowrap;"> <label style="white-space: nowrap;" for="node-input-accumulatedProduction"><i class="icon-tag"></i> Accumulated production</label> <input type="checkbox" id="node-input-accumulatedProduction" value="1"> </div> <div class="form-row" style="white-space: nowrap;"> <label style="white-space: nowrap;" for="node-input-accumulatedConsumptionLastHour"><i class="icon-tag"></i> Accumulated consumption last hour</label> <input type="checkbox" id="node-input-accumulatedConsumptionLastHour" value="1"> </div> <div class="form-row" style="white-space: nowrap;"> <label style="white-space: nowrap;" for="node-input-accumulatedProductionLastHour"><i class="icon-tag"></i> Accumulated production last hour</label> <input type="checkbox" id="node-input-accumulatedProductionLastHour" value="1"> </div> <div class="form-row" style="white-space: nowrap;"> <label style="white-space: nowrap;" for="node-input-accumulatedCost"><i class="icon-tag"></i> Accumulated cost</label> <input type="checkbox" id="node-input-accumulatedCost" value="1"> </div> <div class="form-row" style="white-space: nowrap;"> <label style="white-space: nowrap;" for="node-input-accumulatedReward"><i class="icon-tag"></i> Accumulated reward</label> <input type="checkbox" id="node-input-accumulatedReward" value="1"> </div> <div class="form-row" style="white-space: nowrap;"> <label style="white-space: nowrap;" for="node-input-currency"><i class="icon-tag"></i> Currency</label> <input type="checkbox" id="node-input-currency" value="1"> </div> <div class="form-row" style="white-space: nowrap;"> <label style="white-space: nowrap;" for="node-input-minPower"><i class="icon-tag"></i> Min power</label> <input type="checkbox" id="node-input-minPower" value="1"> </div> <div class="form-row" style="white-space: nowrap;"> <label style="white-space: nowrap;" for="node-input-averagePower"><i class="icon-tag"></i> Average power</label> <input type="checkbox" id="node-input-averagePower" value="1"> </div> <div class="form-row" style="white-space: nowrap;"> <label style="white-space: nowrap;" for="node-input-maxPower"><i class="icon-tag"></i> Max power</label> <input type="checkbox" id="node-input-maxPower" value="1"> </div> <div class="form-row" style="white-space: nowrap;"> <label style="white-space: nowrap;" for="node-input-powerProduction"><i class="icon-tag"></i> Power production</label> <input type="checkbox" id="node-input-powerProduction" value="1"> </div> <div class="form-row" style="white-space: nowrap;"> <label style="white-space: nowrap;" for="node-input-minPowerProduction"><i class="icon-tag"></i> Min power production</label> <input type="checkbox" id="node-input-minPowerProduction" value="1"> </div> <div class="form-row" style="white-space: nowrap;"> <label style="white-space: nowrap;" for="node-input-maxPowerProduction"><i class="icon-tag"></i> Max power production</label> <input type="checkbox" id="node-input-maxPowerProduction" value="1"> </div> <div class="form-row" style="white-space: nowrap;"> <label style="white-space: nowrap;" for="node-input-lastMeterProduction"><i class="icon-tag"></i> Last meter production</label> <input type="checkbox" id="node-input-lastMeterProduction" value="1"> </div> <div class="form-row" style="white-space: nowrap;"> <label style="white-space: nowrap;" for="node-input-powerFactor"><i class="icon-tag"></i> Power factor</label> <input type="checkbox" id="node-input-powerFactor" value="1"> </div> <div class="form-row" style="white-space: nowrap;"> <label style="white-space: nowrap;" for="node-input-voltagePhase1"><i class="icon-tag"></i> Voltage phase 1</label> <input type="checkbox" id="node-input-voltagePhase1" value="1"> </div> <div class="form-row" style="white-space: nowrap;"> <label style="white-space: nowrap;" for="node-input-voltagePhase2"><i class="icon-tag"></i> Voltage phase 2</label> <input type="checkbox" id="node-input-voltagePhase2" value="1"> </div> <div class="form-row" style="white-space: nowrap;"> <label style="white-space: nowrap;" for="node-input-voltagePhase3"><i class="icon-tag"></i> Voltage phase 3</label> <input type="checkbox" id="node-input-voltagePhase3" value="1"> </div> <div class="form-row" style="white-space: nowrap;"> <label style="white-space: nowrap;" for="node-input-currentL1"><i class="icon-tag"></i> Current L1</label> <input type="checkbox" id="node-input-currentL1" value="1"> </div> <div class="form-row" style="white-space: nowrap;"> <label style="white-space: nowrap;" for="node-input-currentL2"><i class="icon-tag"></i> Current L2</label> <input type="checkbox" id="node-input-currentL2" value="1"> </div> <div class="form-row" style="white-space: nowrap;"> <label style="white-space: nowrap;" for="node-input-currentL3"><i class="icon-tag"></i> Current L3</label> <input type="checkbox" id="node-input-currentL3" value="1"> </div> <div class="form-row" style="white-space: nowrap;"> <label style="white-space: nowrap;" for="node-input-signalStrength"><i class="icon-tag"></i> Signal strength</label> <input type="checkbox" id="node-input-signalStrength" value="1"> </div> </script> <script type="text/x-red" data-help-name="tibber-api"> <p>A simple node that enables you to stream realtime data from tibber.</p> </script>