feat: add floating power cards for all powered furniture

This commit is contained in:
jhartworks committed 2026-11-11 16:24:52 +01:00
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}