feat: avoid setting icon when device_class is defined

This commit is contained in:
Necroneco 2025-01-05 23:27:37 +08:00
parent 5c46504d0e
commit 5c3e087500
No known key found for this signature in database
2 changed files with 2 additions and 2 deletions

View File

@ -88,7 +88,7 @@ class Number(MIoTPropertyEntity, NumberEntity):
if self.spec.external_unit:
self._attr_native_unit_of_measurement = self.spec.external_unit
# Set icon
if self.spec.icon:
if self.spec.icon and not self.device_class:
self._attr_icon = self.spec.icon
# Set value range
if self._value_range:

View File

@ -116,7 +116,7 @@ class Sensor(MIoTPropertyEntity, SensorEntity):
if spec.state_class:
self._attr_state_class = spec.state_class
# Set icon
if spec.icon:
if spec.icon and not self.device_class:
self._attr_icon = spec.icon
@property