fix: keep Symcon binding paths compact and allow direct unlinking
This commit is contained in:
1 parent
00fca890de
commit
b9a095bc6e
12 files changed
+131
-46
No files matched your search
@@ -30,12 +30,12 @@ try {
|
||||
await page.evaluate(async () => {
|
||||
window.humidityValue = 51.6;
|
||||
window.bootstrapCalls = 0;
|
||||
const raw = (id, name, type, value, unit, domain = "sensor") => ({ entity_id: `${domain}.${id}`, name, path: `Haus / Messwerte / ${name}`, state: domain === "cover" ? "open" : String(value), attributes: { symcon_id: id, symcon_variable_type: type, symcon_numeric_value: value, unit_of_measurement: unit } });
|
||||
const raw = (id, name, type, value, unit, domain = "sensor") => ({ entity_id: `${domain}.${id}`, name, path: `Haus / DP KNX / OG Allgemein / Heizen Kühlen / RAT Teeküche / Weiterer Unterordner / Messwerte / ${name}`, state: domain === "cover" ? "open" : String(value), attributes: { symcon_id: id, symcon_variable_type: type, symcon_numeric_value: value, unit_of_measurement: unit } });
|
||||
const originalFetch = window.fetch;
|
||||
window.fetch = async (url, init) => {
|
||||
if (!String(url).includes("/hook/climate-fixture/")) return originalFetch(url, init);
|
||||
window.bootstrapCalls++;
|
||||
const variables = [raw(201, "Raumtemperatur", 2, 21.5, "°C"), raw(202, "Messwert Raumfeuchtigkeit", 2, window.humidityValue, "%", "cover"), raw(203, "CO₂", 1, 780, "ppm"), raw(204, "Raumhelligkeit", 2, 320.5, "lx")];
|
||||
const variables = [raw(201, "Raumtemperatur", 2, 21.5, "°C"), raw(202, "Messwert Raumfeuchtigkeit", 2, window.humidityValue, "%", "cover"), raw(203, "CO₂", 1, 780, "ppm"), raw(204, "Raumhelligkeit", 2, 320.5, "lx"), raw(205, "Zusatztemperatur", 2, 21.5, "°C")];
|
||||
const objects = [{ object_id: 100, parent_id: 0, name: "Haus", path: "Haus", object_type: 0, position: 0, hidden: true, icon: "" },
|
||||
...variables.map((v) => ({ object_id: v.attributes.symcon_id, parent_id: 100, entity_id: v.entity_id, name: v.name, path: v.path, object_type: 2, position: 0, hidden: false, icon: "" }))];
|
||||
return new Response(JSON.stringify({ state_revision: window.bootstrapCalls, building_revision: 1, variables, objects, areas: [] }));
|
||||
@@ -89,6 +89,24 @@ try {
|
||||
await window.pickClimate("Luftfeuchte", 202, "Messwert Raumfeuchtigkeit");
|
||||
await window.pickClimate("CO₂", 203, "CO₂");
|
||||
await window.pickClimate("Helligkeit", 204, "Raumhelligkeit");
|
||||
await window.pickClimate("… und noch ein Sensor", 205, "Zusatztemperatur");
|
||||
window.unlinkTemperature = async () => {
|
||||
const field = [...window.climateSection.querySelectorAll("label.nf-field")].find((el) => el.textContent.trim().startsWith("Temperatur"));
|
||||
const picker = field.querySelector("nf-entity-picker");
|
||||
await picker.updateComplete;
|
||||
const native = picker.shadowRoot.querySelector("nf-symcon-object-picker");
|
||||
await native.updateComplete;
|
||||
native.shadowRoot.querySelector(".clear").click();
|
||||
await e.updateComplete;
|
||||
await window.nfPanel.updateComplete;
|
||||
await e.updateComplete;
|
||||
};
|
||||
await window.unlinkTemperature();
|
||||
if (e._doc.floors[0].rooms[0].climate.temperature !== "sensor.205") throw new Error("Clearing the first averaged sensor removed its remaining link");
|
||||
if (e._doc.floors[0].rooms[0].climate.humidity !== "cover.202") throw new Error("Unlinking temperature changed another metric");
|
||||
await window.unlinkTemperature();
|
||||
if (e._doc.floors[0].rooms[0].climate.temperature !== "none") throw new Error("The last temperature link must stay explicitly unlinked");
|
||||
await window.pickClimate("Temperatur", 201, "Raumtemperatur");
|
||||
const label = [...window.climateSection.querySelectorAll("label.nf-check")].find((el) => el.textContent.includes("schwebende Karte"));
|
||||
label.querySelector("input").click();
|
||||
await e.updateComplete;
|
||||
|
||||
Reference in new issue
Block a user