feat: add scoped user accounts, password login and garden paving materials
This commit is contained in:
1 parent
c56f1a5ba9
commit
1d67e8ceba
43 files changed
+2024
-625
No files matched your search
@@ -1,6 +1,7 @@
|
||||
// Lit wrapper around the lazily loaded 3D viewer.
|
||||
|
||||
import { changeMoments, hassAt, loadHistory, replayable, type History } from "../live/time-travel.ts";
|
||||
import { canControl } from "../access.ts";
|
||||
import { sunPosition, todayAt } from "../sun-position.ts";
|
||||
import { dayCurves, statesRead, type DayCurves } from "../live/day-curves.ts";
|
||||
import { backdropStyle } from "../backdrop.ts";
|
||||
@@ -1070,7 +1071,7 @@ export class NfView3d extends LitElement {
|
||||
private jumpTo(a: Alert): void {
|
||||
// an own warning: its details, or what was chosen for it (switch the entity, go to its room)
|
||||
if (a.kind === "own" && a.tap !== "room") {
|
||||
if (a.tap === "toggle") void this.hass.callService("homeassistant", "toggle", { entity_id: a.entity });
|
||||
if (a.tap === "toggle" && canControl(this.hass, a.entity)) void this.hass.callService("homeassistant", "toggle", { entity_id: a.entity });
|
||||
else openMoreInfo(this, a.entity);
|
||||
return;
|
||||
}
|
||||
@@ -1091,7 +1092,7 @@ export class NfView3d extends LitElement {
|
||||
const room = floor?.rooms.find((r) => r.id === roomId);
|
||||
if (!b || !hass || !floor || !room) return;
|
||||
const mode = roomToggleMode(b.settings.room_double_tap, this.roomDoubleTap);
|
||||
const lights = roomToggleLights(hass, floor, room, this.furnitureLinks, this.confirmSet, mode);
|
||||
const lights = roomToggleLights(hass, floor, room, this.furnitureLinks, this.confirmSet, mode).filter((id) => canControl(hass, id));
|
||||
if (!lights.length) return;
|
||||
const anyOn = lights.some((id) => hass.states[id]?.state === "on");
|
||||
void hass.callService("homeassistant", anyOn ? "turn_off" : "turn_on", { entity_id: lights });
|
||||
@@ -1104,6 +1105,7 @@ export class NfView3d extends LitElement {
|
||||
}
|
||||
|
||||
private runScene(id: string): void {
|
||||
if (!canControl(this.hass, id)) return;
|
||||
void this.hass.callService(id.split(".")[0], "turn_on", { entity_id: id });
|
||||
this._sceneFired = id;
|
||||
setTimeout(() => (this._sceneFired = null), 600);
|
||||
@@ -1802,7 +1804,7 @@ export class NfView3d extends LitElement {
|
||||
const st = this.hass?.states[entityId];
|
||||
if (phase === "start") {
|
||||
// devices that ask before switching are not moved by a swipe (it turns the view instead)
|
||||
if (!st || isUnavailable(st) || this.confirmSet.has(entityId)) return false;
|
||||
if (!st || isUnavailable(st) || !canControl(this.hass, entityId) || this.confirmSet.has(entityId)) return false;
|
||||
const kind = kindOf(entityId);
|
||||
if (kind === "light" && lightAbilities(st).dim) {
|
||||
const pct = st.state === "on" ? (typeof st.attributes.brightness === "number" ? Math.round((st.attributes.brightness as number) / 2.55) : 100) : 0;
|
||||
@@ -1843,6 +1845,7 @@ export class NfView3d extends LitElement {
|
||||
}
|
||||
|
||||
private applySwipe(): void {
|
||||
if (this._swipe && !canControl(this.hass, this._swipe.entity)) return;
|
||||
const s = this._swipe;
|
||||
if (!s || !this.hass) return;
|
||||
if (s.kind === "light") {
|
||||
@@ -2002,8 +2005,8 @@ export class NfView3d extends LitElement {
|
||||
if (!this._central) return star;
|
||||
const floor = this.floorId ? b.floors.find((f) => f.id === this.floorId) : undefined;
|
||||
const floors = floor ? [floor] : b.floors;
|
||||
const lights = floors.flatMap((f) => floorControls(hass, f).lights);
|
||||
const covers = floors.flatMap((f) => floorControls(hass, f).covers);
|
||||
const lights = floors.flatMap((f) => floorControls(hass, f).lights).filter((id) => canControl(hass, id));
|
||||
const covers = floors.flatMap((f) => floorControls(hass, f).covers).filter((id) => canControl(hass, id));
|
||||
const lightsOn = lights.filter((id) => hass.states[id]?.state === "on").length;
|
||||
const house = !floor;
|
||||
// house-wide: the first tap arms the button ("sure?"), the second runs it
|
||||
@@ -2050,7 +2053,7 @@ export class NfView3d extends LitElement {
|
||||
return html`<button
|
||||
class="nf-chip"
|
||||
aria-pressed=${on || this._sceneFired === id}
|
||||
?disabled=${isUnavailable(st)}
|
||||
?disabled=${isUnavailable(st) || !canControl(hass, id)}
|
||||
@click=${() => {
|
||||
void hass.callService(domain, service, { entity_id: id });
|
||||
this._sceneFired = id;
|
||||
@@ -2357,6 +2360,10 @@ export class NfView3d extends LitElement {
|
||||
return;
|
||||
}
|
||||
const kind = kindOf(entityId);
|
||||
if (this.hass.symconObjects !== undefined && !canControl(this.hass, entityId)) {
|
||||
if (this.hass.states[entityId]) this._menu = { entity: entityId, x, y };
|
||||
return;
|
||||
}
|
||||
// blinds have no single on/off: a tap opens their quick menu (up, positions, stop, down); speakers and TVs open theirs
|
||||
// (play, skip, volume, sources and the stations set for them)
|
||||
if (kind === "cover" || kind === "media") {
|
||||
|
||||
Reference in new issue
Block a user