Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions custom_components/xiaomi_home/miot/specs/spec_modify.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -122,23 +122,37 @@ urn:miot-spec-v2:device:air-conditioner:0000A004:xiaomi-rr0r00:3: urn:miot-spec-
urn:miot-spec-v2:device:air-conditioner:0000A004:xiaomi-rr0r00:4: urn:miot-spec-v2:device:air-conditioner:0000A004:xiaomi-rr0r00:1
urn:miot-spec-v2:device:air-fresh:0000A012:daikin-k33:1:
prop.2.1:
name: ac-on
name: 'on'
format: string
access:
- read
- write
- notify
expr: src_value in ["OPEN", True, 1, "1", "true", "True"]
prop.2.3:
name: ac-mode
name: 'mode'
format: string
access:
- read
- write
- notify
expr: 2 if src_value == "AUTO_MODE" else src_value
value-list:
- value: 2
description: 自动
prop.2.5:
name: ac-fan-level
name: 'fan-level'
format: string
access:
- read
- write
- notify
expr: 1 if src_value in ["MID", "LOW", "WEAK"] else 2 if src_value in ["STRONG", "HIGH"] else src_value
value-list:
- value: 1
description: 50%
- value: 2
description: 100%
urn:miot-spec-v2:device:air-monitor:0000A008:cgllc-cgd1st:1:
prop.3.7:
value-range:
Expand Down
26 changes: 25 additions & 1 deletion custom_components/xiaomi_home/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ async def async_setup_entry(
for miot_device in device_list:
for prop in miot_device.prop_list.get('select', []):
new_entities.append(Select(miot_device=miot_device, spec=prop))
if miot_device.model == 'daikin.airfresh.k33':
for entity_data in miot_device.entity_list.get('fan', []):
for prop in entity_data.props:
if prop.name == 'fan-level':
new_entities.append(
Select(miot_device=miot_device, spec=prop))

if new_entities:
async_add_entities(new_entities)
Expand All @@ -82,15 +88,33 @@ class Select(MIoTPropertyEntity, SelectEntity):
def __init__(self, miot_device: MIoTDevice, spec: MIoTSpecProperty) -> None:
"""Initialize the Select."""
super().__init__(miot_device=miot_device, spec=spec)
self._custom_options_map: dict | None = None
if miot_device.model == 'daikin.airfresh.k33' and spec.name == 'fan-level':
self._custom_options_map = {
1: '50%',
2: '100%',
}
if self._value_list:
self._attr_options = self._value_list.descriptions
self._attr_options = (
list(self._custom_options_map.values())
if self._custom_options_map
else self._value_list.descriptions
)

async def async_select_option(self, option: str) -> None:
"""Change the selected option."""
if self._custom_options_map:
reverse_map = {
value: key for key, value in self._custom_options_map.items()
}
await self.set_property_async(value=reverse_map.get(option))
return
await self.set_property_async(
value=self.get_vlist_value(description=option))

@property
def current_option(self) -> Optional[str]:
"""Return the current selected option."""
if self._custom_options_map:
return self._custom_options_map.get(self._value)
return self.get_vlist_description(value=self._value)
6 changes: 6 additions & 0 deletions custom_components/xiaomi_home/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ async def async_setup_entry(
for miot_device in device_list:
for prop in miot_device.prop_list.get('switch', []):
new_entities.append(Switch(miot_device=miot_device, spec=prop))
if miot_device.model == 'daikin.airfresh.k33':
for entity_data in miot_device.entity_list.get('fan', []):
for prop in entity_data.props:
if prop.name == 'on':
new_entities.append(
Switch(miot_device=miot_device, spec=prop))

if new_entities:
async_add_entities(new_entities)
Expand Down