Add icons for prusalink sensors and buttons (#87256)

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
This commit is contained in:
Paul Bottein 2023-02-03 16:03:15 +01:00 committed by GitHub
parent 923abdb02a
commit e77e49a87a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 0 deletions

View file

@ -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"]),
),

View file

@ -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: (