diff --git a/homeassistant/components/group/sensor.py b/homeassistant/components/group/sensor.py index 52ce90b2535..088678b6c1a 100644 --- a/homeassistant/components/group/sensor.py +++ b/homeassistant/components/group/sensor.py @@ -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.""" diff --git a/tests/components/group/test_sensor.py b/tests/components/group/test_sensor.py index 03e067a5082..89897e3e985 100644 --- a/tests/components/group/test_sensor.py +++ b/tests/components/group/test_sensor.py @@ -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"