UNPKG

node-red-contrib-smartnora

Version:

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

202 lines (200 loc) 8.21 kB
<script type="text/javascript"> RED.nodes.registerType('noraf-lock', { category: 'nora', color: 'rgb(235, 227, 141)', icon: 'assistant.png', defaults: { devicename: { value: 'Lock', required: true, }, roomhint: { value: '' }, name: { value: '' }, passthru: { value: false, }, errorifstateunchaged: { value: false, }, nora: { type: 'noraf-config', required: true }, topic: { value: '' }, lockValue: { value: true, required: true, validate: (RED.validators.hasOwnProperty('typedInput') ? RED.validators.typedInput( 'lockValueType') : function (v) { return true }) }, lockValueType: { value: 'bool' }, unlockValue: { value: false, required: true, validate: (RED.validators.hasOwnProperty('typedInput') ? RED.validators.typedInput( 'unlockValueType') : function (v) { return true }) }, unlockValueType: { value: 'bool' }, jammedValue: { value: true, required: true, validate: (RED.validators.hasOwnProperty('typedInput') ? RED.validators.typedInput( 'jammedValueType') : function (v) { return true }) }, jammedValueType: { value: 'bool' }, unjammedValue: { value: false, required: true, validate: (RED.validators.hasOwnProperty('typedInput') ? RED.validators.typedInput( 'unjammedValueType') : function (v) { return true }) }, unjammedValueType: { value: 'bool' }, twofactor: { value: 'off', }, twofactorpin: { value: '' }, filter: { value: false, }, }, inputs: 1, outputs: 1, paletteLabel: 'lock', label: function () { return this.name || this.devicename || 'lock'; }, oneditprepare: function () { $('#node-input-lockValue').typedInput({ default: 'bool', typeField: $("#node-input-lockValueType"), types: ['str', 'num', 'bool', 'json', 'bin', 'date'] }); $('#node-input-unlockValue').typedInput({ default: 'bool', typeField: $("#node-input-unlockValueType"), types: ['str', 'num', 'bool', 'json', 'bin', 'date'] }); $('#node-input-jammedValue').typedInput({ default: 'bool', typeField: $("#node-input-jammedValueType"), types: ['str', 'num', 'bool', 'json', 'bin', 'date'] }); $('#node-input-unjammedValue').typedInput({ default: 'bool', typeField: $("#node-input-unjammedValueType"), types: ['str', 'num', 'bool', 'json', 'bin', 'date'] }); $('#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-lock"> <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 style="width:auto; font-weight: bold" >Google Device:</label> </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-devicename"><i class="fa fa-i-cursor"></i> Lock Name</label> <input type="text" id="node-input-devicename"> </div> <div class="form-row"> <label style="width:auto; font-weight: bold" >Message Payloads:</label> </div> <div class="form-row"> <label style="width:auto" for="node-input-passthru"><i class="fa fa-arrow-right"></i> If <code>msg</code> arrives on input, pass through to output: </label> <input type="checkbox" id="node-input-passthru" style="display:inline-block; width:auto; vertical-align:top;"> </div> <div class="form-row"> <label style="width:auto" for="node-input-filter"><i class="fa fa-filter"></i> Ignore input messages that don't match the <code>topic</code> value: </label> <input type="checkbox" id="node-input-filter" style="display:inline-block; width:auto; vertical-align:top;"> </div> <div class="form-row"> <label style="width:auto" for="node-input-errorifstateunchaged"><i class="fa fa-exclamation-triangle"></i> If state doesn't change via voice, warn user: </label> <input type="checkbox" id="node-input-errorifstateunchaged" style="display:inline-block; width:auto; vertical-align:top;"> </div> <div class="form-row"> <label for="node-input-lockValue" style="padding-left:20px; margin-right:-20px">Lock</label> <input type="text" id="node-input-lockValue" style="width:70%"> <input type="hidden" id="node-input-lockValueType"> </div> <div class="form-row"> <label for="node-input-unlockValue" style="padding-left:20px; margin-right:-20px">Unlock</label> <input type="text" id="node-input-unlockValue" style="width:70%"> <input type="hidden" id="node-input-unlockValueType"> </div> <div class="form-row"> <label style="width:auto", font-style: "italic" >Optional</label> </div> <div class="form-row"> <label for="node-input-jammedValue" style="padding-left:20px; margin-right:-20px">Jammed</label> <input type="text" id="node-input-jammedValue" style="width:70%"> <input type="hidden" id="node-input-jammedValueType"> </div> <div class="form-row"> <label for="node-input-unjammedValue" style="padding-left:20px; margin-right:-20px">Unjammed</label> <input type="text" id="node-input-unjammedValue" style="width:70%"> <input type="hidden" id="node-input-unjammedValueType"> </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:20px; margin-right:-20px" ><i class="fa fa-tasks"></i> Topic</label> <input type="text" id="node-input-topic" style="width:70%"> </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-lock"> <p> <a href="https://github.com/andrei-tatar/node-red-contrib-smartnora/blob/master/doc/nodes/lock/README.md">https://github.com/andrei-tatar/node-red-contrib-smartnora/blob/master/doc/nodes/lock/README.md</a> </p> </script>