mirror of
https://github.com/XiaoMi/ha_xiaomi_home.git
synced 2026-01-14 13:20:42 +08:00
fix bug
This commit is contained in:
parent
1cf52a3f78
commit
1b58dc75fb
@ -261,17 +261,12 @@ class Light(MIoTServiceEntity, LightEntity):
|
||||
device_id = list(
|
||||
self.miot_device.device_info.get("identifiers"))[0][1]
|
||||
self._command_send_mode_entity_id = entity_registry.async_get_entity_id(
|
||||
"select", DOMAIN, f"light_{device_id}_command_send_mode")
|
||||
"select", DOMAIN,
|
||||
f"{DOMAIN}.light_{device_id}_command_send_mode")
|
||||
command_send_mode = self.hass.states.get(
|
||||
self._command_send_mode_entity_id)
|
||||
if command_send_mode and command_send_mode.state == "Send Together":
|
||||
set_properties_list: List[Dict[str, Any]] = []
|
||||
# Do not send the light on command here. Otherwise,
|
||||
# the light will continue to use the color temperature and brightness of the last time.
|
||||
# if self._prop_on:
|
||||
# value_on = True if self._prop_on.format_ == bool else 1 # noqa: E721
|
||||
# set_properties_list.append({"prop": self._prop_on, "value": value_on})
|
||||
|
||||
# color-temperature
|
||||
if ATTR_COLOR_TEMP_KELVIN in kwargs:
|
||||
set_properties_list.append({
|
||||
@ -307,6 +302,12 @@ class Light(MIoTServiceEntity, LightEntity):
|
||||
self.get_map_key(map_=self._mode_map,
|
||||
value=kwargs[ATTR_EFFECT]),
|
||||
})
|
||||
if self._prop_on:
|
||||
value_on = True if self._prop_on.format_ == bool else 1 # noqa: E721
|
||||
set_properties_list.append({
|
||||
"prop": self._prop_on,
|
||||
"value": value_on
|
||||
})
|
||||
await self.set_properties_async(set_properties_list)
|
||||
self.async_write_ha_state()
|
||||
elif command_send_mode and command_send_mode.state == "Send Turn On First":
|
||||
|
||||
@ -125,7 +125,7 @@ class LightCommandSendMode(SelectEntity, RestoreEntity):
|
||||
self.hass = hass
|
||||
self._device_id = device_id
|
||||
self._attr_name = "Command Send Mode"
|
||||
self._attr_unique_id = f"light_{device_id}_command_send_mode"
|
||||
self._attr_unique_id = f"{DOMAIN}.light_{device_id}_command_send_mode"
|
||||
self._attr_options = [
|
||||
"Send One by One", "Send Turn On First", "Send Together"
|
||||
]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user