Add icons for prusalink sensors and buttons (#87256)
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
This commit is contained in:
parent
923abdb02a
commit
e77e49a87a
2 changed files with 6 additions and 0 deletions
|
@ -39,6 +39,7 @@ BUTTONS: dict[str, tuple[PrusaLinkButtonEntityDescription, ...]] = {
|
|||
PrusaLinkButtonEntityDescription[PrinterInfo](
|
||||
key="printer.cancel_job",
|
||||
name="Cancel Job",
|
||||
icon="mdi:cancel",
|
||||
press_fn=lambda api: cast(Coroutine, api.cancel_job()),
|
||||
available_fn=lambda data: any(
|
||||
data["state"]["flags"][flag]
|
||||
|
@ -48,6 +49,7 @@ BUTTONS: dict[str, tuple[PrusaLinkButtonEntityDescription, ...]] = {
|
|||
PrusaLinkButtonEntityDescription[PrinterInfo](
|
||||
key="job.pause_job",
|
||||
name="Pause Job",
|
||||
icon="mdi:pause",
|
||||
press_fn=lambda api: cast(Coroutine, api.pause_job()),
|
||||
available_fn=lambda data: (
|
||||
data["state"]["flags"]["printing"]
|
||||
|
@ -57,6 +59,7 @@ BUTTONS: dict[str, tuple[PrusaLinkButtonEntityDescription, ...]] = {
|
|||
PrusaLinkButtonEntityDescription[PrinterInfo](
|
||||
key="job.resume_job",
|
||||
name="Resume Job",
|
||||
icon="mdi:play",
|
||||
press_fn=lambda api: cast(Coroutine, api.resume_job()),
|
||||
available_fn=lambda data: cast(bool, data["state"]["flags"]["paused"]),
|
||||
),
|
||||
|
|
|
@ -86,6 +86,7 @@ SENSORS: dict[str, tuple[PrusaLinkSensorEntityDescription, ...]] = {
|
|||
PrusaLinkSensorEntityDescription[JobInfo](
|
||||
key="job.progress",
|
||||
name="Progress",
|
||||
icon="mdi:progress-clock",
|
||||
native_unit_of_measurement=PERCENTAGE,
|
||||
value_fn=lambda data: cast(float, data["progress"]["completion"]) * 100,
|
||||
available_fn=lambda data: data.get("progress") is not None,
|
||||
|
@ -101,6 +102,7 @@ SENSORS: dict[str, tuple[PrusaLinkSensorEntityDescription, ...]] = {
|
|||
key="job.start",
|
||||
name="Print Start",
|
||||
device_class=SensorDeviceClass.TIMESTAMP,
|
||||
icon="mdi:clock-start",
|
||||
value_fn=ignore_variance(
|
||||
lambda data: (
|
||||
utcnow() - timedelta(seconds=data["progress"]["printTime"])
|
||||
|
@ -112,6 +114,7 @@ SENSORS: dict[str, tuple[PrusaLinkSensorEntityDescription, ...]] = {
|
|||
PrusaLinkSensorEntityDescription[JobInfo](
|
||||
key="job.finish",
|
||||
name="Print Finish",
|
||||
icon="mdi:clock-end",
|
||||
device_class=SensorDeviceClass.TIMESTAMP,
|
||||
value_fn=ignore_variance(
|
||||
lambda data: (
|
||||
|
|
Loading…
Add table
Reference in a new issue