Skip to content

Commit 6a9a7ed

Browse files
committed
Simplify code
* custom_components/daikin_onecta/sensor.py:
1 parent b42cdc7 commit 6a9a7ed

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

custom_components/daikin_onecta/sensor.py

+4-16
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,6 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
120120
management_point_type,
121121
mode,
122122
)
123-
icon = "mdi:fire"
124-
if mode == "cooling":
125-
icon = "mdi:snowflake"
126123
for period in cdve[mode]:
127124
_LOGGER.info(
128125
"Device '%s:%s' provides mode %s %s supports period %s",
@@ -135,17 +132,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
135132
periodName = SENSOR_PERIODS[period]
136133
sensor = f"{device.name} {management_point_type} {mode} {periodName}"
137134
_LOGGER.info("Proposing sensor '%s'", sensor)
138-
sensors.append(
139-
DaikinEnergySensor(
140-
device,
141-
coordinator,
142-
embedded_id,
143-
management_point_type,
144-
mode,
145-
period,
146-
icon,
147-
)
148-
)
135+
sensors.append(DaikinEnergySensor(device, coordinator, embedded_id, management_point_type, mode, period))
149136
else:
150137
_LOGGER.info(
151138
"Ignoring consumption data '%s', not a supported operation_mode",
@@ -166,7 +153,6 @@ def __init__(
166153
management_point_type,
167154
operation_mode,
168155
period,
169-
icon,
170156
) -> None:
171157
super().__init__(coordinator)
172158
self._device = device
@@ -179,7 +165,9 @@ def __init__(
179165
self._attr_name = f"{mpt} {operation_mode.capitalize()} {periodName} Electrical Consumption"
180166
self._attr_unique_id = f"{self._device.getId()}_{self._management_point_type}_electrical_{self._operation_mode}_{self._period}"
181167
self._attr_entity_category = None
182-
self._attr_icon = icon
168+
self._attr_icon = "mdi:fire"
169+
if operation_mode == "cooling":
170+
self._attr_icon = "mdi:snowflake"
183171
self._attr_has_entity_name = True
184172
self._attr_device_class = SensorDeviceClass.ENERGY
185173
self._attr_state_class = SensorStateClass.TOTAL_INCREASING

0 commit comments

Comments
 (0)