Add icon translations to IPP (#111846)

* Add icon translations to IPP

* Add icon translations to IPP
This commit is contained in:
Joost Lekkerkerker 2024-02-29 16:09:47 +01:00 committed by GitHub
parent 63c3d6e113
commit b70eea7fb2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 17 additions and 16 deletions

View File

@ -0,0 +1,15 @@
{
"entity": {
"sensor": {
"printer": {
"default": "mdi:printer"
},
"uptime": {
"default": "mdi:clock-outline"
},
"marker": {
"default": "mdi:water"
}
}
}
}

View File

@ -70,7 +70,6 @@ PRINTER_SENSORS: tuple[IPPSensorEntityDescription, ...] = (
key="printer",
name=None,
translation_key="printer",
icon="mdi:printer",
device_class=SensorDeviceClass.ENUM,
options=["idle", "printing", "stopped"],
attributes_fn=lambda printer: {
@ -87,7 +86,6 @@ PRINTER_SENSORS: tuple[IPPSensorEntityDescription, ...] = (
IPPSensorEntityDescription(
key="uptime",
translation_key="uptime",
icon="mdi:clock-outline",
device_class=SensorDeviceClass.TIMESTAMP,
entity_category=EntityCategory.DIAGNOSTIC,
entity_registry_enabled_default=False,
@ -118,7 +116,7 @@ async def async_setup_entry(
IPPSensorEntityDescription(
key=f"marker_{index}",
name=marker.name,
icon="mdi:water",
translation_key="marker",
native_unit_of_measurement=PERCENTAGE,
state_class=SensorStateClass.MEASUREMENT,
attributes_fn=_get_marker_attributes_fn(

View File

@ -4,12 +4,7 @@ from unittest.mock import AsyncMock
import pytest
from homeassistant.components.sensor import ATTR_OPTIONS
from homeassistant.const import (
ATTR_ICON,
ATTR_UNIT_OF_MEASUREMENT,
PERCENTAGE,
EntityCategory,
)
from homeassistant.const import ATTR_UNIT_OF_MEASUREMENT, PERCENTAGE, EntityCategory
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry as er
@ -26,7 +21,6 @@ async def test_sensors(
"""Test the creation and values of the IPP sensors."""
state = hass.states.get("sensor.test_ha_1000_series")
assert state
assert state.attributes.get(ATTR_ICON) == "mdi:printer"
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) is None
assert state.attributes.get(ATTR_OPTIONS) == ["idle", "printing", "stopped"]
@ -36,37 +30,31 @@ async def test_sensors(
state = hass.states.get("sensor.test_ha_1000_series_black_ink")
assert state
assert state.attributes.get(ATTR_ICON) == "mdi:water"
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) is PERCENTAGE
assert state.state == "58"
state = hass.states.get("sensor.test_ha_1000_series_photo_black_ink")
assert state
assert state.attributes.get(ATTR_ICON) == "mdi:water"
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) is PERCENTAGE
assert state.state == "98"
state = hass.states.get("sensor.test_ha_1000_series_cyan_ink")
assert state
assert state.attributes.get(ATTR_ICON) == "mdi:water"
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) is PERCENTAGE
assert state.state == "91"
state = hass.states.get("sensor.test_ha_1000_series_yellow_ink")
assert state
assert state.attributes.get(ATTR_ICON) == "mdi:water"
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) is PERCENTAGE
assert state.state == "95"
state = hass.states.get("sensor.test_ha_1000_series_magenta_ink")
assert state
assert state.attributes.get(ATTR_ICON) == "mdi:water"
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) is PERCENTAGE
assert state.state == "73"
state = hass.states.get("sensor.test_ha_1000_series_uptime")
assert state
assert state.attributes.get(ATTR_ICON) == "mdi:clock-outline"
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) is None
assert state.state == "2019-11-11T09:10:02+00:00"