mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 18:27:09 +00:00
Add icon translations to IPP (#111846)
* Add icon translations to IPP * Add icon translations to IPP
This commit is contained in:
parent
63c3d6e113
commit
b70eea7fb2
15
homeassistant/components/ipp/icons.json
Normal file
15
homeassistant/components/ipp/icons.json
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"entity": {
|
||||||
|
"sensor": {
|
||||||
|
"printer": {
|
||||||
|
"default": "mdi:printer"
|
||||||
|
},
|
||||||
|
"uptime": {
|
||||||
|
"default": "mdi:clock-outline"
|
||||||
|
},
|
||||||
|
"marker": {
|
||||||
|
"default": "mdi:water"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -70,7 +70,6 @@ PRINTER_SENSORS: tuple[IPPSensorEntityDescription, ...] = (
|
|||||||
key="printer",
|
key="printer",
|
||||||
name=None,
|
name=None,
|
||||||
translation_key="printer",
|
translation_key="printer",
|
||||||
icon="mdi:printer",
|
|
||||||
device_class=SensorDeviceClass.ENUM,
|
device_class=SensorDeviceClass.ENUM,
|
||||||
options=["idle", "printing", "stopped"],
|
options=["idle", "printing", "stopped"],
|
||||||
attributes_fn=lambda printer: {
|
attributes_fn=lambda printer: {
|
||||||
@ -87,7 +86,6 @@ PRINTER_SENSORS: tuple[IPPSensorEntityDescription, ...] = (
|
|||||||
IPPSensorEntityDescription(
|
IPPSensorEntityDescription(
|
||||||
key="uptime",
|
key="uptime",
|
||||||
translation_key="uptime",
|
translation_key="uptime",
|
||||||
icon="mdi:clock-outline",
|
|
||||||
device_class=SensorDeviceClass.TIMESTAMP,
|
device_class=SensorDeviceClass.TIMESTAMP,
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
@ -118,7 +116,7 @@ async def async_setup_entry(
|
|||||||
IPPSensorEntityDescription(
|
IPPSensorEntityDescription(
|
||||||
key=f"marker_{index}",
|
key=f"marker_{index}",
|
||||||
name=marker.name,
|
name=marker.name,
|
||||||
icon="mdi:water",
|
translation_key="marker",
|
||||||
native_unit_of_measurement=PERCENTAGE,
|
native_unit_of_measurement=PERCENTAGE,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
attributes_fn=_get_marker_attributes_fn(
|
attributes_fn=_get_marker_attributes_fn(
|
||||||
|
@ -4,12 +4,7 @@ from unittest.mock import AsyncMock
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant.components.sensor import ATTR_OPTIONS
|
from homeassistant.components.sensor import ATTR_OPTIONS
|
||||||
from homeassistant.const import (
|
from homeassistant.const import ATTR_UNIT_OF_MEASUREMENT, PERCENTAGE, EntityCategory
|
||||||
ATTR_ICON,
|
|
||||||
ATTR_UNIT_OF_MEASUREMENT,
|
|
||||||
PERCENTAGE,
|
|
||||||
EntityCategory,
|
|
||||||
)
|
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers import entity_registry as er
|
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."""
|
"""Test the creation and values of the IPP sensors."""
|
||||||
state = hass.states.get("sensor.test_ha_1000_series")
|
state = hass.states.get("sensor.test_ha_1000_series")
|
||||||
assert state
|
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_UNIT_OF_MEASUREMENT) is None
|
||||||
assert state.attributes.get(ATTR_OPTIONS) == ["idle", "printing", "stopped"]
|
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")
|
state = hass.states.get("sensor.test_ha_1000_series_black_ink")
|
||||||
assert state
|
assert state
|
||||||
assert state.attributes.get(ATTR_ICON) == "mdi:water"
|
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) is PERCENTAGE
|
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) is PERCENTAGE
|
||||||
assert state.state == "58"
|
assert state.state == "58"
|
||||||
|
|
||||||
state = hass.states.get("sensor.test_ha_1000_series_photo_black_ink")
|
state = hass.states.get("sensor.test_ha_1000_series_photo_black_ink")
|
||||||
assert state
|
assert state
|
||||||
assert state.attributes.get(ATTR_ICON) == "mdi:water"
|
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) is PERCENTAGE
|
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) is PERCENTAGE
|
||||||
assert state.state == "98"
|
assert state.state == "98"
|
||||||
|
|
||||||
state = hass.states.get("sensor.test_ha_1000_series_cyan_ink")
|
state = hass.states.get("sensor.test_ha_1000_series_cyan_ink")
|
||||||
assert state
|
assert state
|
||||||
assert state.attributes.get(ATTR_ICON) == "mdi:water"
|
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) is PERCENTAGE
|
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) is PERCENTAGE
|
||||||
assert state.state == "91"
|
assert state.state == "91"
|
||||||
|
|
||||||
state = hass.states.get("sensor.test_ha_1000_series_yellow_ink")
|
state = hass.states.get("sensor.test_ha_1000_series_yellow_ink")
|
||||||
assert state
|
assert state
|
||||||
assert state.attributes.get(ATTR_ICON) == "mdi:water"
|
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) is PERCENTAGE
|
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) is PERCENTAGE
|
||||||
assert state.state == "95"
|
assert state.state == "95"
|
||||||
|
|
||||||
state = hass.states.get("sensor.test_ha_1000_series_magenta_ink")
|
state = hass.states.get("sensor.test_ha_1000_series_magenta_ink")
|
||||||
assert state
|
assert state
|
||||||
assert state.attributes.get(ATTR_ICON) == "mdi:water"
|
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) is PERCENTAGE
|
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) is PERCENTAGE
|
||||||
assert state.state == "73"
|
assert state.state == "73"
|
||||||
|
|
||||||
state = hass.states.get("sensor.test_ha_1000_series_uptime")
|
state = hass.states.get("sensor.test_ha_1000_series_uptime")
|
||||||
assert state
|
assert state
|
||||||
assert state.attributes.get(ATTR_ICON) == "mdi:clock-outline"
|
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) is None
|
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) is None
|
||||||
assert state.state == "2019-11-11T09:10:02+00:00"
|
assert state.state == "2019-11-11T09:10:02+00:00"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user