-
-
Notifications
You must be signed in to change notification settings - Fork 37.5k
prusalink: add X/Y axis, location, and min extrusion temp sensors #169312
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
7bb5b5a
f5dc59e
eb183b2
5279cf4
b7bf6d9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,6 +46,7 @@ class PrusaLinkSensorEntityDescription( | |
| """Describes PrusaLink sensor entity.""" | ||
|
|
||
| available_fn: Callable[[T], bool] = lambda _: True | ||
| supported_fn: Callable[[T], bool] = lambda _: True | ||
|
|
||
|
|
||
| SENSORS: dict[str, tuple[PrusaLinkSensorEntityDescription, ...]] = { | ||
|
|
@@ -103,6 +104,26 @@ class PrusaLinkSensorEntityDescription( | |
| value_fn=lambda data: cast(float, data["printer"]["axis_z"]), | ||
| entity_registry_enabled_default=False, | ||
| ), | ||
| PrusaLinkSensorEntityDescription[PrinterStatus]( | ||
| key="printer.telemetry.x-position", | ||
| translation_key="x_position", | ||
| native_unit_of_measurement=UnitOfLength.MILLIMETERS, | ||
| device_class=SensorDeviceClass.DISTANCE, | ||
| state_class=SensorStateClass.MEASUREMENT, | ||
| value_fn=lambda data: cast(float, data["printer"]["axis_x"]), | ||
| supported_fn=lambda data: data["printer"].get("axis_x") is not None, | ||
| entity_registry_enabled_default=False, | ||
| ), | ||
| PrusaLinkSensorEntityDescription[PrinterStatus]( | ||
| key="printer.telemetry.y-position", | ||
| translation_key="y_position", | ||
| native_unit_of_measurement=UnitOfLength.MILLIMETERS, | ||
| device_class=SensorDeviceClass.DISTANCE, | ||
| state_class=SensorStateClass.MEASUREMENT, | ||
| value_fn=lambda data: cast(float, data["printer"]["axis_y"]), | ||
| supported_fn=lambda data: data["printer"].get("axis_y") is not None, | ||
| entity_registry_enabled_default=False, | ||
| ), | ||
| PrusaLinkSensorEntityDescription[PrinterStatus]( | ||
| key="printer.telemetry.print-speed", | ||
| translation_key="print_speed", | ||
|
|
@@ -194,6 +215,22 @@ class PrusaLinkSensorEntityDescription( | |
| value_fn=lambda data: cast(str, data["nozzle_diameter"]), | ||
| entity_registry_enabled_default=False, | ||
| ), | ||
| PrusaLinkSensorEntityDescription[PrinterInfo]( | ||
| key="info.location", | ||
| translation_key="location", | ||
| value_fn=lambda data: cast(str, data["location"]), | ||
| supported_fn=lambda data: data.get("location") is not None, | ||
| entity_registry_enabled_default=False, | ||
| ), | ||
|
Comment on lines
+218
to
+224
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So why is location a sensor? If it reflects the current location of the printer, it should probably be set to
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch — agreed that this is the right architectural choice. Opened #170099 which:
The sensor was added in this PR (default-disabled, just merged) so the breaking impact is small — most users never enabled it. Side note for posterity: |
||
| PrusaLinkSensorEntityDescription[PrinterInfo]( | ||
| key="info.min_extrusion_temp", | ||
| translation_key="min_extrusion_temp", | ||
| native_unit_of_measurement=UnitOfTemperature.CELSIUS, | ||
| device_class=SensorDeviceClass.TEMPERATURE, | ||
| value_fn=lambda data: cast(int, data["min_extrusion_temp"]), | ||
| supported_fn=lambda data: data.get("min_extrusion_temp") is not None, | ||
| entity_registry_enabled_default=False, | ||
| ), | ||
| ), | ||
| } | ||
|
|
||
|
|
@@ -213,6 +250,7 @@ async def async_setup_entry( | |
| entities.extend( | ||
| PrusaLinkSensorEntity(coordinator, sensor_description) | ||
| for sensor_description in sensors | ||
| if sensor_description.supported_fn(coordinator.data) | ||
| ) | ||
|
|
||
| async_add_entities(entities) | ||
|
heikkih marked this conversation as resolved.
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.