@switchbot/homebridge-switchbot 5.0.0-beta.113 → 5.0.0-beta.115
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/homebridge-ui/public/js/app.js +57 -0
- package/dist/homebridge-ui/public/js/app.js.map +2 -2
- package/dist/homebridge-ui/public/js/render.d.ts.map +1 -1
- package/dist/homebridge-ui/public/js/render.js +62 -0
- package/dist/homebridge-ui/public/js/render.js.map +1 -1
- package/dist/homebridge-ui/public/js/render.ts +64 -0
- package/dist/platform.js +3 -3
- package/dist/platform.js.map +1 -1
- package/docs/variables/default.html +1 -1
- package/package.json +1 -1
- package/src/homebridge-ui/public/js/render.ts +64 -0
- package/src/platform.ts +3 -3
- package/test/matter-integration.spec.ts +2 -2
|
@@ -2574,6 +2574,63 @@ function renderDeviceDetailsPanel(device) {
|
|
|
2574
2574
|
line.appendChild(label);
|
|
2575
2575
|
line.appendChild(valueWrap);
|
|
2576
2576
|
details.appendChild(line);
|
|
2577
|
+
if (row.label === "Battery" && Array.isArray(batteryHistory) && batteryHistory.length > 1) {
|
|
2578
|
+
const chart = document.createElement("div");
|
|
2579
|
+
chart.style.margin = "2px 0 8px 0";
|
|
2580
|
+
chart.style.width = "100%";
|
|
2581
|
+
chart.style.height = "28px";
|
|
2582
|
+
chart.style.display = "flex";
|
|
2583
|
+
const w = 120, h = 24, pad = 2;
|
|
2584
|
+
const min = Math.min(...batteryHistory.map((b) => b.value), 100);
|
|
2585
|
+
const max = Math.max(...batteryHistory.map((b) => b.value), 0);
|
|
2586
|
+
const range = max - min || 1;
|
|
2587
|
+
const points = batteryHistory.map((b, i) => {
|
|
2588
|
+
const x = pad + i * (w - 2 * pad) / (batteryHistory.length - 1);
|
|
2589
|
+
const y = pad + (h - 2 * pad) * (1 - (b.value - min) / range);
|
|
2590
|
+
return `${x},${y}`;
|
|
2591
|
+
}).join(" ");
|
|
2592
|
+
const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
2593
|
+
svg.setAttribute("width", String(w));
|
|
2594
|
+
svg.setAttribute("height", String(h));
|
|
2595
|
+
svg.setAttribute("viewBox", `0 0 ${w} ${h}`);
|
|
2596
|
+
svg.style.display = "block";
|
|
2597
|
+
svg.style.background = "#f3f4f6";
|
|
2598
|
+
svg.style.borderRadius = "3px";
|
|
2599
|
+
svg.style.marginTop = "2px";
|
|
2600
|
+
svg.style.boxShadow = "0 1px 2px #0001";
|
|
2601
|
+
const polyline = document.createElementNS("http://www.w3.org/2000/svg", "polyline");
|
|
2602
|
+
polyline.setAttribute("points", points);
|
|
2603
|
+
polyline.setAttribute("fill", "none");
|
|
2604
|
+
polyline.setAttribute("stroke", "#2563eb");
|
|
2605
|
+
polyline.setAttribute("stroke-width", "2");
|
|
2606
|
+
svg.appendChild(polyline);
|
|
2607
|
+
batteryHistory.forEach((b, i) => {
|
|
2608
|
+
const x = pad + i * (w - 2 * pad) / (batteryHistory.length - 1);
|
|
2609
|
+
const y = pad + (h - 2 * pad) * (1 - (b.value - min) / range);
|
|
2610
|
+
const circle = document.createElementNS("http://www.w3.org/2000/svg", "circle");
|
|
2611
|
+
circle.setAttribute("cx", String(x));
|
|
2612
|
+
circle.setAttribute("cy", String(y));
|
|
2613
|
+
circle.setAttribute("r", "2.5");
|
|
2614
|
+
circle.setAttribute("fill", "#2563eb");
|
|
2615
|
+
svg.appendChild(circle);
|
|
2616
|
+
});
|
|
2617
|
+
const minLabel = document.createElementNS("http://www.w3.org/2000/svg", "text");
|
|
2618
|
+
minLabel.setAttribute("x", "2");
|
|
2619
|
+
minLabel.setAttribute("y", String(h - 2));
|
|
2620
|
+
minLabel.setAttribute("font-size", "9");
|
|
2621
|
+
minLabel.setAttribute("fill", "#888");
|
|
2622
|
+
minLabel.textContent = `${min}%`;
|
|
2623
|
+
svg.appendChild(minLabel);
|
|
2624
|
+
const maxLabel = document.createElementNS("http://www.w3.org/2000/svg", "text");
|
|
2625
|
+
maxLabel.setAttribute("x", String(w - 18));
|
|
2626
|
+
maxLabel.setAttribute("y", "10");
|
|
2627
|
+
maxLabel.setAttribute("font-size", "9");
|
|
2628
|
+
maxLabel.setAttribute("fill", "#888");
|
|
2629
|
+
maxLabel.textContent = `${max}%`;
|
|
2630
|
+
svg.appendChild(maxLabel);
|
|
2631
|
+
chart.appendChild(svg);
|
|
2632
|
+
details.appendChild(chart);
|
|
2633
|
+
}
|
|
2577
2634
|
}
|
|
2578
2635
|
const featureKeys = [
|
|
2579
2636
|
"airQuality",
|