mirror of
https://github.com/home-assistant/core.git
synced 2025-04-25 09:47:52 +00:00
Use enum sensor device class in PrusaLink (#83107)
This commit is contained in:
parent
a63dd811dd
commit
b40923a4cd
@ -59,7 +59,9 @@ SENSORS: dict[str, tuple[PrusaLinkSensorEntityDescription, ...]] = {
|
||||
if flags["printing"]
|
||||
else "idle"
|
||||
),
|
||||
device_class="prusalink__printer_state",
|
||||
device_class=SensorDeviceClass.ENUM,
|
||||
options=["cancelling", "idle", "paused", "pausing", "printing"],
|
||||
translation_key="printer_state",
|
||||
),
|
||||
PrusaLinkSensorEntityDescription[PrinterInfo](
|
||||
key="printer.telemetry.temp-bed",
|
||||
|
@ -14,5 +14,18 @@
|
||||
"unknown": "[%key:common::config_flow::error::unknown%]",
|
||||
"not_supported": "Only PrusaLink API v2 is supported"
|
||||
}
|
||||
},
|
||||
"entity": {
|
||||
"sensor": {
|
||||
"printer_state": {
|
||||
"state": {
|
||||
"cancelling": "Cancelling",
|
||||
"idle": "Idle",
|
||||
"paused": "Paused",
|
||||
"pausing": "Pausing",
|
||||
"printing": "Printing"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +0,0 @@
|
||||
{
|
||||
"state": {
|
||||
"prusalink__printer_state": {
|
||||
"pausing": "Pausing",
|
||||
"cancelling": "Cancelling",
|
||||
"paused": "Paused",
|
||||
"printing": "Printing",
|
||||
"idle": "Idle"
|
||||
}
|
||||
}
|
||||
}
|
@ -14,5 +14,18 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"entity": {
|
||||
"sensor": {
|
||||
"printer_state": {
|
||||
"state": {
|
||||
"cancelling": "Cancelling",
|
||||
"idle": "Idle",
|
||||
"paused": "Paused",
|
||||
"pausing": "Pausing",
|
||||
"printing": "Printing"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -6,6 +6,7 @@ from unittest.mock import PropertyMock, patch
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.sensor import (
|
||||
ATTR_OPTIONS,
|
||||
ATTR_STATE_CLASS,
|
||||
SensorDeviceClass,
|
||||
SensorStateClass,
|
||||
@ -39,6 +40,14 @@ async def test_sensors_no_job(hass: HomeAssistant, mock_config_entry, mock_api):
|
||||
state = hass.states.get("sensor.mock_title")
|
||||
assert state is not None
|
||||
assert state.state == "idle"
|
||||
assert state.attributes[ATTR_DEVICE_CLASS] == SensorDeviceClass.ENUM
|
||||
assert state.attributes[ATTR_OPTIONS] == [
|
||||
"cancelling",
|
||||
"idle",
|
||||
"paused",
|
||||
"pausing",
|
||||
"printing",
|
||||
]
|
||||
|
||||
state = hass.states.get("sensor.mock_title_heatbed")
|
||||
assert state is not None
|
||||
|
Loading…
x
Reference in New Issue
Block a user