feat: add floating power cards for all powered furniture
This commit is contained in:
1 parent
6bd3598779
commit
4967dd7950
19 files changed
+1125
-810
No files matched your search
@@ -12,6 +12,7 @@ import type { EditorHost } from "../host.ts";
|
||||
import { lightEffectFields } from "../light-effect-fields.ts";
|
||||
import { lightEffectSource } from "../../../light-effects.ts";
|
||||
import { renderDeviceValues } from "../device-values.ts";
|
||||
import { isSymcon, isSymconVariable } from "../../../entities/symcon-values.ts";
|
||||
import { calibrationFrom, calibrationFromRooms, gridPlaces, gridRooms, mapCamera, nudgeCalibration, type CalibrationNudge, type Place } from "../../../live/vacuum-map.ts";
|
||||
|
||||
/** What the forms of a piece of furniture make the editor do. */
|
||||
@@ -266,11 +267,13 @@ export function furnitureLinks(host: EditorHost, item: Furniture, actions: Furni
|
||||
const t = host.t;
|
||||
const lamp = isLamp(item.type);
|
||||
const main = mainEntity(item, hass);
|
||||
const power = entityOptions(hass, (id) => isPowerSensor(hass, id));
|
||||
const power = entityOptions(hass, (id) => isSymcon(hass) ? isSymconVariable(hass, id, [1, 2]) : isPowerSensor(hass, id));
|
||||
const set = (key: keyof Furniture) => (v: string | null) => actions.update({ [key]: noneAsNull(v) });
|
||||
const kindOptions = (accept: (id: string) => boolean) => entityOptions(hass, accept);
|
||||
const strings = (host.doc.settings.roof.strings ?? []).filter((s) => s.inverter === item.id).map((s) => s.name);
|
||||
const hasLink = !!item.entity && item.entity !== "none";
|
||||
const autoPower = automaticLink(host, item, "power");
|
||||
const powerRef = item.power === "none" ? null : item.power || autoPower;
|
||||
const doors = item.type === "fridge_smart" ? kindOptions((id) => id.startsWith("binary_sensor.")) : [];
|
||||
const hintKey: I18nKey = item.type === "ceiling_fan" ? "fan_hint" : lamp ? (item.type === "lamp_pendant" ? "lamp_hint_pendant" : "lamp_hint") : isMediaFurniture(item.type) ? "furn_links_hint_tv" : item.type === "robot_vacuum" ? "robot_hint" : "furn_links_hint";
|
||||
return html`${linkBlock(
|
||||
@@ -287,7 +290,8 @@ export function furnitureLinks(host: EditorHost, item: Furniture, actions: Furni
|
||||
lamp ? lightEffectFields(host, item, lightEffectSource(hass, item, item.entity && item.entity !== "none" ? item.entity : automaticLink(host, item, "entity"))?.attributes.effect_list, actions.update) : nothing,
|
||||
hasScreen(item.type) ? glowField(host, item.ambilight, (v) => actions.update({ ambilight: v }), { label: "ambilight", hint: "ambilight_hint", lowest: 0 }) : nothing,
|
||||
(isMediaFurniture(item.type) || isSpeakerFurniture(item.type)) ? glowField(host, item.sound_rings, (v) => actions.update({ sound_rings: v }), { label: "sound_rings", hint: "sound_rings_hint", lowest: 0 }) : nothing,
|
||||
item.type === "grid_point" ? nothing : entityField(host, t(meterParent(host.doc, item) ? "meter_sub_power" : powerLabel(item.type)), item.power ?? null, automaticLink(host, item, "power"), power, (v) => actions.update({ power: v })),
|
||||
item.type === "grid_point" ? nothing : html`${entityField(host, t(meterParent(host.doc, item) ? "meter_sub_power" : powerLabel(item.type)), item.power ?? null, autoPower, power, (v) => actions.update({ power: v }))}
|
||||
${checkField(host, t("furniture_power_card"), !!item.power_card, (on) => actions.update({ power_card: on || undefined }))}${hint(t("furniture_power_card_hint"), "nf-wide")}`,
|
||||
)}
|
||||
${isCooling(item.type) ? coolingLinks(host, item, actions) : lamp || item.type === "grid_point" ? nothing : deviceTempLink(host, item, actions)}
|
||||
${item.type === "meter" ? subMeterLinks(host, item, actions) : nothing}
|
||||
@@ -302,7 +306,7 @@ export function furnitureLinks(host: EditorHost, item: Furniture, actions: Furni
|
||||
)
|
||||
: nothing}
|
||||
${item.type === "wallbox" ? linkBlock(entityField(host, t("furn_wallbox_status"), item.status ?? null, undefined, kindOptions((id) => isBinary(id) || isNumeric(id)), set("status"))) : nothing}
|
||||
${!lamp || item.entity
|
||||
${!lamp || hasLink || powerRef
|
||||
? html`${checkField(host, t("device_confirm"), !!item.confirm, (on) => actions.update({ confirm: on }), { title: t("device_confirm_hint") })}
|
||||
<div class="nf-form">${markerField(host, item.marker ?? null, (v) => actions.update({ marker: v }))}${iconField(host, item.icon, (v) => actions.update({ icon: v }))}${lamp ? nothing : pinShiftField(host, item.pin_offset, (v) => actions.update({ pin_offset: v }))}</div>`
|
||||
: nothing}
|
||||
|
||||
@@ -31,6 +31,7 @@ import { weatherEntity } from "../weather.ts";
|
||||
import { chosenEffects, readSkyWeather, withDensity } from "../live/sky-weather.ts";
|
||||
import { energyPicture, houseHub, type EnergyPicture } from "../live/energy-flow.ts";
|
||||
import { roomClimateCards } from "../live/room-climate-card.ts";
|
||||
import { furniturePowerCards } from "../live/furniture-power-card.ts";
|
||||
import { loadWeek, type WeekBars } from "../live/week-bars.ts";
|
||||
import { binsDue, loadToday, sortDay, type TodayItem } from "../live/today.ts";
|
||||
import { forecastDays, loadForecast } from "../live/forecast.ts";
|
||||
@@ -2659,7 +2660,10 @@ export class NfView3d extends LitElement {
|
||||
for (const p of this.liveHeatPumps(b)) cards.push({ kind: "heatpump", at: p.at, name: p.name, pump: p.pump });
|
||||
for (const m of media) cards.push({ kind: "media", at: { ...m.at, y: m.at.y + 0.5 }, media: m });
|
||||
}
|
||||
if (this.liveCardsOn && !this.dimmed) cards.push(...roomClimateCards(hass, b, this.floorId, this.roomId));
|
||||
if (this.liveCardsOn && !this.dimmed) {
|
||||
cards.push(...roomClimateCards(hass, b, this.floorId, this.roomId));
|
||||
cards.push(...furniturePowerCards(hass, b, this.furnitureLinks ?? new Map(), this.floorId, this.roomId));
|
||||
}
|
||||
if (JSON.stringify(cards) !== JSON.stringify(this._liveCards)) this._liveCards = cards;
|
||||
v.setLiveAnchors(
|
||||
cards.map((c) => c.at),
|
||||
@@ -2710,7 +2714,7 @@ export class NfView3d extends LitElement {
|
||||
const own = this.ownSensors();
|
||||
const e = this._liveEnergy?.summary;
|
||||
const energy = !!e && !this.roomId && this.showEnergy && !!this.hass && !(e.consumption === null && e.grid === null && e.solar === null && e.battery === null);
|
||||
const climate = this.building?.floors.some((f) => f.rooms.some((r) => r.climate_card));
|
||||
const climate = this.building?.floors.some((f) => f.rooms.some((r) => r.climate_card) || f.furniture.some((m) => m.power_card));
|
||||
const climateToggle = climate ? this.renderCardToggle() : nothing;
|
||||
const roomNames = this.roomNamesButton ? html`<button class="nf-energy-item nf-flow-toggle nf-room-names-toggle" aria-pressed=${this.roomLabels} title=${translate(this.hass, "room_names_toggle_hint")} @click=${() => {
|
||||
this.roomLabels = !this.roomLabels;
|
||||
|
||||
Reference in new issue
Block a user