Skip to content

Commit 964c781

Browse files
authored
Fix hardcoded Led.Off causing AC panel light to turn off on every command (#180)
1 parent 8ffa077 commit 964c781

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

  • custom_components/xiaomi_miio_airconditioningcompanion

custom_components/xiaomi_miio_airconditioningcompanion/climate.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
CONF_SLOT = "slot"
7575
CONF_COMMAND = "command"
7676
CONF_POWER_SENSOR = "power_sensor"
77+
CONF_LED = "led"
7778

7879
SCAN_INTERVAL = timedelta(seconds=15)
7980

@@ -86,6 +87,7 @@
8687
vol.Optional(CONF_MIN_TEMP, default=16): vol.Coerce(int),
8788
vol.Optional(CONF_MAX_TEMP, default=30): vol.Coerce(int),
8889
vol.Optional(CONF_POWER_SENSOR): cv.entity_id,
90+
vol.Optional(CONF_LED, default=True): cv.boolean,
8991
}
9092
)
9193

@@ -140,6 +142,7 @@ async def async_setup_platform(hass, config, async_add_devices, discovery_info=N
140142
max_temp = config.get(CONF_MAX_TEMP)
141143
sensor_entity_id = config.get(CONF_SENSOR)
142144
power_sensor_entity_id = config.get(CONF_POWER_SENSOR)
145+
led = config.get(CONF_LED)
143146

144147
_LOGGER.info("Initializing with host %s (token %s...)", host, token[:5])
145148

@@ -167,6 +170,7 @@ async def async_setup_platform(hass, config, async_add_devices, discovery_info=N
167170
power_sensor_entity_id,
168171
min_temp,
169172
max_temp,
173+
led,
170174
)
171175
hass.data[DATA_KEY][host] = air_conditioning_companion
172176
async_add_devices([air_conditioning_companion], update_before_add=True)
@@ -226,6 +230,7 @@ def __init__(
226230
power_sensor_entity_id,
227231
min_temp,
228232
max_temp,
233+
led=True,
229234
):
230235
"""Initialize the climate device."""
231236
self.hass = hass
@@ -234,6 +239,7 @@ def __init__(
234239
self._unique_id = unique_id
235240
self._sensor_entity_id = sensor_entity_id
236241
self._power_sensor_entity_id = power_sensor_entity_id
242+
self._led = led
237243

238244
self._available = False
239245
self._state = None
@@ -539,7 +545,7 @@ async def _send_configuration(self):
539545
int(self._target_temperature),
540546
self._fan_mode,
541547
self._swing_mode,
542-
Led.Off,
548+
Led.On if self._led else Led.Off,
543549
)
544550
else:
545551
_LOGGER.error(

0 commit comments

Comments
 (0)