UNPKG

node-red-contrib-smartnora

Version:

Google Smart Home integration via Smart Nora https://smart-nora.eu/

144 lines (142 loc) 5.45 kB
<script type="text/javascript"> RED.nodes.registerType('noraf-scene', { category: 'nora', color: 'rgb(235, 227, 141)', icon: 'assistant.png', defaults: { devicename: { value: 'Scene', required: true, }, roomhint: { value: '' }, scenereversible: { value: false, }, name: { value: '' }, nora: { type: 'noraf-config', required: true }, topic: { value: '' }, onvalue: { value: true, required: true, validate: (RED.validators.hasOwnProperty('typedInput') ? RED.validators.typedInput( 'onvalueType') : function (v) { return true }) }, onvalueType: { value: 'bool' }, offvalue: { value: false, required: true, validate: (RED.validators.hasOwnProperty('typedInput') ? RED.validators.typedInput( 'offvalueType') : function (v) { return true }) }, offvalueType: { value: 'bool' }, twofactor: { value: 'off', }, twofactorpin: { value: '' }, }, inputs: 0, outputs: 1, paletteLabel: 'scene', label: function () { return this.name || this.devicename || 'scene'; }, oneditprepare: function () { $('#node-input-onvalue').typedInput({ default: 'bool', typeField: $("#node-input-onvalueType"), types: ['str', 'num', 'bool', 'json', 'bin', 'date'] }); $('#node-input-offvalue').typedInput({ default: 'bool', typeField: $("#node-input-offvalueType"), types: ['str', 'num', 'bool', 'json', 'bin', 'date'] }); $('#node-input-scenereversible').change(function () { if (this.checked) { $('#deactivate-payload').show(); } else { $('#deactivate-payload').hide(); } }); $('#node-input-twofactor').change(function () { if ($(this).val() === 'pin') { $('#node-twofactor-pin').show(); } else { $('#node-twofactor-pin').hide(); } }); }, }); </script> <script type="text/x-red" data-template-name="noraf-scene"> <div class="form-row"> <label for="node-input-nora"><i class="fa fa-table"></i> Config</label> <input type="text" id="node-input-nora"> </div> <div class="form-row"> <label for="node-input-devicename"><i class="fa fa-i-cursor"></i> Scene</label> <input type="text" id="node-input-devicename"> </div> <div class="form-row"> <label style="width:auto" for="node-input-scenereversible"><i class="fa fa-arrow-right"></i> Scene reversible: </label> <input type="checkbox" id="node-input-scenereversible" style="display:inline-block; width:auto; vertical-align:top;"> </div> <div class="form-row"> <label for="node-input-onvalue" style="padding-left:25px; margin-right:-25px">Activate</label> <input type="text" id="node-input-onvalue" style="width:70%"> <input type="hidden" id="node-input-onvalueType"> </div> <div class="form-row" id="deactivate-payload"> <label for="node-input-offvalue" style="padding-left:25px; margin-right:-25px">Deactivate</label> <input type="text" id="node-input-offvalue" style="width:70%"> <input type="hidden" id="node-input-offvalueType"> </div> <div class="form-row"> <label for="node-input-roomhint"><i class="fa fa-i-cursor"></i> Room Hint</label> <input type="text" id="node-input-roomhint"> </div> <div class="form-row"> <label for="node-input-twofactor"><i class="fa fa-question-sign"></i> Two Factor</label> <select id="node-input-twofactor"> <option value="off">None</option> <option value="ack">Acknowledge</option> <option value="pin">Pin</option> </select> </div> <div id="node-twofactor-pin" class="form-row"> <label for="node-input-twofactorpin"><i class="fa fa-code"></i> Pin</label> <input type="text" id="node-input-twofactorpin"> </div> <div class="form-row"> <label for="node-input-topic" style="padding-left:25px; margin-right:-25px">Topic</label> <input type="text" id="node-input-topic"> </div> <div class="form-row"> <label for="node-input-name"><i class="fa fa-tag"></i> Name</label> <input type="text" id="node-input-name"> </div> </script> <script type="text/x-red" data-help-name="noraf-scene"> <p> <a href="https://github.com/andrei-tatar/node-red-contrib-smartnora/blob/master/doc/nodes/scene/README.md">https://github.com/andrei-tatar/node-red-contrib-smartnora/blob/master/doc/nodes/scene/README.md</a> </p> </script>