mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 21:57:51 +00:00
Don't override icon in sensor group when device class is set (#87304)
This commit is contained in:
parent
61734f04b8
commit
1b4f4edce2
@ -244,7 +244,6 @@ class SensorGroup(GroupEntity, SensorEntity):
|
||||
|
||||
_attr_available = False
|
||||
_attr_should_poll = False
|
||||
_attr_icon = "mdi:calculator"
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
@ -352,6 +351,16 @@ class SensorGroup(GroupEntity, SensorEntity):
|
||||
return self._attr_device_class
|
||||
return self.calc_device_class
|
||||
|
||||
@property
|
||||
def icon(self) -> str | None:
|
||||
"""Return the icon.
|
||||
|
||||
Only override the icon if the device class is not set.
|
||||
"""
|
||||
if not self.device_class:
|
||||
return "mdi:calculator"
|
||||
return None
|
||||
|
||||
@property
|
||||
def state_class(self) -> SensorStateClass | str | None:
|
||||
"""Return state class."""
|
||||
|
@ -24,6 +24,7 @@ from homeassistant.components.sensor import (
|
||||
from homeassistant.const import (
|
||||
ATTR_DEVICE_CLASS,
|
||||
ATTR_ENTITY_ID,
|
||||
ATTR_ICON,
|
||||
ATTR_UNIT_OF_MEASUREMENT,
|
||||
SERVICE_RELOAD,
|
||||
STATE_UNAVAILABLE,
|
||||
@ -99,6 +100,7 @@ async def test_sensors(
|
||||
for key, value in attributes.items():
|
||||
assert state.attributes.get(key) == value
|
||||
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.VOLUME
|
||||
assert state.attributes.get(ATTR_ICON) is None
|
||||
assert state.attributes.get(ATTR_STATE_CLASS) == SensorStateClass.MEASUREMENT
|
||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == "L"
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user