Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions homeassistant/components/prusalink/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ def device_info(self) -> DeviceInfo:
serial_number=info_data.get("serial"),
sw_version=version_data.get("firmware"),
configuration_url=self.coordinator.api.client.host,
suggested_area=info_data.get("location"),
)
3 changes: 0 additions & 3 deletions homeassistant/components/prusalink/icons.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
"filename": {
"default": "mdi:file-image-outline"
},
"location": {
"default": "mdi:map-marker"
},
"material": {
"default": "mdi:palette-swatch-variant"
},
Expand Down
7 changes: 0 additions & 7 deletions homeassistant/components/prusalink/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,13 +215,6 @@ 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,
),
PrusaLinkSensorEntityDescription[PrinterInfo](
key="info.min_extrusion_temp",
translation_key="min_extrusion_temp",
Expand Down
3 changes: 0 additions & 3 deletions homeassistant/components/prusalink/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@
"heatbed_temperature": {
"name": "Heatbed temperature"
},
"location": {
"name": "Location"
},
"material": {
"name": "Material"
},
Expand Down
16 changes: 14 additions & 2 deletions tests/components/prusalink/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
from homeassistant.config_entries import ConfigEntry, ConfigEntryState
from homeassistant.const import CONF_API_KEY, CONF_HOST, CONF_PASSWORD, CONF_USERNAME
from homeassistant.core import HomeAssistant
from homeassistant.helpers import device_registry as dr, issue_registry as ir
from homeassistant.helpers import (
area_registry as ar,
device_registry as dr,
issue_registry as ir,
)
from homeassistant.util.dt import utcnow

from tests.common import MockConfigEntry, async_fire_time_changed
Expand All @@ -24,8 +28,9 @@ async def test_device_info(
hass: HomeAssistant,
mock_config_entry: MockConfigEntry,
device_registry: dr.DeviceRegistry,
area_registry: ar.AreaRegistry,
) -> None:
"""Test device info is populated with serial number and firmware version."""
"""Test device info is populated with serial number, firmware, and suggested area."""
assert await hass.config_entries.async_setup(mock_config_entry.entry_id)

device = device_registry.async_get_device(
Expand All @@ -35,6 +40,13 @@ async def test_device_info(
assert device.serial_number == "serial-1337"
assert device.sw_version == "6.1.2+11023"

# `location` from /api/v1/info is set as suggested_area; the device gets
# placed in that area (created on the fly when not pre-existing).
assert device.area_id is not None
area = area_registry.async_get_area(device.area_id)
assert area is not None
assert area.name == "Workshop"


async def test_unloading(
hass: HomeAssistant,
Expand Down
14 changes: 4 additions & 10 deletions tests/components/prusalink/test_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,16 +335,12 @@ async def test_axis_x_y_not_created_when_absent(


@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_location_and_min_extrusion_temp_sensors(
async def test_min_extrusion_temp_sensor(
hass: HomeAssistant, mock_config_entry: MockConfigEntry, mock_api: None
) -> None:
"""Test location and minimum extrusion temperature sensors from info endpoint."""
"""Test minimum extrusion temperature sensor 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"
Expand All @@ -354,16 +350,14 @@ 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_not_created_when_absent(
async def test_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 sensors are not created when info fields are absent."""
del mock_info_api["location"]
"""Min extrusion temp sensor is not created when the info field is absent."""
del mock_info_api["min_extrusion_temp"]
assert await async_setup_component(hass, "prusalink", {})

assert hass.states.get("sensor.mock_title_location") is None
assert hass.states.get("sensor.mock_title_minimum_extrusion_temperature") is None
Loading