From 7bb5b5a8f13329d99a084cb4143ac23c9e45eb45 Mon Sep 17 00:00:00 2001 From: Heikki Henriksen Date: Mon, 27 Apr 2026 18:35:29 +0200 Subject: [PATCH 1/5] prusalink: add X/Y position, location, and min extrusion temp sensors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add four sensors from data already fetched by existing coordinators, requiring no library changes: - X position (printer.axis_x) — mm, disabled by default - Y position (printer.axis_y) — mm, disabled by default - Location (info.location) — text, disabled by default - Minimum extrusion temperature (info.min_extrusion_temp) — °C, disabled by default X and Y mirror the existing Z-Height sensor pattern. Location and minimum extrusion temperature expose the remaining useful scalar fields from the /api/v1/info endpoint already polled every 30 seconds. All sensors are marked unavailable when the respective field is absent from the API response. Co-Authored-By: Claude Sonnet 4.6 --- homeassistant/components/prusalink/sensor.py | 37 +++++++++++++ .../components/prusalink/strings.json | 12 ++++ tests/components/prusalink/conftest.py | 1 + tests/components/prusalink/test_sensor.py | 55 +++++++++++++++++++ 4 files changed, 105 insertions(+) diff --git a/homeassistant/components/prusalink/sensor.py b/homeassistant/components/prusalink/sensor.py index d39307137d91f4..94adb4a570d026 100644 --- a/homeassistant/components/prusalink/sensor.py +++ b/homeassistant/components/prusalink/sensor.py @@ -103,6 +103,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"]), + available_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"]), + available_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 +214,23 @@ 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"]), + available_fn=lambda data: data.get("location") is not None, + entity_registry_enabled_default=False, + ), + PrusaLinkSensorEntityDescription[PrinterInfo]( + key="info.min_extrusion_temp", + translation_key="min_extrusion_temp", + native_unit_of_measurement=UnitOfTemperature.CELSIUS, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, + value_fn=lambda data: cast(int, data["min_extrusion_temp"]), + available_fn=lambda data: data.get("min_extrusion_temp") is not None, + entity_registry_enabled_default=False, + ), ), } diff --git a/homeassistant/components/prusalink/strings.json b/homeassistant/components/prusalink/strings.json index 3c3b7257dfbd15..31e01700602e75 100644 --- a/homeassistant/components/prusalink/strings.json +++ b/homeassistant/components/prusalink/strings.json @@ -94,6 +94,18 @@ "progress": { "name": "Progress" }, + "location": { + "name": "Location" + }, + "min_extrusion_temp": { + "name": "Minimum extrusion temperature" + }, + "x_position": { + "name": "X" + }, + "y_position": { + "name": "Y" + }, "z_height": { "name": "Z-Height" } diff --git a/tests/components/prusalink/conftest.py b/tests/components/prusalink/conftest.py index 1ef8120a02633b..713bb1f1acbbce 100644 --- a/tests/components/prusalink/conftest.py +++ b/tests/components/prusalink/conftest.py @@ -48,6 +48,7 @@ def mock_info_api() -> Generator[dict[str, Any]]: "serial": "serial-1337", "hostname": "PrusaXL", "min_extrusion_temp": 170, + "location": "Workshop", } with patch("pyprusalink.PrusaLink.get_info", return_value=resp): yield resp diff --git a/tests/components/prusalink/test_sensor.py b/tests/components/prusalink/test_sensor.py index ead56f6493dac6..34dde480f74622 100644 --- a/tests/components/prusalink/test_sensor.py +++ b/tests/components/prusalink/test_sensor.py @@ -16,6 +16,7 @@ ATTR_UNIT_OF_MEASUREMENT, PERCENTAGE, REVOLUTIONS_PER_MINUTE, + STATE_UNAVAILABLE, Platform, UnitOfLength, UnitOfTemperature, @@ -291,3 +292,57 @@ async def test_sensors_active_job( assert state is not None assert state.state == "2500" assert state.attributes[ATTR_UNIT_OF_MEASUREMENT] == REVOLUTIONS_PER_MINUTE + + +@pytest.mark.usefixtures("entity_registry_enabled_by_default") +async def test_axis_x_y_sensors( + hass: HomeAssistant, mock_config_entry, mock_api +) -> None: + """Test X and Y axis position sensors.""" + assert await async_setup_component(hass, "prusalink", {}) + + state = hass.states.get("sensor.mock_title_x") + assert state is not None + assert state.state == "7.9" + assert state.attributes[ATTR_UNIT_OF_MEASUREMENT] == UnitOfLength.MILLIMETERS + assert state.attributes[ATTR_DEVICE_CLASS] == SensorDeviceClass.DISTANCE + assert state.attributes[ATTR_STATE_CLASS] == SensorStateClass.MEASUREMENT + + state = hass.states.get("sensor.mock_title_y") + assert state is not None + assert state.state == "8.4" + assert state.attributes[ATTR_UNIT_OF_MEASUREMENT] == UnitOfLength.MILLIMETERS + assert state.attributes[ATTR_DEVICE_CLASS] == SensorDeviceClass.DISTANCE + assert state.attributes[ATTR_STATE_CLASS] == SensorStateClass.MEASUREMENT + + +@pytest.mark.usefixtures("entity_registry_enabled_by_default") +async def test_axis_x_y_unavailable_when_absent( + hass: HomeAssistant, mock_config_entry, mock_api, mock_get_status_idle +) -> None: + """X and Y sensors are unavailable when axis fields are absent from the response.""" + del mock_get_status_idle["printer"]["axis_x"] + del mock_get_status_idle["printer"]["axis_y"] + assert await async_setup_component(hass, "prusalink", {}) + + assert hass.states.get("sensor.mock_title_x").state == STATE_UNAVAILABLE + assert hass.states.get("sensor.mock_title_y").state == STATE_UNAVAILABLE + + +@pytest.mark.usefixtures("entity_registry_enabled_by_default") +async def test_location_and_min_extrusion_temp_sensors( + hass: HomeAssistant, mock_config_entry, mock_api +) -> None: + """Test location and minimum extrusion temperature sensors from info endpoint.""" + assert await async_setup_component(hass, "prusalink", {}) + + state = hass.states.get("sensor.mock_title_location") + assert state is not None + assert state.state == "Workshop" + + state = hass.states.get("sensor.mock_title_minimum_extrusion_temperature") + assert state is not None + assert state.state == "170" + assert state.attributes[ATTR_UNIT_OF_MEASUREMENT] == UnitOfTemperature.CELSIUS + assert state.attributes[ATTR_DEVICE_CLASS] == SensorDeviceClass.TEMPERATURE + assert state.attributes[ATTR_STATE_CLASS] == SensorStateClass.MEASUREMENT From f5dc59e8c506cecd3754b53cdbfe183e35671aed Mon Sep 17 00:00:00 2001 From: Heikki Henriksen Date: Mon, 27 Apr 2026 19:22:29 +0200 Subject: [PATCH 2/5] prusalink: add unavailability tests and fix type annotations for new sensors - Add test for location and min_extrusion_temp sensors becoming unavailable when fields are absent from /api/v1/info response - Add assert state is not None before .state access in unavailability tests for clearer failure messages - Add type annotations to new test fixture parameters Co-Authored-By: Claude Sonnet 4.6 --- tests/components/prusalink/test_sensor.py | 40 ++++++++++++++++++++--- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/tests/components/prusalink/test_sensor.py b/tests/components/prusalink/test_sensor.py index 34dde480f74622..a1c758c23c9dea 100644 --- a/tests/components/prusalink/test_sensor.py +++ b/tests/components/prusalink/test_sensor.py @@ -1,6 +1,7 @@ """Test Prusalink sensors.""" from datetime import UTC, datetime +from typing import Any from unittest.mock import patch import pytest @@ -24,6 +25,8 @@ from homeassistant.core import HomeAssistant from homeassistant.setup import async_setup_component +from tests.common import MockConfigEntry + @pytest.fixture(autouse=True) def setup_sensor_platform_only(): @@ -296,7 +299,7 @@ async def test_sensors_active_job( @pytest.mark.usefixtures("entity_registry_enabled_by_default") async def test_axis_x_y_sensors( - hass: HomeAssistant, mock_config_entry, mock_api + hass: HomeAssistant, mock_config_entry: MockConfigEntry, mock_api: None ) -> None: """Test X and Y axis position sensors.""" assert await async_setup_component(hass, "prusalink", {}) @@ -318,20 +321,27 @@ async def test_axis_x_y_sensors( @pytest.mark.usefixtures("entity_registry_enabled_by_default") async def test_axis_x_y_unavailable_when_absent( - hass: HomeAssistant, mock_config_entry, mock_api, mock_get_status_idle + hass: HomeAssistant, + mock_config_entry: MockConfigEntry, + mock_api: None, + mock_get_status_idle: dict[str, Any], ) -> None: """X and Y sensors are unavailable when axis fields are absent from the response.""" del mock_get_status_idle["printer"]["axis_x"] del mock_get_status_idle["printer"]["axis_y"] assert await async_setup_component(hass, "prusalink", {}) - assert hass.states.get("sensor.mock_title_x").state == STATE_UNAVAILABLE - assert hass.states.get("sensor.mock_title_y").state == STATE_UNAVAILABLE + state = hass.states.get("sensor.mock_title_x") + assert state is not None + assert state.state == STATE_UNAVAILABLE + state = hass.states.get("sensor.mock_title_y") + assert state is not None + assert state.state == STATE_UNAVAILABLE @pytest.mark.usefixtures("entity_registry_enabled_by_default") async def test_location_and_min_extrusion_temp_sensors( - hass: HomeAssistant, mock_config_entry, mock_api + hass: HomeAssistant, mock_config_entry: MockConfigEntry, mock_api: None ) -> None: """Test location and minimum extrusion temperature sensors from info endpoint.""" assert await async_setup_component(hass, "prusalink", {}) @@ -346,3 +356,23 @@ async def test_location_and_min_extrusion_temp_sensors( assert state.attributes[ATTR_UNIT_OF_MEASUREMENT] == UnitOfTemperature.CELSIUS assert state.attributes[ATTR_DEVICE_CLASS] == SensorDeviceClass.TEMPERATURE assert state.attributes[ATTR_STATE_CLASS] == SensorStateClass.MEASUREMENT + + +@pytest.mark.usefixtures("entity_registry_enabled_by_default") +async def test_location_and_min_extrusion_temp_unavailable_when_absent( + hass: HomeAssistant, + mock_config_entry: MockConfigEntry, + mock_api: None, + mock_info_api: dict[str, Any], +) -> None: + """Location and min extrusion temp are unavailable when info fields are absent.""" + del mock_info_api["location"] + del mock_info_api["min_extrusion_temp"] + assert await async_setup_component(hass, "prusalink", {}) + + state = hass.states.get("sensor.mock_title_location") + assert state is not None + assert state.state == STATE_UNAVAILABLE + state = hass.states.get("sensor.mock_title_minimum_extrusion_temperature") + assert state is not None + assert state.state == STATE_UNAVAILABLE From eb183b24ce67a8003cb2ac4ec3a5a5988bb3b353 Mon Sep 17 00:00:00 2001 From: Heikki Henriksen Date: Wed, 6 May 2026 20:15:52 +0200 Subject: [PATCH 3/5] prusalink: switch unsupported sensors to supported_fn at setup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Per review feedback, available_fn is the wrong tool for "field absent on this firmware" — that's a permanent characteristic of the printer, not transient unavailability. Use a new supported_fn evaluated once in async_setup_entry so the sensor is not created when the field is absent. Job sensors keep available_fn since their unavailability is transient (state-based, not firmware-based). Also fix prettier CI failure: alphabetize new sensor strings. Co-Authored-By: Claude Opus 4.7 (1M context) --- homeassistant/components/prusalink/sensor.py | 10 +++++--- .../components/prusalink/strings.json | 12 ++++----- tests/components/prusalink/test_sensor.py | 25 ++++++------------- 3 files changed, 20 insertions(+), 27 deletions(-) diff --git a/homeassistant/components/prusalink/sensor.py b/homeassistant/components/prusalink/sensor.py index 94adb4a570d026..a9f835a5f2a76e 100644 --- a/homeassistant/components/prusalink/sensor.py +++ b/homeassistant/components/prusalink/sensor.py @@ -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, ...]] = { @@ -110,7 +111,7 @@ class PrusaLinkSensorEntityDescription( device_class=SensorDeviceClass.DISTANCE, state_class=SensorStateClass.MEASUREMENT, value_fn=lambda data: cast(float, data["printer"]["axis_x"]), - available_fn=lambda data: data["printer"].get("axis_x") is not None, + supported_fn=lambda data: data["printer"].get("axis_x") is not None, entity_registry_enabled_default=False, ), PrusaLinkSensorEntityDescription[PrinterStatus]( @@ -120,7 +121,7 @@ class PrusaLinkSensorEntityDescription( device_class=SensorDeviceClass.DISTANCE, state_class=SensorStateClass.MEASUREMENT, value_fn=lambda data: cast(float, data["printer"]["axis_y"]), - available_fn=lambda data: data["printer"].get("axis_y") is not None, + supported_fn=lambda data: data["printer"].get("axis_y") is not None, entity_registry_enabled_default=False, ), PrusaLinkSensorEntityDescription[PrinterStatus]( @@ -218,7 +219,7 @@ class PrusaLinkSensorEntityDescription( key="info.location", translation_key="location", value_fn=lambda data: cast(str, data["location"]), - available_fn=lambda data: data.get("location") is not None, + supported_fn=lambda data: data.get("location") is not None, entity_registry_enabled_default=False, ), PrusaLinkSensorEntityDescription[PrinterInfo]( @@ -228,7 +229,7 @@ class PrusaLinkSensorEntityDescription( device_class=SensorDeviceClass.TEMPERATURE, state_class=SensorStateClass.MEASUREMENT, value_fn=lambda data: cast(int, data["min_extrusion_temp"]), - available_fn=lambda data: data.get("min_extrusion_temp") is not None, + supported_fn=lambda data: data.get("min_extrusion_temp") is not None, entity_registry_enabled_default=False, ), ), @@ -250,6 +251,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) diff --git a/homeassistant/components/prusalink/strings.json b/homeassistant/components/prusalink/strings.json index 31e01700602e75..e76cada465dcaa 100644 --- a/homeassistant/components/prusalink/strings.json +++ b/homeassistant/components/prusalink/strings.json @@ -54,9 +54,15 @@ "heatbed_temperature": { "name": "Heatbed temperature" }, + "location": { + "name": "Location" + }, "material": { "name": "Material" }, + "min_extrusion_temp": { + "name": "Minimum extrusion temperature" + }, "nozzle_diameter": { "name": "Nozzle diameter" }, @@ -94,12 +100,6 @@ "progress": { "name": "Progress" }, - "location": { - "name": "Location" - }, - "min_extrusion_temp": { - "name": "Minimum extrusion temperature" - }, "x_position": { "name": "X" }, diff --git a/tests/components/prusalink/test_sensor.py b/tests/components/prusalink/test_sensor.py index a1c758c23c9dea..5abc8d287e82c0 100644 --- a/tests/components/prusalink/test_sensor.py +++ b/tests/components/prusalink/test_sensor.py @@ -17,7 +17,6 @@ ATTR_UNIT_OF_MEASUREMENT, PERCENTAGE, REVOLUTIONS_PER_MINUTE, - STATE_UNAVAILABLE, Platform, UnitOfLength, UnitOfTemperature, @@ -320,23 +319,19 @@ async def test_axis_x_y_sensors( @pytest.mark.usefixtures("entity_registry_enabled_by_default") -async def test_axis_x_y_unavailable_when_absent( +async def test_axis_x_y_not_created_when_absent( hass: HomeAssistant, mock_config_entry: MockConfigEntry, mock_api: None, mock_get_status_idle: dict[str, Any], ) -> None: - """X and Y sensors are unavailable when axis fields are absent from the response.""" + """X and Y sensors are not created when axis fields are absent from the response.""" del mock_get_status_idle["printer"]["axis_x"] del mock_get_status_idle["printer"]["axis_y"] assert await async_setup_component(hass, "prusalink", {}) - state = hass.states.get("sensor.mock_title_x") - assert state is not None - assert state.state == STATE_UNAVAILABLE - state = hass.states.get("sensor.mock_title_y") - assert state is not None - assert state.state == STATE_UNAVAILABLE + assert hass.states.get("sensor.mock_title_x") is None + assert hass.states.get("sensor.mock_title_y") is None @pytest.mark.usefixtures("entity_registry_enabled_by_default") @@ -359,20 +354,16 @@ async def test_location_and_min_extrusion_temp_sensors( @pytest.mark.usefixtures("entity_registry_enabled_by_default") -async def test_location_and_min_extrusion_temp_unavailable_when_absent( +async def test_location_and_min_extrusion_temp_not_created_when_absent( hass: HomeAssistant, mock_config_entry: MockConfigEntry, mock_api: None, mock_info_api: dict[str, Any], ) -> None: - """Location and min extrusion temp are unavailable when info fields are absent.""" + """Location and min extrusion temp sensors are not created when info fields are absent.""" del mock_info_api["location"] del mock_info_api["min_extrusion_temp"] assert await async_setup_component(hass, "prusalink", {}) - state = hass.states.get("sensor.mock_title_location") - assert state is not None - assert state.state == STATE_UNAVAILABLE - state = hass.states.get("sensor.mock_title_minimum_extrusion_temperature") - assert state is not None - assert state.state == STATE_UNAVAILABLE + assert hass.states.get("sensor.mock_title_location") is None + assert hass.states.get("sensor.mock_title_minimum_extrusion_temperature") is None From 5279cf4474ec937c6544c682db956915139ad5c1 Mon Sep 17 00:00:00 2001 From: Heikki Henriksen Date: Wed, 6 May 2026 20:44:40 +0200 Subject: [PATCH 4/5] prusalink: drop measurement state_class for min_extrusion_temp MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit min_extrusion_temp is a static configuration value, not a continuously measured one — it changes only when the user reconfigures the printer. Treating it as a measurement generates long-term statistics for what is essentially a constant, which is recorder spam. This matches the existing nozzle_diameter sensor (also from /api/v1/info) which has no state_class. Co-Authored-By: Claude Opus 4.7 (1M context) --- homeassistant/components/prusalink/sensor.py | 1 - tests/components/prusalink/test_sensor.py | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/homeassistant/components/prusalink/sensor.py b/homeassistant/components/prusalink/sensor.py index a9f835a5f2a76e..1a6af4da1edd80 100644 --- a/homeassistant/components/prusalink/sensor.py +++ b/homeassistant/components/prusalink/sensor.py @@ -227,7 +227,6 @@ class PrusaLinkSensorEntityDescription( translation_key="min_extrusion_temp", native_unit_of_measurement=UnitOfTemperature.CELSIUS, device_class=SensorDeviceClass.TEMPERATURE, - state_class=SensorStateClass.MEASUREMENT, 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, diff --git a/tests/components/prusalink/test_sensor.py b/tests/components/prusalink/test_sensor.py index 5abc8d287e82c0..926395308ac9e4 100644 --- a/tests/components/prusalink/test_sensor.py +++ b/tests/components/prusalink/test_sensor.py @@ -350,7 +350,7 @@ async def test_location_and_min_extrusion_temp_sensors( assert state.state == "170" assert state.attributes[ATTR_UNIT_OF_MEASUREMENT] == UnitOfTemperature.CELSIUS assert state.attributes[ATTR_DEVICE_CLASS] == SensorDeviceClass.TEMPERATURE - assert state.attributes[ATTR_STATE_CLASS] == SensorStateClass.MEASUREMENT + assert ATTR_STATE_CLASS not in state.attributes @pytest.mark.usefixtures("entity_registry_enabled_by_default") From b7bf6d94cdfae3321ded7351629a5063a373baed Mon Sep 17 00:00:00 2001 From: Heikki Henriksen Date: Thu, 7 May 2026 12:21:24 +0200 Subject: [PATCH 5/5] prusalink: address review feedback on new sensors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Rename X and Y entity names from "X"/"Y" to "X-Position"/"Y-Position" to match the existing Z-Height pattern. Entity IDs change accordingly (sensor._x → sensor.<title>_x_position, same for y), and tests are updated to match. - Add icon for the location sensor. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --- homeassistant/components/prusalink/icons.json | 3 +++ homeassistant/components/prusalink/strings.json | 4 ++-- tests/components/prusalink/test_sensor.py | 8 ++++---- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/prusalink/icons.json b/homeassistant/components/prusalink/icons.json index d2b956f10ec249..e368a87e87ee4e 100644 --- a/homeassistant/components/prusalink/icons.json +++ b/homeassistant/components/prusalink/icons.json @@ -15,6 +15,9 @@ "filename": { "default": "mdi:file-image-outline" }, + "location": { + "default": "mdi:map-marker" + }, "material": { "default": "mdi:palette-swatch-variant" }, diff --git a/homeassistant/components/prusalink/strings.json b/homeassistant/components/prusalink/strings.json index e76cada465dcaa..c9ae97f9d8d445 100644 --- a/homeassistant/components/prusalink/strings.json +++ b/homeassistant/components/prusalink/strings.json @@ -101,10 +101,10 @@ "name": "Progress" }, "x_position": { - "name": "X" + "name": "X-Position" }, "y_position": { - "name": "Y" + "name": "Y-Position" }, "z_height": { "name": "Z-Height" diff --git a/tests/components/prusalink/test_sensor.py b/tests/components/prusalink/test_sensor.py index 926395308ac9e4..28fb267890db29 100644 --- a/tests/components/prusalink/test_sensor.py +++ b/tests/components/prusalink/test_sensor.py @@ -303,14 +303,14 @@ async def test_axis_x_y_sensors( """Test X and Y axis position sensors.""" assert await async_setup_component(hass, "prusalink", {}) - state = hass.states.get("sensor.mock_title_x") + state = hass.states.get("sensor.mock_title_x_position") assert state is not None assert state.state == "7.9" assert state.attributes[ATTR_UNIT_OF_MEASUREMENT] == UnitOfLength.MILLIMETERS assert state.attributes[ATTR_DEVICE_CLASS] == SensorDeviceClass.DISTANCE assert state.attributes[ATTR_STATE_CLASS] == SensorStateClass.MEASUREMENT - state = hass.states.get("sensor.mock_title_y") + state = hass.states.get("sensor.mock_title_y_position") assert state is not None assert state.state == "8.4" assert state.attributes[ATTR_UNIT_OF_MEASUREMENT] == UnitOfLength.MILLIMETERS @@ -330,8 +330,8 @@ async def test_axis_x_y_not_created_when_absent( del mock_get_status_idle["printer"]["axis_y"] assert await async_setup_component(hass, "prusalink", {}) - assert hass.states.get("sensor.mock_title_x") is None - assert hass.states.get("sensor.mock_title_y") is None + assert hass.states.get("sensor.mock_title_x_position") is None + assert hass.states.get("sensor.mock_title_y_position") is None @pytest.mark.usefixtures("entity_registry_enabled_by_default")