mirror of
https://github.com/home-assistant/core.git
synced 2026-12-03 04:08:19 -04:00
Add anion switch support for Midea A1 dehumidifiers (#188172)
Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> Co-authored-by: Lucas Mindêllo de Andrade <lucas@mindello.com.br>
This commit is contained in:
co-authored by
Simone Chemelli
Lucas Mindêllo de Andrade
parent
2400b27d98
commit
84e42ce4d7
@@ -101,7 +101,7 @@ SWITCHES: list[MideaSwitchEntityDescription] = [
|
||||
MideaSwitchEntityDescription(
|
||||
key="anion",
|
||||
translation_key="anion",
|
||||
models=[DeviceType.AC],
|
||||
models=[DeviceType.AC, DeviceType.A1],
|
||||
entity_category=EntityCategory.CONFIG,
|
||||
),
|
||||
MideaSwitchEntityDescription(
|
||||
|
||||
@@ -1,4 +1,54 @@
|
||||
# serializer version: 1
|
||||
# name: test_switch_state_snapshot[a1][switch.dehumidifier_anion-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': list([
|
||||
None,
|
||||
]),
|
||||
'area_id': None,
|
||||
'capabilities': None,
|
||||
'config_entry_id': <ANY>,
|
||||
'config_subentry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'switch',
|
||||
'entity_category': <EntityCategory.CONFIG: 'config'>,
|
||||
'entity_id': 'switch.dehumidifier_anion',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'object_id_base': 'Anion',
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': None,
|
||||
'original_icon': None,
|
||||
'original_name': 'Anion',
|
||||
'platform': 'midea',
|
||||
'previous_unique_id': None,
|
||||
'suggested_object_id': None,
|
||||
'supported_features': 0,
|
||||
'translation_key': 'anion',
|
||||
'unique_id': '12345678_anion',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_switch_state_snapshot[a1][switch.dehumidifier_anion-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
<EntityStateAttribute.FRIENDLY_NAME: 'friendly_name'>: 'Dehumidifier Anion',
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'switch.dehumidifier_anion',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'on',
|
||||
})
|
||||
# ---
|
||||
# name: test_switch_state_snapshot[a1][switch.dehumidifier_pump-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': list([
|
||||
|
||||
@@ -127,7 +127,10 @@ def _set_attribute_calls(device: DummyDevice) -> list[tuple]:
|
||||
pytest.param(
|
||||
DummyDevice(
|
||||
DeviceType.A1,
|
||||
attributes={A1Attributes.pump: False},
|
||||
attributes={
|
||||
A1Attributes.anion: True,
|
||||
A1Attributes.pump: False,
|
||||
},
|
||||
capabilities={"pump": True},
|
||||
),
|
||||
id="a1",
|
||||
@@ -685,6 +688,46 @@ async def test_a1_pump_services(
|
||||
assert state.state == STATE_OFF
|
||||
|
||||
|
||||
async def test_a1_anion_services(
|
||||
hass: HomeAssistant,
|
||||
mock_config_entry: Callable[[DummyDevice], MockConfigEntry],
|
||||
) -> None:
|
||||
"""Test the A1 dehumidifier anion switch."""
|
||||
device = DummyDevice(
|
||||
DeviceType.A1,
|
||||
attributes={A1Attributes.anion: False},
|
||||
)
|
||||
config_entry = mock_config_entry(device)
|
||||
with patch("homeassistant.components.midea._PLATFORMS", [Platform.SWITCH]):
|
||||
await setup_integration(hass, config_entry, device)
|
||||
entity_entry = entity_entries(hass, config_entry)[f"{TEST_DEVICE_ID}_anion"]
|
||||
|
||||
assert (state := hass.states.get(entity_entry.entity_id)) is not None
|
||||
assert state.state == STATE_OFF
|
||||
|
||||
await _assert_service_call(
|
||||
hass,
|
||||
entity_entry.entity_id,
|
||||
SERVICE_TURN_ON,
|
||||
[("set_attribute", A1Attributes.anion, True)],
|
||||
device,
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert (state := hass.states.get(entity_entry.entity_id)) is not None
|
||||
assert state.state == STATE_ON
|
||||
|
||||
await _assert_service_call(
|
||||
hass,
|
||||
entity_entry.entity_id,
|
||||
SERVICE_TURN_OFF,
|
||||
[("set_attribute", A1Attributes.anion, False)],
|
||||
device,
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert (state := hass.states.get(entity_entry.entity_id)) is not None
|
||||
assert state.state == STATE_OFF
|
||||
|
||||
|
||||
async def test_a1_pump_not_created_without_capability(
|
||||
hass: HomeAssistant,
|
||||
mock_config_entry: Callable[[DummyDevice], MockConfigEntry],
|
||||
|
||||
Reference in New Issue
Block a user