From fb7079c62c491614ad7f473a6153e6f44e83746e Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Fri, 30 Sep 2022 10:41:18 +0200 Subject: [PATCH] Adjust icons with new device classes (#79348) * Adjust icons with new device classes * Fix mysensors tests * Fix mysensors tests --- homeassistant/components/homewizard/sensor.py | 1 + homeassistant/components/litterrobot/sensor.py | 1 - homeassistant/components/mysensors/sensor.py | 2 -- tests/components/homewizard/test_sensor.py | 2 +- tests/components/mysensors/test_sensor.py | 3 ++- 5 files changed, 4 insertions(+), 5 deletions(-) diff --git a/homeassistant/components/homewizard/sensor.py b/homeassistant/components/homewizard/sensor.py index df4eb0c4880..6fc1d38ec12 100644 --- a/homeassistant/components/homewizard/sensor.py +++ b/homeassistant/components/homewizard/sensor.py @@ -130,6 +130,7 @@ SENSORS: Final[tuple[SensorEntityDescription, ...]] = ( key="total_liter_m3", name="Total water usage", native_unit_of_measurement=VOLUME_CUBIC_METERS, + icon="mdi:gauge", device_class=SensorDeviceClass.VOLUME, state_class=SensorStateClass.TOTAL_INCREASING, ), diff --git a/homeassistant/components/litterrobot/sensor.py b/homeassistant/components/litterrobot/sensor.py index b9d70528cab..1857931143d 100644 --- a/homeassistant/components/litterrobot/sensor.py +++ b/homeassistant/components/litterrobot/sensor.py @@ -109,7 +109,6 @@ ROBOT_SENSOR_MAP: dict[type[Robot], list[RobotSensorEntityDescription]] = { RobotSensorEntityDescription[LitterRobot4]( key="pet_weight", name="Pet weight", - icon="mdi:scale", native_unit_of_measurement=MASS_POUNDS, device_class=SensorDeviceClass.WEIGHT, ), diff --git a/homeassistant/components/mysensors/sensor.py b/homeassistant/components/mysensors/sensor.py index 59c33a48884..f21d343f9c3 100644 --- a/homeassistant/components/mysensors/sensor.py +++ b/homeassistant/components/mysensors/sensor.py @@ -95,13 +95,11 @@ SENSORS: dict[str, SensorEntityDescription] = { key="V_WEIGHT", native_unit_of_measurement=MASS_KILOGRAMS, device_class=SensorDeviceClass.WEIGHT, - icon="mdi:weight-kilogram", ), "V_DISTANCE": SensorEntityDescription( key="V_DISTANCE", native_unit_of_measurement=LENGTH_METERS, device_class=SensorDeviceClass.DISTANCE, - icon="mdi:ruler", ), "V_IMPEDANCE": SensorEntityDescription( key="V_IMPEDANCE", diff --git a/tests/components/homewizard/test_sensor.py b/tests/components/homewizard/test_sensor.py index 7d350764b2b..c8238c75643 100644 --- a/tests/components/homewizard/test_sensor.py +++ b/tests/components/homewizard/test_sensor.py @@ -610,7 +610,7 @@ async def test_sensor_entity_total_liters( assert state.attributes.get(ATTR_STATE_CLASS) == SensorStateClass.TOTAL_INCREASING assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == VOLUME_CUBIC_METERS assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.VOLUME - assert state.attributes.get(ATTR_ICON) is None + assert state.attributes.get(ATTR_ICON) == "mdi:gauge" async def test_sensor_entity_disabled_when_null( diff --git a/tests/components/mysensors/test_sensor.py b/tests/components/mysensors/test_sensor.py index 45fe98b98c7..58258682d5b 100644 --- a/tests/components/mysensors/test_sensor.py +++ b/tests/components/mysensors/test_sensor.py @@ -117,7 +117,8 @@ async def test_distance_sensor( assert state assert state.state == "15" - assert state.attributes[ATTR_ICON] == "mdi:ruler" + assert state.attributes[ATTR_DEVICE_CLASS] == SensorDeviceClass.DISTANCE + assert ATTR_ICON not in state.attributes assert state.attributes[ATTR_UNIT_OF_MEASUREMENT] == "cm"