|
@@ -109,7 +109,6 @@ class ZLockSlotsCard extends HTMLElement {
|
|
|
<div class="pending-indicator" id="pending-indicator"><ha-icon icon="mdi:loading"></ha-icon></div>
|
|
<div class="pending-indicator" id="pending-indicator"><ha-icon icon="mdi:loading"></ha-icon></div>
|
|
|
<div class="card-content">
|
|
<div class="card-content">
|
|
|
<div class="section">
|
|
<div class="section">
|
|
|
- <h3>Active code slots</h3>
|
|
|
|
|
${slots.length === 0
|
|
${slots.length === 0
|
|
|
? '<div class="empty-note">No active code slots.</div>'
|
|
? '<div class="empty-note">No active code slots.</div>'
|
|
|
: `<table>
|
|
: `<table>
|
|
@@ -143,7 +142,7 @@ class ZLockSlotsCard extends HTMLElement {
|
|
|
<td colspan="3">
|
|
<td colspan="3">
|
|
|
<div class="pin-edit">
|
|
<div class="pin-edit">
|
|
|
<label>New PIN</label>
|
|
<label>New PIN</label>
|
|
|
- <input id="pin-input-${s.slot_num}" type="password" minlength="4" maxlength="8" autocomplete="new-password" placeholder="4–8 digits — Enter to save, Esc to cancel" data-slot="${s.slot_num}" data-type="pin" />
|
|
|
|
|
|
|
+ <input id="pin-input-${s.slot_num}" type="password" minlength="4" maxlength="8" autocomplete="one-time-code" placeholder="4–8 digits — Enter to save, Esc to cancel" data-slot="${s.slot_num}" data-type="pin" />
|
|
|
</div>
|
|
</div>
|
|
|
</td>
|
|
</td>
|
|
|
</tr>
|
|
</tr>
|
|
@@ -154,17 +153,16 @@ class ZLockSlotsCard extends HTMLElement {
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
<div class="section">
|
|
<div class="section">
|
|
|
- <h3>Add / overwrite slot</h3>
|
|
|
|
|
<div class="form-row-inline">
|
|
<div class="form-row-inline">
|
|
|
<div class="field slot">
|
|
<div class="field slot">
|
|
|
<label>Slot #</label>
|
|
<label>Slot #</label>
|
|
|
- <input id="add-slot" type="number" min="1" max="999" placeholder="—" />
|
|
|
|
|
|
|
+ <input id="add-slot" type="number" min="1" max="999" placeholder="auto" />
|
|
|
</div>
|
|
</div>
|
|
|
<div class="field pin">
|
|
<div class="field pin">
|
|
|
<label>PIN</label>
|
|
<label>PIN</label>
|
|
|
- <input id="add-code" type="password" minlength="4" maxlength="8" autocomplete="new-password" placeholder="4–8 digits" />
|
|
|
|
|
|
|
+ <input id="add-code" type="password" minlength="4" maxlength="8" autocomplete="one-time-code" placeholder="4–8 digits" />
|
|
|
</div>
|
|
</div>
|
|
|
- <button class="action" id="add-btn">Set code</button>
|
|
|
|
|
|
|
+ <button class="action" id="add-btn">Set</button>
|
|
|
</div>
|
|
</div>
|
|
|
<span id="add-status" style="font-size:0.85rem;opacity:0.7"></span>
|
|
<span id="add-status" style="font-size:0.85rem;opacity:0.7"></span>
|
|
|
</div>
|
|
</div>
|
|
@@ -252,15 +250,17 @@ class ZLockSlotsCard extends HTMLElement {
|
|
|
const codeInput = root.getElementById("add-code");
|
|
const codeInput = root.getElementById("add-code");
|
|
|
const status = root.getElementById("add-status");
|
|
const status = root.getElementById("add-status");
|
|
|
|
|
|
|
|
- const slot = parseInt(slotInput.value, 10);
|
|
|
|
|
|
|
+ const slotVal = slotInput.value ? parseInt(slotInput.value, 10) : undefined;
|
|
|
const code = codeInput.value.trim();
|
|
const code = codeInput.value.trim();
|
|
|
|
|
|
|
|
- if (!slot || slot < 1) { status.textContent = "Enter a valid slot number."; return; }
|
|
|
|
|
|
|
+ if (slotVal !== undefined && slotVal < 1) { status.textContent = "Slot must be 1 or higher."; return; }
|
|
|
if (code.length < 4 || code.length > 8) { status.textContent = "PIN must be 4–8 digits."; return; }
|
|
if (code.length < 4 || code.length > 8) { status.textContent = "PIN must be 4–8 digits."; return; }
|
|
|
|
|
|
|
|
status.textContent = "";
|
|
status.textContent = "";
|
|
|
try {
|
|
try {
|
|
|
- await this._callService("set_code", { lock_entity_id: lock, slot, code });
|
|
|
|
|
|
|
+ const data = { lock_entity_id: lock, code };
|
|
|
|
|
+ if (slotVal !== undefined) data.slot = slotVal;
|
|
|
|
|
+ await this._callService("set_code", data);
|
|
|
slotInput.value = "";
|
|
slotInput.value = "";
|
|
|
codeInput.value = "";
|
|
codeInput.value = "";
|
|
|
} catch (err) {
|
|
} catch (err) {
|