feat: add native charging station telemetry and aliased lock status
This commit is contained in:
1 parent
df4a6f36a3
commit
59292517b7
24 files changed
+1756
-1304
No files matched your search
@@ -0,0 +1,31 @@
|
||||
import { html, nothing, type TemplateResult } from "lit";
|
||||
import { isChargingStation, type ChargingStationConfig, type ChargingDurationUnit, type ChargingTimeFormat } from "../../../charging-station.ts";
|
||||
import type { Furniture } from "../../../model.ts";
|
||||
import { entityOptions } from "../entities.ts";
|
||||
import { entityField, hint, selectField } from "../fields.ts";
|
||||
import type { EditorHost } from "../host.ts";
|
||||
|
||||
export function chargingStationFields(host: EditorHost, item: Furniture, update: (patch: Partial<Furniture>) => void): TemplateResult | typeof nothing {
|
||||
if (!isChargingStation(item.type)) return nothing;
|
||||
const t = host.t, c = item.charging ?? {}, options = entityOptions(host.hass, () => true);
|
||||
const set = (patch: Partial<ChargingStationConfig>) => {
|
||||
const charging = { ...c, ...patch };
|
||||
update({ charging: Object.values(charging).some((v) => v != null) ? charging : null });
|
||||
};
|
||||
const timeFormats: [ChargingTimeFormat, string][] = [["auto", t("charging_auto")], ["value", t("charging_value")], ["seconds", t("charging_unix_seconds")], ["milliseconds", t("charging_unix_ms")]];
|
||||
const units: [ChargingDurationUnit, string][] = [["auto", t("charging_auto")], ["value", t("charging_value")], ["seconds", t("charging_seconds")], ["minutes", t("charging_minutes")], ["hours", t("charging_hours")]];
|
||||
const field = (key: "soc" | "start" | "end" | "duration" | "energy" | "lock", label: string, types: number[]) => entityField(host, label, c[key] ?? null, undefined, options, (v) => set({ [key]: v === "none" ? null : v }), { types });
|
||||
return html`<div class="nf-form nf-links nf-charging-links">
|
||||
<b class="nf-wide">${t("charging_data")}</b>
|
||||
${hint(t("charging_hint"), "nf-wide")}
|
||||
${field("soc", t("furn_soc"), [1, 2])}
|
||||
${field("start", t("charging_start"), [1, 2, 3])}
|
||||
${c.start && c.start !== "none" ? selectField(host, `${t("charging_start")} · ${t("charging_time_format")}`, c.start_format ?? "auto", timeFormats, (start_format) => set({ start_format }), { wide: true }) : nothing}
|
||||
${field("end", t("charging_end"), [1, 2, 3])}
|
||||
${c.end && c.end !== "none" ? selectField(host, `${t("charging_end")} · ${t("charging_time_format")}`, c.end_format ?? "auto", timeFormats, (end_format) => set({ end_format }), { wide: true }) : nothing}
|
||||
${field("duration", t("charging_duration"), [1, 2, 3])}
|
||||
${c.duration && c.duration !== "none" ? selectField(host, t("charging_duration_unit"), c.duration_unit ?? "auto", units, (duration_unit) => set({ duration_unit }), { wide: true }) : nothing}
|
||||
${field("energy", t("charging_energy"), [1, 2])}
|
||||
${field("lock", t("charging_lock"), [1])}
|
||||
</div>`;
|
||||
}
|
||||
@@ -13,6 +13,8 @@ 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 { isChargingStation } from "../../../charging-station.ts";
|
||||
import { chargingStationFields } from "./charging-station.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. */
|
||||
@@ -291,7 +293,7 @@ export function furnitureLinks(host: EditorHost, item: Furniture, actions: Furni
|
||||
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 : html`${entityField(host, t(meterParent(host.doc, item) ? "meter_sub_power" : powerLabel(item.type)), item.power ?? null, autoPower, power, (v) => actions.update({ power: v }), { types: [1, 2] })}
|
||||
${checkField(host, t("furniture_power_card"), !!item.power_card, (on) => actions.update({ power_card: on || undefined }))}${hint(t("furniture_power_card_hint"), "nf-wide")}`,
|
||||
${checkField(host, t(isChargingStation(item.type) ? "charging_card" : "furniture_power_card"), !!item.power_card, (on) => actions.update({ power_card: on || undefined }))}${hint(t(isChargingStation(item.type) ? "charging_hint" : "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}
|
||||
@@ -305,7 +307,8 @@ export function furnitureLinks(host: EditorHost, item: Furniture, actions: Furni
|
||||
hint(t("furn_charge_hint"), "nf-wide"),
|
||||
)
|
||||
: nothing}
|
||||
${item.type === "wallbox" ? linkBlock(entityField(host, t("furn_wallbox_status"), item.status ?? null, undefined, kindOptions((id) => isBinary(id) || isNumeric(id)), set("status"))) : nothing}
|
||||
${isChargingStation(item.type) ? linkBlock(entityField(host, t("furn_wallbox_status"), item.status ?? null, undefined, kindOptions((id) => isBinary(id) || isNumeric(id)), set("status"), { types: [0, 1, 2, 3] })) : nothing}
|
||||
${chargingStationFields(host, item, actions.update)}
|
||||
${!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>`
|
||||
|
||||
@@ -29,6 +29,8 @@ import type { HassEntity, HomeAssistant } from "../types.ts";
|
||||
import { coverTiltEntity, coverWithTilt } from "../entities/covers.ts";
|
||||
import { deviceValueReadouts } from "../entities/device-values.ts";
|
||||
import { pointInPolygon } from "../model.ts";
|
||||
import { chargingReadouts } from "../charging-station.ts";
|
||||
import { furnitureName } from "../furniture-names.ts";
|
||||
|
||||
const COVER_SET_POSITION = 4;
|
||||
const COVER_STOP = 8;
|
||||
@@ -561,7 +563,7 @@ export class NfRoomPanel extends LitElement {
|
||||
private extraValues(room: Room) {
|
||||
if (!this.floor) return nothing;
|
||||
const groups = [...this.floor.placements.filter((p) => !p.outside && pointInPolygon([p.x, p.z], room.points)).map((p) => ({ name: p.name || entityName(this.hass, p.entity_id), rows: deviceValueReadouts(this.hass, p.values) })),
|
||||
...this.floor.furniture.filter((f) => pointInPolygon([f.x, f.z], room.points)).map((f) => ({ name: f.name || (f.entity && f.entity !== "none" ? entityName(this.hass, f.entity) : this.t("device")), rows: deviceValueReadouts(this.hass, f.values) }))].filter((g) => g.rows.length);
|
||||
...this.floor.furniture.filter((f) => pointInPolygon([f.x, f.z], room.points)).map((f) => ({ name: f.name || (f.entity && f.entity !== "none" ? entityName(this.hass, f.entity) : furnitureName(this.hass, f.type)), rows: [...chargingReadouts(this.hass, f), ...deviceValueReadouts(this.hass, f.values)] }))].filter((g) => g.rows.length);
|
||||
return groups.length ? this.section("device_values", groups.map((g) => html`<div class="nf-extra-values"><b>${g.name}</b>${g.rows.map((v) => html`<div class="nf-rp-row"><span class="nf-rp-icon">${v.icon}</span><span class="nf-rp-name">${v.label}</span><b class="nf-rp-state">${v.text}${trendButton(this.hass, [v.entity], v.label)}</b></div>`)}</div>`)) : nothing;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import type { HomeAssistant } from "../../types.ts";
|
||||
import { weatherEntity } from "../../weather.ts";
|
||||
import { utilityWatched } from "../../utilities.ts";
|
||||
import { hydronicRefs } from "../../hydronic-model.ts";
|
||||
import { chargingRefs } from "../../charging-station.ts";
|
||||
|
||||
export interface WatchInputs {
|
||||
hass: HomeAssistant;
|
||||
@@ -46,6 +47,7 @@ function furnitureIds(inputs: WatchInputs): MaybeId[] {
|
||||
...pieces.filter((m) => m.type === "washer" || m.type === "dryer" || m.type === "dishwasher").flatMap((m) => deviceSiblings(hass, furnitureLinks.get(m.id)?.entity ?? furnitureLinks.get(m.id)?.power).filter((id) => id.startsWith("sensor."))),
|
||||
...pieces.flatMap((m) => [m.door_left, m.door_right, m.soc, m.status, m.charge, m.export, m.temp_entity, m.temp_entity2, ...(m.values ?? []).map((v) => v.entity)]),
|
||||
...pieces.flatMap(hydronicRefs),
|
||||
...pieces.flatMap(chargingRefs),
|
||||
...pieces.filter((m) => m.type === "robot_vacuum").map((m) => robotRoomSensor(hass, furnitureLinks.get(m.id)?.entity ?? null, m.room_sensor)),
|
||||
...pieces.flatMap((m) => (m.pictures ?? []).flatMap((rule) => [rule.entity, ...(rule.image.startsWith("camera:") ? [rule.image.slice("camera:".length)] : [])])),
|
||||
];
|
||||
|
||||
Reference in new issue
Block a user