pushraker 0.3.2__tar.gz → 0.3.3__tar.gz
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.
- {pushraker-0.3.2/src/pushraker.egg-info → pushraker-0.3.3}/PKG-INFO +1 -1
- {pushraker-0.3.2 → pushraker-0.3.3}/pyproject.toml +1 -1
- {pushraker-0.3.2 → pushraker-0.3.3}/src/pushraker/__init__.py +1 -1
- {pushraker-0.3.2 → pushraker-0.3.3}/src/pushraker/component.py +183 -85
- {pushraker-0.3.2 → pushraker-0.3.3}/src/pushraker/printers/snapmaker_u1.py +12 -17
- {pushraker-0.3.2 → pushraker-0.3.3}/src/pushraker/templating.py +74 -42
- {pushraker-0.3.2 → pushraker-0.3.3}/src/pushraker/web/index.html +58 -35
- {pushraker-0.3.2 → pushraker-0.3.3/src/pushraker.egg-info}/PKG-INFO +1 -1
- {pushraker-0.3.2 → pushraker-0.3.3}/tests/test_pushraker.py +30 -6
- {pushraker-0.3.2 → pushraker-0.3.3}/LICENSE +0 -0
- {pushraker-0.3.2 → pushraker-0.3.3}/README.md +0 -0
- {pushraker-0.3.2 → pushraker-0.3.3}/setup.cfg +0 -0
- {pushraker-0.3.2 → pushraker-0.3.3}/src/pushraker/__main__.py +0 -0
- {pushraker-0.3.2 → pushraker-0.3.3}/src/pushraker/discord.py +0 -0
- {pushraker-0.3.2 → pushraker-0.3.3}/src/pushraker/email_html.py +0 -0
- {pushraker-0.3.2 → pushraker-0.3.3}/src/pushraker/images.py +0 -0
- {pushraker-0.3.2 → pushraker-0.3.3}/src/pushraker/klipper/pushraker.cfg +0 -0
- {pushraker-0.3.2 → pushraker-0.3.3}/src/pushraker/printers/__init__.py +0 -0
- {pushraker-0.3.2 → pushraker-0.3.3}/src/pushraker/settings.py +0 -0
- {pushraker-0.3.2 → pushraker-0.3.3}/src/pushraker.egg-info/SOURCES.txt +0 -0
- {pushraker-0.3.2 → pushraker-0.3.3}/src/pushraker.egg-info/dependency_links.txt +0 -0
- {pushraker-0.3.2 → pushraker-0.3.3}/src/pushraker.egg-info/requires.txt +0 -0
- {pushraker-0.3.2 → pushraker-0.3.3}/src/pushraker.egg-info/top_level.txt +0 -0
- {pushraker-0.3.2 → pushraker-0.3.3}/tests/test_settings.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pushraker
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.3
|
|
4
4
|
Summary: Push notifications for Klipper printers: a Moonraker component with pictures, sent through Apprise (ntfy, Pushover, Telegram, Discord, webhooks, email)
|
|
5
5
|
Author: noon92
|
|
6
6
|
License-Expression: GPL-3.0-or-later
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "pushraker"
|
|
7
|
-
version = "0.3.
|
|
7
|
+
version = "0.3.3"
|
|
8
8
|
description = "Push notifications for Klipper printers: a Moonraker component with pictures, sent through Apprise (ntfy, Pushover, Telegram, Discord, webhooks, email)"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = "GPL-3.0-or-later"
|
|
@@ -124,27 +124,19 @@ DATA_ALIAS = {"preprint_done": "started", "file_pause": "paused",
|
|
|
124
124
|
DATA_QUERY_TIMEOUT = 5.
|
|
125
125
|
# Time-left methods, id -> (label, help); see _left_seconds
|
|
126
126
|
TIME_METHODS = {
|
|
127
|
-
"blend": ("Blend", "
|
|
128
|
-
"
|
|
129
|
-
"
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
"
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
"the time printed: the pace so far, extrapolated (Fluidd's "
|
|
141
|
-
"and Mainsail's \"file\" estimate). Wild early in a print, "
|
|
142
|
-
"good near the end."),
|
|
143
|
-
"filament": ("Filament", "The same extrapolation by filament used "
|
|
144
|
-
"against the file's filament total."),
|
|
145
|
-
"m73": ("M73", "The slicer's own time-left markers in the file (M73 R, "
|
|
146
|
-
"written by PrusaSlicer, OrcaSlicer and their forks), at the "
|
|
147
|
-
"current position. A file without them uses Blend."),
|
|
127
|
+
"blend": ("Blend", "Slicer estimate until 30 % of the file, then mixed "
|
|
128
|
+
"with the pace so far, more so as the print goes on "
|
|
129
|
+
"(KlipperScreen's auto). The most accurate on tested prints."),
|
|
130
|
+
"slicer": ("Slicer", "Slicer estimate minus time printed. Early by the "
|
|
131
|
+
"start routine's length."),
|
|
132
|
+
"slicer_first_layer": ("Slicer from first layer", "Slicer estimate "
|
|
133
|
+
"minus time printed since layer 1, so the "
|
|
134
|
+
"start routine doesn't count."),
|
|
135
|
+
"file": ("File", "Pace so far: time printed ÷ file progress. Wild "
|
|
136
|
+
"early, good late."),
|
|
137
|
+
"filament": ("Filament", "Pace so far by filament used."),
|
|
138
|
+
"m73": ("M73", "The slicer's own M73 R markers at the current point "
|
|
139
|
+
"of the file; Blend if it has none."),
|
|
148
140
|
}
|
|
149
141
|
# (see _left_seconds); the printer harness may add its
|
|
150
142
|
# own and picks the default. KlipperScreen's blend hands over from the
|
|
@@ -160,7 +152,12 @@ SAMPLE_FILAMENTS = [
|
|
|
160
152
|
("TPU 95A Orange", "TPU", "Generic", "#F98C36", 230, 40),
|
|
161
153
|
("PLA Matte Grey", "PLA", "Generic", "#808080", 215, 55),
|
|
162
154
|
]
|
|
163
|
-
SAMPLE_LEFT =
|
|
155
|
+
SAMPLE_LEFT = (24 * 60 + 3 * 60 + 12) * 60 # 1d 3h 12m remaining
|
|
156
|
+
SAMPLE_FILE = "3DBenchy_x40_4colour"
|
|
157
|
+
# The sample's job queue: name, hours, grams, meters, materials
|
|
158
|
+
SAMPLE_QUEUE = [("Cable_clips_x12_PETG", 0.75, 22.4, 7.32, ["PETG"]),
|
|
159
|
+
("Spool_holder_PLA", 2.2, 96.0, 32.21, ["PLA"]),
|
|
160
|
+
("Phone_stand_PLA_TPU", 1.1, 41.5, 13.87, ["PLA", "TPU"])]
|
|
164
161
|
# Klipper's toolheads (extruder, extruder1, ...) and the fields pushraker
|
|
165
162
|
# adds to them: the filament loaded, the MMU slot feeding it
|
|
166
163
|
RX_EXTRUDER = re.compile(r"extruder(\d*)")
|
|
@@ -1518,6 +1515,21 @@ class PushNotifications:
|
|
|
1518
1515
|
"colors": "color", "vendors": "vendor",
|
|
1519
1516
|
"grams": "grams"}.get(key)
|
|
1520
1517
|
return [f.get(field) for f in fl] if field and fl else None
|
|
1518
|
+
if head == "queue":
|
|
1519
|
+
q = base.get("queue") or {}
|
|
1520
|
+
items = q.get("items") or []
|
|
1521
|
+
if not rest:
|
|
1522
|
+
return q.get("remaining")
|
|
1523
|
+
key = rest[0]
|
|
1524
|
+
if key == "next" or key.isdigit():
|
|
1525
|
+
n = 1 if key == "next" else int(key)
|
|
1526
|
+
it = items[n - 1] if 0 < n <= len(items) else (
|
|
1527
|
+
self._sample_queue_item(n) if sample and not active
|
|
1528
|
+
and n > 0 else None)
|
|
1529
|
+
if it is None:
|
|
1530
|
+
return None
|
|
1531
|
+
return tp.dig(it, rest[1:]) if rest[1:] else it["name"]
|
|
1532
|
+
return tp.dig(q, rest)
|
|
1521
1533
|
m = re.fullmatch(r"filament(\d+)", head)
|
|
1522
1534
|
if m:
|
|
1523
1535
|
f = filament(int(m.group(1)))
|
|
@@ -1554,7 +1566,8 @@ class PushNotifications:
|
|
|
1554
1566
|
"layer": info.get("current_layer"),
|
|
1555
1567
|
"layers": info.get("total_layer"),
|
|
1556
1568
|
"plate": self._job_slicer.get("curr_bed_type") or None,
|
|
1557
|
-
"queue": self.
|
|
1569
|
+
"queue": self._queue_values(
|
|
1570
|
+
filename, self._left_seconds(self._time_method())),
|
|
1558
1571
|
"time": self._times(
|
|
1559
1572
|
{m: self._left_seconds(m) for m in self._time_methods()},
|
|
1560
1573
|
self._left_seconds(self._time_method()), pd),
|
|
@@ -1566,17 +1579,84 @@ class PushNotifications:
|
|
|
1566
1579
|
}
|
|
1567
1580
|
|
|
1568
1581
|
def _sample_filament(self, n: int) -> Dict[str, Any]:
|
|
1582
|
+
"""The sample job's filament n: four in use, any number on demand."""
|
|
1569
1583
|
name, mat, vendor, colour, nozzle, bed = \
|
|
1570
1584
|
SAMPLE_FILAMENTS[(n - 1) % len(SAMPLE_FILAMENTS)]
|
|
1571
1585
|
ch = (n - 1) % max(1, len(self.printer.extruders))
|
|
1572
|
-
return {"index": n - 1, "used": n
|
|
1573
|
-
"
|
|
1574
|
-
"
|
|
1586
|
+
return {"index": n - 1, "used": n <= len(SAMPLE_FILAMENTS),
|
|
1587
|
+
"name": name, "material": mat, "vendor": vendor,
|
|
1588
|
+
"color": colour, "grams": round(38.5 - n * 6.3, 1)
|
|
1589
|
+
if n <= len(SAMPLE_FILAMENTS) else round(2. + n * 0.7, 1),
|
|
1575
1590
|
"extruder": self._ext_name(ch),
|
|
1576
1591
|
"slot": f"ACE 1 slot {ch + 1}" if self._ace_on else None,
|
|
1577
1592
|
"nozzle_temperature": float(nozzle),
|
|
1578
1593
|
"nozzle_diameter": 0.4, "bed_temperature": float(bed)}
|
|
1579
1594
|
|
|
1595
|
+
def _queue_item(self, name: str, seconds: float, grams: Optional[float],
|
|
1596
|
+
meters: Optional[float], materials: List[str],
|
|
1597
|
+
start: float) -> Dict[str, Any]:
|
|
1598
|
+
return {"name": name, "time": self._dur(seconds) if seconds
|
|
1599
|
+
else None, "grams": grams, "meters": meters,
|
|
1600
|
+
"materials": materials or None,
|
|
1601
|
+
"eta": self._eta(start + seconds) if seconds else None}
|
|
1602
|
+
|
|
1603
|
+
def _sample_queue_item(self, n: int, start: float = 0.
|
|
1604
|
+
) -> Dict[str, Any]:
|
|
1605
|
+
name, hours, grams, meters, mats = SAMPLE_QUEUE[(n - 1) % len(SAMPLE_QUEUE)]
|
|
1606
|
+
if not start:
|
|
1607
|
+
start = SAMPLE_LEFT + sum(
|
|
1608
|
+
SAMPLE_QUEUE[(i - 1) % len(SAMPLE_QUEUE)][1] * 3600.
|
|
1609
|
+
for i in range(1, n))
|
|
1610
|
+
return self._queue_item(name, hours * 3600., grams, meters, mats,
|
|
1611
|
+
start)
|
|
1612
|
+
|
|
1613
|
+
def _queue_summary(self, items: List[Dict[str, Any]],
|
|
1614
|
+
left: Optional[float]) -> Dict[str, Any]:
|
|
1615
|
+
secs = sum(float(i["time"]) for i in items if i.get("time"))
|
|
1616
|
+
grams = [i["grams"] for i in items if i.get("grams")]
|
|
1617
|
+
meters = [i["meters"] for i in items if i.get("meters")]
|
|
1618
|
+
return {"remaining": len(items), "items": items,
|
|
1619
|
+
"list": [i["name"] for i in items] or None,
|
|
1620
|
+
"time": self._dur(secs) if items else None,
|
|
1621
|
+
"eta": self._eta((left or 0.) + secs) if items else None,
|
|
1622
|
+
"grams": round(sum(grams), 1) if grams else None,
|
|
1623
|
+
"meters": round(sum(meters), 2) if meters else None}
|
|
1624
|
+
|
|
1625
|
+
def _queue_values(self, filename: str, left: Optional[float]
|
|
1626
|
+
) -> Dict[str, Any]:
|
|
1627
|
+
"""Moonraker's job queue after the current print job: each file's
|
|
1628
|
+
slicer estimate, filament and ETA (one after the other)."""
|
|
1629
|
+
start = left or 0.
|
|
1630
|
+
items = []
|
|
1631
|
+
for f in self._queue_files(filename):
|
|
1632
|
+
try:
|
|
1633
|
+
fm = self.server.lookup_component("file_manager")
|
|
1634
|
+
meta = fm.get_metadata_storage().get(f, {}) or {}
|
|
1635
|
+
except Exception:
|
|
1636
|
+
meta = {}
|
|
1637
|
+
secs = float(meta.get("estimated_time") or 0.)
|
|
1638
|
+
grams = meta.get("filament_weight_total")
|
|
1639
|
+
mm = meta.get("filament_total")
|
|
1640
|
+
mats = [m for m in tp.split_values(str(meta.get("filament_type")
|
|
1641
|
+
or "")) if m]
|
|
1642
|
+
items.append(self._queue_item(
|
|
1643
|
+
shown(f), secs, float(grams) if grams else None,
|
|
1644
|
+
round(float(mm) / 1000., 2) if mm else None, mats, start))
|
|
1645
|
+
start += secs
|
|
1646
|
+
return self._queue_summary(items, left)
|
|
1647
|
+
|
|
1648
|
+
def _queue_files(self, filename: str) -> List[str]:
|
|
1649
|
+
try:
|
|
1650
|
+
jq = self.server.lookup_component("job_queue", None)
|
|
1651
|
+
files = [str(j) for j in list(getattr(jq, "queued_jobs", {})
|
|
1652
|
+
.values())] if jq else []
|
|
1653
|
+
except Exception:
|
|
1654
|
+
return []
|
|
1655
|
+
# The queue starts its next job before taking it off the list
|
|
1656
|
+
if files and files[0] == filename:
|
|
1657
|
+
files = files[1:]
|
|
1658
|
+
return files
|
|
1659
|
+
|
|
1580
1660
|
def _job_sample(self) -> Dict[str, Any]:
|
|
1581
1661
|
methods = self._time_methods()
|
|
1582
1662
|
# Each method a little off the others, as on a real print
|
|
@@ -1585,26 +1665,22 @@ class PushNotifications:
|
|
|
1585
1665
|
spread = {m: SAMPLE_LEFT + (i - 2 if i >= 2 else i - 3) * 60
|
|
1586
1666
|
for i, m in enumerate(others)}
|
|
1587
1667
|
spread[default_m] = SAMPLE_LEFT
|
|
1588
|
-
|
|
1589
|
-
|
|
1668
|
+
fils = [self._sample_filament(n)
|
|
1669
|
+
for n in range(1, len(SAMPLE_FILAMENTS) + 1)]
|
|
1670
|
+
queue = [self._sample_queue_item(n)
|
|
1671
|
+
for n in range(1, len(SAMPLE_QUEUE) + 1)]
|
|
1672
|
+
return {"file": SAMPLE_FILE, "progress": 42.3,
|
|
1590
1673
|
"layer": 120, "layers": 285, "plate": "Textured PEI Plate",
|
|
1591
|
-
"queue":
|
|
1592
|
-
"
|
|
1593
|
-
"
|
|
1674
|
+
"queue": self._queue_summary(queue, SAMPLE_LEFT),
|
|
1675
|
+
"time": self._times(spread, SAMPLE_LEFT, 18 * 3600 + 51 * 60),
|
|
1676
|
+
"filaments": fils,
|
|
1677
|
+
"extruders": sorted({f["extruder"] for f in fils},
|
|
1678
|
+
key=lambda e: self._ext_index(e) or 0)}
|
|
1594
1679
|
|
|
1595
1680
|
@staticmethod
|
|
1596
1681
|
def _dur(seconds: Optional[float]) -> Optional[tp.Duration]:
|
|
1597
1682
|
return tp.Duration(max(0., seconds)) if seconds is not None else None
|
|
1598
1683
|
|
|
1599
|
-
def _queue_count(self, filename: str) -> Optional[int]:
|
|
1600
|
-
try:
|
|
1601
|
-
jq = self.server.lookup_component("job_queue", None)
|
|
1602
|
-
files = [str(j) for j in list(getattr(jq, "queued_jobs", {})
|
|
1603
|
-
.values())] if jq else []
|
|
1604
|
-
return len([f for f in files if f != filename])
|
|
1605
|
-
except Exception:
|
|
1606
|
-
return None
|
|
1607
|
-
|
|
1608
1684
|
def _filaments(self) -> List[Dict[str, Any]]:
|
|
1609
1685
|
"""The job's filaments, in slicer order (index 0 = the slicer's
|
|
1610
1686
|
filament 1), each as the slicer reported it, with the extruder
|
|
@@ -1695,11 +1771,17 @@ class PushNotifications:
|
|
|
1695
1771
|
def fields(obj: str, spec: Sequence[Tuple[str, str, str, bool]]
|
|
1696
1772
|
) -> List[Dict[str, Any]]:
|
|
1697
1773
|
st = state.get(obj) or {}
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1774
|
+
out = []
|
|
1775
|
+
for f, h, i, frac in spec:
|
|
1776
|
+
if st.get(f) is None and st:
|
|
1777
|
+
continue
|
|
1778
|
+
node = tp.node(f, hint=h, info=i, token=f"{obj}.{f}",
|
|
1779
|
+
formats=None if f in tp.NO_FORMATS
|
|
1780
|
+
else tp.format_options(st.get(f), frac))
|
|
1781
|
+
if f in tp.DEGREE_FIELDS:
|
|
1782
|
+
node["degree"] = True
|
|
1783
|
+
out.append(node)
|
|
1784
|
+
return out
|
|
1703
1785
|
|
|
1704
1786
|
# Thermals
|
|
1705
1787
|
thermals = []
|
|
@@ -1726,9 +1808,8 @@ class PushNotifications:
|
|
|
1726
1808
|
obj, bool(self.spoolman_url))
|
|
1727
1809
|
except Exception as e:
|
|
1728
1810
|
logging.warning("[pushraker] harness catalogue: %s", e)
|
|
1729
|
-
heads.append(tp.node(
|
|
1730
|
-
|
|
1731
|
-
"extruder, extruder1, extruder2…", children=kids))
|
|
1811
|
+
heads.append(tp.node(obj, info=f"Toolhead {ch + 1}.",
|
|
1812
|
+
children=kids))
|
|
1732
1813
|
placed.add(obj)
|
|
1733
1814
|
# Fans
|
|
1734
1815
|
fans = []
|
|
@@ -1755,12 +1836,10 @@ class PushNotifications:
|
|
|
1755
1836
|
other.append(tp.node(obj, hint=hint(obj) or "",
|
|
1756
1837
|
children=kids))
|
|
1757
1838
|
cats = [
|
|
1758
|
-
{"id": "thermals", "label": "🌡️ Thermals", "
|
|
1759
|
-
"children": thermals},
|
|
1839
|
+
{"id": "thermals", "label": "🌡️ Thermals", "children": thermals},
|
|
1760
1840
|
{"id": "toolheads", "label": "🔧 Toolheads",
|
|
1761
1841
|
"info": "Klipper calls toolheads extruder, extruder1, "
|
|
1762
|
-
"extruder2…
|
|
1763
|
-
"children": heads},
|
|
1842
|
+
"extruder2…", "children": heads},
|
|
1764
1843
|
{"id": "fans", "label": "🌀 Fans", "children": fans},
|
|
1765
1844
|
{"id": "job", "label": "🖨️ Print job",
|
|
1766
1845
|
"info": "Generated by pushraker, not Klipper values.",
|
|
@@ -1777,53 +1856,62 @@ class PushNotifications:
|
|
|
1777
1856
|
n = tp.node
|
|
1778
1857
|
|
|
1779
1858
|
def leaf(path: str, hint: str = "", info: str = "",
|
|
1780
|
-
frac: bool = False) -> Dict[str, Any]:
|
|
1859
|
+
frac: bool = False, degree: bool = False) -> Dict[str, Any]:
|
|
1781
1860
|
v = job(path.replace("#", "1").split("."))
|
|
1782
1861
|
last = path.rsplit(".", 1)[-1]
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1862
|
+
out = n(last, hint=hint, info=info, token=f"job.{path}",
|
|
1863
|
+
formats=None if last in tp.NO_FORMATS
|
|
1864
|
+
else tp.format_options(v, frac))
|
|
1865
|
+
if "#" in path:
|
|
1866
|
+
out["placeholder"] = True
|
|
1867
|
+
if degree:
|
|
1868
|
+
out["degree"] = True
|
|
1869
|
+
return out
|
|
1786
1870
|
|
|
1787
1871
|
default_label = methods[self._time_method()][0]
|
|
1788
1872
|
remaining = [leaf("time.remaining.default", hint=default_label,
|
|
1789
|
-
info="
|
|
1790
|
-
"
|
|
1791
|
-
f"{default_label}).")]
|
|
1873
|
+
info="The method selected in Print time remaining "
|
|
1874
|
+
f"estimation method (now: {default_label}).")]
|
|
1792
1875
|
remaining += [leaf(f"time.remaining.{m}", info=methods[m][1])
|
|
1793
1876
|
for m in sorted(methods)]
|
|
1794
1877
|
fil = [
|
|
1795
1878
|
leaf("filament#.name"), leaf("filament#.material"),
|
|
1796
1879
|
leaf("filament#.color"), leaf("filament#.vendor"),
|
|
1797
|
-
leaf("filament#.grams", info="
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
leaf("filament#.nozzle_temperature", info="As sliced. The "
|
|
1804
|
-
"temperature in effect is whatever the G-code sets."),
|
|
1880
|
+
leaf("filament#.grams", info="As sliced."),
|
|
1881
|
+
leaf("filament#.extruder", info="The toolhead it prints with."),
|
|
1882
|
+
] + ([leaf("filament#.slot", info="multiACE slot feeding it.")]
|
|
1883
|
+
if self._ace_on else []) + [
|
|
1884
|
+
leaf("filament#.nozzle_temperature", info="As sliced; the "
|
|
1885
|
+
"G-code sets what's in effect.", degree=True),
|
|
1805
1886
|
leaf("filament#.nozzle_diameter", info="As sliced."),
|
|
1806
1887
|
leaf("filament#.bed_temperature", info="As sliced for the "
|
|
1807
1888
|
"plate type. In a multi-material print one filament's bed "
|
|
1808
|
-
"temperature wins, so the heated bed may run at another."
|
|
1889
|
+
"temperature wins, so the heated bed may run at another.",
|
|
1890
|
+
degree=True),
|
|
1809
1891
|
]
|
|
1810
|
-
|
|
1811
|
-
|
|
1892
|
+
queued = [leaf("queue.#.name"),
|
|
1893
|
+
leaf("queue.#.time", info="Slicer estimate."),
|
|
1894
|
+
leaf("queue.#.eta", info="If printed one after another."),
|
|
1895
|
+
leaf("queue.#.grams"), leaf("queue.#.meters"),
|
|
1896
|
+
leaf("queue.#.materials")]
|
|
1897
|
+
nxt = [leaf("queue.next.name"),
|
|
1898
|
+
leaf("queue.next.time", info="Slicer estimate."),
|
|
1899
|
+
leaf("queue.next.eta", info="When it should finish, after "
|
|
1900
|
+
"this print job."),
|
|
1901
|
+
leaf("queue.next.grams"), leaf("queue.next.meters"),
|
|
1902
|
+
leaf("queue.next.materials")]
|
|
1812
1903
|
return [
|
|
1813
1904
|
leaf("file"),
|
|
1814
|
-
leaf("progress", info="Through the
|
|
1905
|
+
leaf("progress", info="Through the file, 0-100."),
|
|
1815
1906
|
leaf("layer"), leaf("layers"),
|
|
1816
|
-
leaf("plate", hint="plate type", info="
|
|
1817
|
-
"and its forks)
|
|
1818
|
-
|
|
1819
|
-
"queue after this one."),
|
|
1907
|
+
leaf("plate", hint="plate type", info="Bambu Studio and "
|
|
1908
|
+
"OrcaSlicer (and its forks) only; other slicers have no "
|
|
1909
|
+
"plate types."),
|
|
1820
1910
|
n("time", children=[
|
|
1821
1911
|
n("remaining", children=remaining),
|
|
1822
|
-
leaf("time.elapsed", info="Print time
|
|
1823
|
-
"paused
|
|
1824
|
-
leaf("time.eta", info="
|
|
1825
|
-
"the selected method, in your time zone; +1d when "
|
|
1826
|
-
"it's tomorrow."),
|
|
1912
|
+
leaf("time.elapsed", info="Print time; stops while "
|
|
1913
|
+
"paused."),
|
|
1914
|
+
leaf("time.eta", info="Your time zone; +1d tomorrow."),
|
|
1827
1915
|
]),
|
|
1828
1916
|
n("filaments", hint="all filaments", children=[
|
|
1829
1917
|
leaf("filaments.names"), leaf("filaments.materials"),
|
|
@@ -1831,11 +1919,21 @@ class PushNotifications:
|
|
|
1831
1919
|
leaf("filaments.grams"),
|
|
1832
1920
|
leaf("filaments.total_grams")]),
|
|
1833
1921
|
n("filament#", hint="specific filament",
|
|
1834
|
-
info="
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1922
|
+
info="Replace # with the slicer's number.", children=fil),
|
|
1923
|
+
leaf("extruders", hint="toolheads used"),
|
|
1924
|
+
n("queue", hint="Moonraker's job queue", children=[
|
|
1925
|
+
leaf("queue.remaining", info="Print jobs waiting after "
|
|
1926
|
+
"this one."),
|
|
1927
|
+
leaf("queue.list"),
|
|
1928
|
+
n("next", children=nxt),
|
|
1929
|
+
n("#", hint="by position", info="Replace # with the "
|
|
1930
|
+
"position in the queue (1 = next).", children=queued),
|
|
1931
|
+
leaf("queue.time", info="All waiting print jobs, slicer "
|
|
1932
|
+
"estimates."),
|
|
1933
|
+
leaf("queue.eta", info="When the last one should finish."),
|
|
1934
|
+
leaf("queue.grams", info="All waiting print jobs."),
|
|
1935
|
+
leaf("queue.meters", info="All waiting print jobs."),
|
|
1936
|
+
]),
|
|
1839
1937
|
]
|
|
1840
1938
|
|
|
1841
1939
|
async def _ep_preview(self, web_request: Any) -> Dict[str, Any]:
|
|
@@ -72,11 +72,8 @@ class SnapmakerU1(Printer):
|
|
|
72
72
|
# The touchscreen's "Remaining": the slicer's estimate scaled by the
|
|
73
73
|
# share of the file still to print (confirmed against screen snapshots)
|
|
74
74
|
time_methods = {"snapmaker": (
|
|
75
|
-
"Snapmaker", "What the
|
|
76
|
-
"
|
|
77
|
-
"print. Ignores how fast the print actually runs, so it drifts on "
|
|
78
|
-
"prints that run slower than sliced; Blend was more accurate on "
|
|
79
|
-
"tested prints.")}
|
|
75
|
+
"Snapmaker", "What the touchscreen shows: slicer estimate × share "
|
|
76
|
+
"of the file left. Ignores the actual pace.")}
|
|
80
77
|
time_default = "snapmaker"
|
|
81
78
|
HINTS = {"temperature_sensor cavity": "cavity",
|
|
82
79
|
"dragonbreath": "chamber heater"}
|
|
@@ -143,17 +140,16 @@ class SnapmakerU1(Printer):
|
|
|
143
140
|
tp.node("color", token=f"{obj}.filament.color")]
|
|
144
141
|
if spoolman:
|
|
145
142
|
fil.append(tp.node(
|
|
146
|
-
"grams_left", info="
|
|
147
|
-
|
|
143
|
+
"grams_left", info="Left on the spool (Spoolman).",
|
|
144
|
+
token=f"{obj}.filament.grams_left",
|
|
148
145
|
formats=tp.format_options(640.0)))
|
|
149
|
-
out = [tp.node("filament", hint="
|
|
150
|
-
info="The filament
|
|
151
|
-
"printer
|
|
152
|
-
"Generated by pushraker.", children=fil)]
|
|
146
|
+
out = [tp.node("filament", hint="current",
|
|
147
|
+
info="The filament in this toolhead, as set on the "
|
|
148
|
+
"printer. Generated by pushraker.", children=fil)]
|
|
153
149
|
if "ace" in self.objects:
|
|
154
|
-
out.append(tp.node("slot", hint="multiACE
|
|
155
|
-
info="The
|
|
156
|
-
"
|
|
150
|
+
out.append(tp.node("slot", hint="multiACE",
|
|
151
|
+
info="The slot feeding this toolhead. "
|
|
152
|
+
"Generated by pushraker.",
|
|
157
153
|
token=f"{obj}.slot"))
|
|
158
154
|
return out
|
|
159
155
|
|
|
@@ -164,7 +160,7 @@ class SnapmakerU1(Printer):
|
|
|
164
160
|
st = state.get("purifier") or {}
|
|
165
161
|
ex = (st.get("exhaust_fan") or {}).get("speed")
|
|
166
162
|
inner = (st.get("inner_fan") or {}).get("speed")
|
|
167
|
-
speed = "
|
|
163
|
+
speed = ""
|
|
168
164
|
return [tp.node("purifier", hint="exhaust and inner fans", children=[
|
|
169
165
|
tp.node("exhaust_fan", children=[tp.node(
|
|
170
166
|
"speed", info=speed, token="purifier.exhaust_fan.speed",
|
|
@@ -174,8 +170,7 @@ class SnapmakerU1(Printer):
|
|
|
174
170
|
"speed", info=speed, token="purifier.inner_fan.speed",
|
|
175
171
|
formats=tp.format_options(inner if inner is not None
|
|
176
172
|
else 1.0, True))]),
|
|
177
|
-
tp.node("inner_fan_rpm",
|
|
178
|
-
token="purifier.inner_fan_rpm"),
|
|
173
|
+
tp.node("inner_fan_rpm", token="purifier.inner_fan_rpm"),
|
|
179
174
|
])]
|
|
180
175
|
|
|
181
176
|
def left_seconds(self, method: str, ctx: Dict[str, Any]) -> Optional[float]:
|
|
@@ -28,7 +28,7 @@ notification.
|
|
|
28
28
|
from __future__ import annotations
|
|
29
29
|
import datetime
|
|
30
30
|
import re
|
|
31
|
-
from typing import Any, Callable, Dict, List, Optional, Sequence
|
|
31
|
+
from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple
|
|
32
32
|
|
|
33
33
|
NA = "n/a"
|
|
34
34
|
# {object.field}, {object with space.field.sub}, {job.filament2.name|fmt}
|
|
@@ -113,49 +113,68 @@ class Clock:
|
|
|
113
113
|
|
|
114
114
|
|
|
115
115
|
def format_duration(seconds: float) -> str:
|
|
116
|
-
|
|
117
|
-
|
|
116
|
+
"""1d 3h 12m, 3h 12m, 12m (the default for durations)."""
|
|
117
|
+
total = max(0, int(round(seconds / 60.)))
|
|
118
|
+
d, rest = divmod(total, 1440)
|
|
119
|
+
h, m = divmod(rest, 60)
|
|
120
|
+
if d:
|
|
121
|
+
return f"{d}d {h}h {m:02d}m"
|
|
118
122
|
if h:
|
|
119
123
|
return f"{h}h {m:02d}m"
|
|
120
|
-
return f"{m}m"
|
|
124
|
+
return f"{m}m"
|
|
121
125
|
|
|
122
126
|
|
|
123
|
-
|
|
127
|
+
# A pattern: "quoted text", words, and anything else. A word made only of
|
|
128
|
+
# D, H and M letters is a field (DD, H, HHMM...); any other word ("days",
|
|
129
|
+
# "min") prints as typed.
|
|
130
|
+
RX_PATTERN = re.compile(r'"([^"]*)"|([A-Za-z]+)|(.)', re.S)
|
|
131
|
+
RX_FIELDS = re.compile(r"[dD]+|[hH]+|[mM]+")
|
|
124
132
|
UNIT_MINUTES = {"d": 1440, "h": 60, "m": 1}
|
|
125
133
|
|
|
126
134
|
|
|
135
|
+
def _pattern_parts(pattern: str) -> List[Tuple[str, str]]:
|
|
136
|
+
"""[(kind, text)]: kind "unit" (a run of one letter) or "text"."""
|
|
137
|
+
out: List[Tuple[str, str]] = []
|
|
138
|
+
for m in RX_PATTERN.finditer(pattern):
|
|
139
|
+
quoted, word, other = m.group(1), m.group(2), m.group(3)
|
|
140
|
+
if quoted is not None:
|
|
141
|
+
out.append(("text", quoted))
|
|
142
|
+
elif word is not None and re.fullmatch(r"[dDhHmM]+", word):
|
|
143
|
+
out += [("unit", r.group(0)) for r in RX_FIELDS.finditer(word)]
|
|
144
|
+
else:
|
|
145
|
+
out.append(("text", word if word is not None else other))
|
|
146
|
+
return out
|
|
147
|
+
|
|
148
|
+
|
|
127
149
|
def apply_pattern(pattern: str, minutes: int,
|
|
128
150
|
units_total: bool = True) -> str:
|
|
129
151
|
"""D/H/M pattern over a number of minutes. units_total: the largest
|
|
130
152
|
unit in the pattern carries the total (durations); otherwise each
|
|
131
153
|
unit is the clock's own field (hours 0-23, minutes 0-59)."""
|
|
132
|
-
parts =
|
|
133
|
-
|
|
134
|
-
present = [u[0].lower() for _, u, _ in parts if u]
|
|
135
|
-
order = [u for u in ("d", "h", "m") if u in present]
|
|
154
|
+
parts = _pattern_parts(pattern)
|
|
155
|
+
present = {t[0].lower() for k, t in parts if k == "unit"}
|
|
136
156
|
values: Dict[str, int] = {}
|
|
137
157
|
if units_total:
|
|
138
158
|
left = minutes
|
|
139
|
-
for u in
|
|
140
|
-
|
|
141
|
-
|
|
159
|
+
for u in ("d", "h", "m"):
|
|
160
|
+
if u in present:
|
|
161
|
+
values[u] = left // UNIT_MINUTES[u]
|
|
162
|
+
left -= values[u] * UNIT_MINUTES[u]
|
|
142
163
|
else:
|
|
143
164
|
values = {"d": minutes // 1440, "h": (minutes // 60) % 24,
|
|
144
165
|
"m": minutes % 60}
|
|
145
166
|
out = []
|
|
146
|
-
for
|
|
147
|
-
if
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
v = values.get(unit[0].lower(), 0)
|
|
151
|
-
out.append(f"{v:02d}" if len(unit) >= 2 else str(v))
|
|
167
|
+
for kind, text in parts:
|
|
168
|
+
if kind == "unit":
|
|
169
|
+
v = values.get(text[0].lower(), 0)
|
|
170
|
+
out.append(f"{v:02d}" if len(text) >= 2 else str(v))
|
|
152
171
|
else:
|
|
153
|
-
out.append(
|
|
172
|
+
out.append(text)
|
|
154
173
|
return "".join(out)
|
|
155
174
|
|
|
156
175
|
|
|
157
176
|
def is_pattern(fmt: str) -> bool:
|
|
158
|
-
return
|
|
177
|
+
return any(k == "unit" for k, _ in _pattern_parts(fmt))
|
|
159
178
|
|
|
160
179
|
|
|
161
180
|
def fmt_value(value: Any, fmt: str) -> str:
|
|
@@ -175,8 +194,10 @@ def fmt_value(value: Any, fmt: str) -> str:
|
|
|
175
194
|
if fmt and is_pattern(fmt) else value.at.strftime("%H:%M")
|
|
176
195
|
return (f"+{value.days}d " if value.days > 0 else "") + text
|
|
177
196
|
if isinstance(value, (list, tuple)):
|
|
178
|
-
|
|
179
|
-
|
|
197
|
+
sep = "\n" if low == "line" else ", "
|
|
198
|
+
inner = "" if low in ("line", "comma") else fmt
|
|
199
|
+
items = [fmt_value(v, inner) for v in value]
|
|
200
|
+
return sep.join(i for i in items if i != NA) or NA
|
|
180
201
|
if isinstance(value, dict):
|
|
181
202
|
return ", ".join(f"{k}: {fmt_value(v, fmt)}" for k, v in value.items()
|
|
182
203
|
) or NA
|
|
@@ -222,16 +243,28 @@ def render(text: str, resolve: Callable[[Token], Any]) -> str:
|
|
|
222
243
|
|
|
223
244
|
# ---- the picker's tree ------------------------------------------------------
|
|
224
245
|
|
|
246
|
+
# The examples the picker shows for time formats: every field filled
|
|
247
|
+
EXAMPLE_DURATION = Duration((24 * 60 + 3 * 60 + 12) * 60.) # 1d 3h 12m
|
|
248
|
+
TIME_FORMATS = ("", "D H:MM", "H:MM", "HH:MM", "M", 'D"d" H"h" MM"m"')
|
|
249
|
+
CLOCK_FORMATS = ("", "H:MM")
|
|
250
|
+
|
|
251
|
+
|
|
225
252
|
def format_options(value: Any, fraction: bool = False
|
|
226
253
|
) -> List[Dict[str, str]]:
|
|
227
254
|
"""The formats the picker offers for a value, each with how it reads:
|
|
228
|
-
[{"label": "219.8", "fmt": "1"}]. Empty: no choice to make.
|
|
255
|
+
[{"label": "219.8", "fmt": "1"}]. Empty: no choice to make. Time
|
|
256
|
+
formats read on a fixed example (1d 3h 12m; 09:05 tomorrow), so every
|
|
257
|
+
field shows."""
|
|
229
258
|
if isinstance(value, Duration):
|
|
230
|
-
return [{"label": fmt_value(
|
|
231
|
-
for f in
|
|
259
|
+
return [{"label": fmt_value(EXAMPLE_DURATION, f), "fmt": f}
|
|
260
|
+
for f in TIME_FORMATS]
|
|
232
261
|
if isinstance(value, Clock):
|
|
233
|
-
|
|
234
|
-
|
|
262
|
+
example = Clock(datetime.datetime(2026, 1, 2, 9, 5), 1)
|
|
263
|
+
return [{"label": fmt_value(example, f), "fmt": f}
|
|
264
|
+
for f in CLOCK_FORMATS]
|
|
265
|
+
if isinstance(value, (list, tuple)):
|
|
266
|
+
return [{"label": "a, b, c", "fmt": ""},
|
|
267
|
+
{"label": "one per line", "fmt": "line"}]
|
|
235
268
|
if isinstance(value, bool) or not isinstance(value, (int, float)):
|
|
236
269
|
return []
|
|
237
270
|
if fraction:
|
|
@@ -269,23 +302,22 @@ def node(name: str, hint: str = "", info: str = "",
|
|
|
269
302
|
# info, the value is a 0-1 fraction)
|
|
270
303
|
HEATER_FIELDS = [
|
|
271
304
|
("temperature", "now", "", False),
|
|
272
|
-
("target", "set", "
|
|
273
|
-
("power", "heater power", "
|
|
274
|
-
True)]
|
|
305
|
+
("target", "set", "0 when off.", False),
|
|
306
|
+
("power", "heater power", "", True)]
|
|
275
307
|
EXTRUDER_FIELDS = [
|
|
276
308
|
("temperature", "nozzle, now", "", False),
|
|
277
|
-
("target", "nozzle, set", "
|
|
278
|
-
|
|
279
|
-
("power", "heater power", "How hard the nozzle heater is working, "
|
|
280
|
-
"0-100 %.", True),
|
|
309
|
+
("target", "nozzle, set", "0 when off.", False),
|
|
310
|
+
("power", "heater power", "", True),
|
|
281
311
|
("nozzle_diameter", "mm", "", False)]
|
|
282
312
|
# Values whose decimals aren't a choice (a 0.4 nozzle is never "0")
|
|
283
313
|
NO_FORMATS = {"nozzle_diameter"}
|
|
314
|
+
# Temperatures: the picker offers °C after their decimals
|
|
315
|
+
DEGREE_FIELDS = {"temperature", "target", "nozzle_temperature",
|
|
316
|
+
"bed_temperature"}
|
|
284
317
|
SENSOR_FIELDS = [("temperature", "now", "", False)]
|
|
285
318
|
FAN_FIELDS = [
|
|
286
|
-
("speed", "", "
|
|
287
|
-
("rpm", "", "
|
|
288
|
-
False)]
|
|
319
|
+
("speed", "", "", True),
|
|
320
|
+
("rpm", "", "Fans with a tachometer only.", False)]
|
|
289
321
|
THERMAL_TYPES = {"heater_bed": HEATER_FIELDS, "heater_generic": HEATER_FIELDS,
|
|
290
322
|
"temperature_sensor": SENSOR_FIELDS,
|
|
291
323
|
"temperature_host": SENSOR_FIELDS,
|
|
@@ -298,9 +330,9 @@ FAN_TYPES = {"fan": FAN_FIELDS, "fan_generic": FAN_FIELDS,
|
|
|
298
330
|
GENERIC_HINTS = {"heater_bed": "heated bed", "fan": "part cooling fan",
|
|
299
331
|
"temperature_host": "host computer"}
|
|
300
332
|
FIELD_INFO = {
|
|
301
|
-
"filament_detected": "yes
|
|
302
|
-
"enabled": "
|
|
303
|
-
"value": "
|
|
333
|
+
"filament_detected": "yes / no.",
|
|
334
|
+
"enabled": "Sensor switched on: yes / no.",
|
|
335
|
+
"value": "0-1 (1 = fully on).",
|
|
304
336
|
}
|
|
305
337
|
# Klipper's and Moonraker's internals: never offered (typing a token for
|
|
306
338
|
# one still works)
|
|
@@ -315,7 +347,7 @@ HIDDEN = {
|
|
|
315
347
|
"stepper_enable", "menu", "board_pins", "gcode_arcs", "pid_calibrate",
|
|
316
348
|
"garbage_collection", "heaters",
|
|
317
349
|
}
|
|
318
|
-
HIDDEN_PREFIXES = ("gcode_macro ", "mcu", "stepper_", "extruder_stepper ",
|
|
350
|
+
HIDDEN_PREFIXES = ("gcode_macro ", "mcu", "stepper_", "tmc", "extruder_stepper ",
|
|
319
351
|
"manual_stepper ", "gcode_button ", "delayed_gcode ",
|
|
320
352
|
"duplicate_pin_override", "verify_heater ", "bed_mesh ",
|
|
321
353
|
"adxl345", "lis2dw", "display", "endstop_phase",
|
|
@@ -344,7 +376,7 @@ def fields_tree(obj: str, values: Dict[str, Any], prefix: str = "",
|
|
|
344
376
|
kids = fields_tree(obj, v, f"{path}.", depth + 1)
|
|
345
377
|
if kids:
|
|
346
378
|
out.append(node(k, children=kids))
|
|
347
|
-
elif isinstance(v, (int, float, str, bool))
|
|
379
|
+
elif isinstance(v, (int, float, str, bool)):
|
|
348
380
|
out.append(node(k, info=FIELD_INFO.get(k, ""),
|
|
349
381
|
token=f"{obj}.{path}",
|
|
350
382
|
formats=format_options(v)))
|
|
@@ -198,18 +198,20 @@
|
|
|
198
198
|
.pr-row { display: flex; align-items: center; gap: 6px; padding: 6px 10px; border-top: 1px solid #2a2a2a; color: #ddd; cursor: pointer; flex-wrap: wrap; }
|
|
199
199
|
.pr-pick > .pr-row:first-child { border-top: none; }
|
|
200
200
|
.pr-row:hover { background: #262626; }
|
|
201
|
-
.pr-row .pr-ar { color: var(--muted); font-size:
|
|
201
|
+
.pr-row .pr-ar { color: var(--muted); font-size: 15px; width: 16px; flex: none; line-height: 1; text-align: center; }
|
|
202
202
|
.pr-row code { font-family: monospace; font-size: 12px; color: var(--text); }
|
|
203
203
|
.pr-row.pr-leaf code { color: var(--accent); }
|
|
204
204
|
.pr-row small { color: var(--muted); font-size: 11px; }
|
|
205
205
|
.pr-row.pr-cat { color: #fff; font-weight: 600; border-top: 1px solid #333; }
|
|
206
206
|
.pr-row.pr-cat a { font-size: 12px; font-weight: normal; }
|
|
207
207
|
.pr-row.pr-sel { background: #263238; }
|
|
208
|
-
.pr-deg { background: #555; color: #fff; border: none; border-radius: 5px; font-size: 12px; font-weight: 600; padding:
|
|
208
|
+
.pr-deg { background: #555; color: #fff; border: none; border-radius: 5px; font-size: 12px; font-weight: 600; padding: 3px 9px; font-family: inherit; cursor: pointer; margin: 0 0 4px 14px; }
|
|
209
209
|
.pr-deg:hover { background: #666; }
|
|
210
|
-
.pr-row .nt-i { width:
|
|
211
|
-
|
|
212
|
-
|
|
210
|
+
.pr-row .nt-i, .pr-fmt .nt-i { width: 17px; height: 17px; font-size: 12px; }
|
|
211
|
+
/* The (i) explanations: a tooltip (hover on a computer; a click or tap
|
|
212
|
+
keeps it open until the next click or tap anywhere) */
|
|
213
|
+
.pr-tip { display: none; position: fixed; z-index: 30; max-width: 320px; background: #1e1e1e; border: 1px solid #555; border-radius: 8px; padding: 8px 10px; font-size: 12px; line-height: 1.4; color: var(--text); box-shadow: 0 6px 20px rgba(0,0,0,0.5); }
|
|
214
|
+
.pr-tip a { margin-left: 4px; }
|
|
213
215
|
.pr-fmt { padding: 6px 10px 8px; border-top: 1px solid #2a2a2a; background: #181818; }
|
|
214
216
|
.pr-fmt .pr-lbl { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
|
|
215
217
|
.pr-fmt button.pr-f { background: #2a2a2a; color: var(--accent); border: 1px solid #555; border-radius: 5px; font-size: 12px; padding: 3px 9px; margin: 0 4px 4px 0; font-family: monospace; cursor: pointer; }
|
|
@@ -835,12 +837,13 @@
|
|
|
835
837
|
return catalogue;
|
|
836
838
|
}
|
|
837
839
|
const FMT_INFO = {
|
|
838
|
-
decimals: '
|
|
839
|
-
percent: '|pct
|
|
840
|
-
time: 'D days, H hours, M minutes,
|
|
840
|
+
decimals: 'Decimal places.',
|
|
841
|
+
percent: '|pct: a 0-1 value as a percentage.',
|
|
842
|
+
time: 'D days, H hours, M minutes, any case; doubled = two digits. The largest one carries the total. Other words print as typed. Type your own after the |.'
|
|
841
843
|
};
|
|
842
844
|
function fmtKind(formats) {
|
|
843
845
|
if (formats.some(f => /[hm]/i.test(f.fmt))) return 'time';
|
|
846
|
+
if (formats.some(f => f.fmt === 'line')) return 'list';
|
|
844
847
|
if (formats.some(f => f.fmt === 'pct')) return 'percent';
|
|
845
848
|
return 'decimals';
|
|
846
849
|
}
|
|
@@ -859,8 +862,9 @@
|
|
|
859
862
|
if (n.children) html += n.children.map(k => nodeHtml(k, depth + 1)).join('');
|
|
860
863
|
if (n.formats) {
|
|
861
864
|
const kind = fmtKind(n.formats);
|
|
862
|
-
html += `<div class="pr-fmt" style="padding-left:${pad + 16}px"><div class="pr-lbl">${kind === '
|
|
863
|
-
n.formats.map(f => `<button type="button" class="pr-f" data-token="${esc(n.token)}" data-fmt="${esc(f.fmt)}"${n.placeholder ? ' data-ph="1"' : ''}>${esc(f.label)}<small>${f.fmt ? '|' + esc(f.fmt) : 'default'}</small></button>`).join('') +
|
|
865
|
+
html += `<div class="pr-fmt" style="padding-left:${pad + 16}px"><div class="pr-lbl">${kind === 'decimals' ? 'Decimals' : kind === 'percent' ? 'Shown as' : 'Format'}${infoButton(FMT_INFO[kind])}</div>` +
|
|
866
|
+
n.formats.map(f => `<button type="button" class="pr-f" data-token="${esc(n.token)}" data-fmt="${esc(f.fmt)}"${n.placeholder ? ' data-ph="1"' : ''}>${esc(f.label)}<small>${f.fmt ? '|' + esc(f.fmt) : 'default'}</small></button>`).join('') +
|
|
867
|
+
(n.degree ? '<button type="button" class="pr-deg">°C</button>' : '') + '</div>';
|
|
864
868
|
}
|
|
865
869
|
html += '</div>';
|
|
866
870
|
}
|
|
@@ -873,15 +877,13 @@
|
|
|
873
877
|
return;
|
|
874
878
|
}
|
|
875
879
|
pick.innerHTML = cats.map(c =>
|
|
876
|
-
`<div class="pr-row pr-cat" data-node><span class="pr-ar">▸</span>${esc(c.label)}${infoButton(c.info, c.guide)}
|
|
877
|
-
(c.degree ? '<button type="button" class="pr-deg" data-insert="°C">°C</button>' : '') + '</div>' +
|
|
880
|
+
`<div class="pr-row pr-cat" data-node><span class="pr-ar">▸</span>${esc(c.label)}${infoButton(c.info, c.guide)}</div>` +
|
|
878
881
|
`<div class="pr-kids" style="display:none">${c.children.map(n => nodeHtml(n, 1)).join('')}</div>`).join('') +
|
|
879
882
|
'<div class="pr-any">Or type any <code>{object.field}</code>: <a href="https://www.klipper3d.org/Status_Reference.html" target="_blank">Klipper status reference</a> · <a href="' + GUIDE + '#adding-data" target="_blank">Guide</a></div>';
|
|
880
883
|
pick.querySelectorAll('[data-node]').forEach(row => {
|
|
881
884
|
row.onclick = e => {
|
|
882
885
|
if (e.target.closest('a')) return;
|
|
883
|
-
if (e.target.closest('.pr-info'))
|
|
884
|
-
if (e.target.closest('.pr-deg')) { insertText('°C'); return; }
|
|
886
|
+
if (e.target.closest('.pr-info')) return;
|
|
885
887
|
if (row.dataset.token) { insertToken(row.dataset.token, '', !!row.dataset.ph); return; }
|
|
886
888
|
const kids = row.nextElementSibling;
|
|
887
889
|
if (!kids || !kids.classList.contains('pr-kids')) return;
|
|
@@ -891,35 +893,56 @@
|
|
|
891
893
|
row.classList.toggle('pr-sel', open && !!kids.querySelector(':scope > .pr-fmt'));
|
|
892
894
|
};
|
|
893
895
|
});
|
|
894
|
-
pick
|
|
895
|
-
|
|
896
|
-
});
|
|
896
|
+
wireTips(pick);
|
|
897
|
+
pick.onscroll = hideTip;
|
|
898
|
+
pick.querySelectorAll('.pr-deg').forEach(b => { b.onclick = () => insertText('°C'); });
|
|
897
899
|
pick.querySelectorAll('.pr-f').forEach(b => {
|
|
898
900
|
b.onclick = () => insertToken(b.dataset.token, b.dataset.fmt, !!b.dataset.ph);
|
|
899
901
|
});
|
|
900
902
|
}
|
|
901
|
-
//
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
const tip = document.createElement('div');
|
|
910
|
-
tip.className = 'pr-tipline';
|
|
911
|
-
tip.textContent = btn.dataset.info;
|
|
903
|
+
// (i): a tooltip on hover (computer); a click or tap keeps it open,
|
|
904
|
+
// and the next click or tap anywhere closes it and does what it does
|
|
905
|
+
const tipBox = document.createElement('div');
|
|
906
|
+
tipBox.className = 'pr-tip';
|
|
907
|
+
document.body.append(tipBox);
|
|
908
|
+
let tipPinned = null, tipShown = null;
|
|
909
|
+
function showTip(btn) {
|
|
910
|
+
tipBox.textContent = btn.dataset.info;
|
|
912
911
|
if (btn.dataset.guide) {
|
|
913
912
|
const a = document.createElement('a');
|
|
914
913
|
a.href = `${GUIDE}#${btn.dataset.guide}`;
|
|
915
914
|
a.target = '_blank';
|
|
916
|
-
a.textContent = '
|
|
917
|
-
|
|
915
|
+
a.textContent = 'Guide';
|
|
916
|
+
tipBox.append(a);
|
|
918
917
|
}
|
|
919
|
-
|
|
920
|
-
|
|
918
|
+
tipBox.style.display = 'block';
|
|
919
|
+
const r = btn.getBoundingClientRect(), w = tipBox.offsetWidth, h = tipBox.offsetHeight;
|
|
920
|
+
tipBox.style.left = Math.max(8, Math.min(r.left, innerWidth - w - 8)) + 'px';
|
|
921
|
+
tipBox.style.top = (r.bottom + 6 + h > innerHeight ? r.top - h - 6 : r.bottom + 6) + 'px';
|
|
922
|
+
if (tipShown) tipShown.classList.remove('on');
|
|
923
|
+
tipShown = btn;
|
|
921
924
|
btn.classList.add('on');
|
|
922
925
|
}
|
|
926
|
+
function hideTip() {
|
|
927
|
+
tipBox.style.display = 'none';
|
|
928
|
+
if (tipShown) tipShown.classList.remove('on');
|
|
929
|
+
tipShown = tipPinned = null;
|
|
930
|
+
}
|
|
931
|
+
document.addEventListener('click', e => {
|
|
932
|
+
if (!e.target.closest('.pr-info') && !e.target.closest('.pr-tip')) hideTip();
|
|
933
|
+
}, true);
|
|
934
|
+
function wireTips(root) {
|
|
935
|
+
root.querySelectorAll('.pr-info').forEach(b => {
|
|
936
|
+
b.onmouseenter = () => { if (matchMedia('(hover: hover)').matches && !tipPinned) showTip(b); };
|
|
937
|
+
b.onmouseleave = () => { if (!tipPinned) hideTip(); };
|
|
938
|
+
b.onclick = e => {
|
|
939
|
+
e.stopPropagation();
|
|
940
|
+
if (tipPinned === b) { hideTip(); return; }
|
|
941
|
+
showTip(b);
|
|
942
|
+
tipPinned = b;
|
|
943
|
+
};
|
|
944
|
+
});
|
|
945
|
+
}
|
|
923
946
|
function insertText(text, selectFrom, selectLen) {
|
|
924
947
|
const ta = el('pr-data-text');
|
|
925
948
|
toCustom();
|
|
@@ -977,13 +1000,13 @@
|
|
|
977
1000
|
try {
|
|
978
1001
|
const r = await api('/server/pushraker/preview', 'POST', { row: rid, text });
|
|
979
1002
|
rendered = (r && r.text) || '';
|
|
980
|
-
note = r && r.live_job ? 'The current print job
|
|
1003
|
+
note = r && r.live_job ? 'The current print job and the printer\'s current values.' : 'A sample print job (40 Benchies, four filaments) and the printer\'s current values.';
|
|
981
1004
|
} catch (e) {
|
|
982
1005
|
note = 'Preview unavailable: ' + e.message;
|
|
983
1006
|
}
|
|
984
1007
|
}
|
|
985
|
-
box.innerHTML = `<div class="pr-pt">${esc(title)}</div>
|
|
986
|
-
(rid === 'started' ? 'Estimated print time
|
|
1008
|
+
box.innerHTML = `<div class="pr-pt">${esc(title)}</div>3DBenchy_x40_4colour\n` +
|
|
1009
|
+
(rid === 'started' ? 'Estimated print time 1d 22h 03m\n' : rid === 'complete' ? 'Print time: 1d 21h 40m\n' : '') +
|
|
987
1010
|
(rendered ? `<span class="pr-px">${esc(rendered)}</span>` : '<span class="pr-pn">(no data added)</span>');
|
|
988
1011
|
el('pr-note').textContent = note;
|
|
989
1012
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pushraker
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.3
|
|
4
4
|
Summary: Push notifications for Klipper printers: a Moonraker component with pictures, sent through Apprise (ntfy, Pushover, Telegram, Discord, webhooks, email)
|
|
5
5
|
Author: noon92
|
|
6
6
|
License-Expression: GPL-3.0-or-later
|
|
@@ -2400,7 +2400,9 @@ async def test_data():
|
|
|
2400
2400
|
STATE["fan"] = {"speed": 0.55, "rpm": None}
|
|
2401
2401
|
STATE["purifier"] = {"exhaust_fan": {"speed": 0.4}, "inner_fan":
|
|
2402
2402
|
{"speed": 1.0}, "inner_fan_rpm": 3200}
|
|
2403
|
-
STATE["some_addon"] = {"state": "idle", "count": 3, "nested": {"x": 1.5}
|
|
2403
|
+
STATE["some_addon"] = {"state": "idle", "count": 3, "nested": {"x": 1.5},
|
|
2404
|
+
"unknown": None}
|
|
2405
|
+
STATE["tmc2209 stepper_z"] = {"temperature": None, "run_current": 0.8}
|
|
2404
2406
|
STATE["temperature_sensor cavity"] = {"temperature": 31.0}
|
|
2405
2407
|
STATE["print_task_config"] = {"extruder_map_table": [2, 0, 1, 3],
|
|
2406
2408
|
"filament_type": ["PETG", "PLA", "PLA", "NONE"],
|
|
@@ -2482,11 +2484,19 @@ async def test_data():
|
|
|
2482
2484
|
out = await c._ep_preview(WebRequest("POST", {"row": "started", "text":
|
|
2483
2485
|
"{job.file} {job.filaments} {job.filament1.material} "
|
|
2484
2486
|
"{heater_bed.temperature|0} {job.extruders} {job.filament29.name} "
|
|
2485
|
-
"{job.filament29.extruder} {job.time.remaining|H:MM} {job.filament#.name}"
|
|
2487
|
+
"{job.filament29.extruder} {job.time.remaining|H:MM} {job.filament#.name}"
|
|
2488
|
+
" | {job.filaments.materials} | {job.time.remaining|D days H hours M minutes}"
|
|
2489
|
+
" | {job.queue.remaining} {job.queue.next} {job.queue.2.time|H:MM}"
|
|
2490
|
+
" {job.queue.meters} {job.queue.next.meters}"
|
|
2491
|
+
" {job.queue.list|line}"}))
|
|
2486
2492
|
check("preview: the sample Benchy for job values, any filament number, "
|
|
2487
2493
|
"the printer's live values for Klipper objects; # reads n/a",
|
|
2488
|
-
out["text"] == "
|
|
2489
|
-
"
|
|
2494
|
+
out["text"] == "3DBenchy_x40_4colour PLA Basic White, PETG HF Black, "
|
|
2495
|
+
"TPU 95A Orange, PLA Matte Grey PLA 60 extruder, extruder1, "
|
|
2496
|
+
"extruder2, extruder3 PLA Basic White extruder 27:12 n/a"
|
|
2497
|
+
" | PLA, PETG, TPU, PLA | 1 days 3 hours 12 minutes"
|
|
2498
|
+
" | 3 Cable_clips_x12_PETG 2:12 53.4 7.32 Cable_clips_x12_PETG\n"
|
|
2499
|
+
"Spool_holder_PLA\nPhone_stand_PLA_TPU"
|
|
2490
2500
|
and not out["live_job"] and out["placeholders"]
|
|
2491
2501
|
== ["{job.filament#.name}"], out)
|
|
2492
2502
|
cat = await c._ep_objects(WebRequest("GET"))
|
|
@@ -2512,8 +2522,22 @@ async def test_data():
|
|
|
2512
2522
|
names(job["time"]["children"]) == ["remaining", "elapsed", "eta"]
|
|
2513
2523
|
and names(rem["children"])[0] == "default"
|
|
2514
2524
|
and names(rem["children"])[1:] == sorted(names(rem["children"])[1:])
|
|
2515
|
-
and [f["
|
|
2516
|
-
== ["", "
|
|
2525
|
+
and [f["label"] for f in rem["children"][0]["formats"]]
|
|
2526
|
+
== ["1d 3h 12m", "1 3:12", "27:12", "27:12", "1632", "1d 3h 12m"],
|
|
2527
|
+
[f["label"] for f in rem["children"][0]["formats"]])
|
|
2528
|
+
check("queue: remaining, list, next, by position, time, eta, grams",
|
|
2529
|
+
names(job["queue"]["children"]) == ["remaining", "list", "next",
|
|
2530
|
+
"#", "time", "eta", "grams",
|
|
2531
|
+
"meters"],
|
|
2532
|
+
names(job["queue"]["children"]))
|
|
2533
|
+
check("a driver without a temperature isn't offered; nor a value "
|
|
2534
|
+
"that isn't there",
|
|
2535
|
+
"stepper_z" not in str(cat) and "some_addon.unknown" not in str(cat),
|
|
2536
|
+
[c["id"] for c in cat["categories"]])
|
|
2537
|
+
check("°C offered after the decimals of temperatures",
|
|
2538
|
+
ext1["children"][0].get("degree")
|
|
2539
|
+
and not [k for k in ext1["children"] if k["name"] == "power"][0]
|
|
2540
|
+
.get("degree"), ext1["children"][0])
|
|
2517
2541
|
check("filament#: the placeholder, every value as the slicer gives it",
|
|
2518
2542
|
job["filament#"]["children"][0]["token"] == "job.filament#.name"
|
|
2519
2543
|
and job["filament#"]["children"][0].get("placeholder"), job["filament#"])
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|