mirror of
https://github.com/home-assistant/core.git
synced 2026-09-26 01:11:51 -04:00
Add salt setting to Midea (#182436)
This commit is contained in:
@@ -13,7 +13,7 @@ from homeassistant.components.number import (
|
||||
NumberEntity,
|
||||
NumberEntityDescription,
|
||||
)
|
||||
from homeassistant.const import UnitOfTime, UnitOfVolume
|
||||
from homeassistant.const import UnitOfMass, UnitOfTime, UnitOfVolume
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||
|
||||
@@ -93,6 +93,16 @@ NUMBERS: list[MideaNumberEntityDescription] = [
|
||||
native_step=50,
|
||||
native_unit_of_measurement=UnitOfVolume.LITERS,
|
||||
),
|
||||
MideaNumberEntityDescription(
|
||||
key="salt_setting",
|
||||
translation_key="salt_setting",
|
||||
models=[DeviceType.ED],
|
||||
device_class=NumberDeviceClass.WEIGHT,
|
||||
native_min_value=0,
|
||||
native_max_value=255,
|
||||
native_step=1,
|
||||
native_unit_of_measurement=UnitOfMass.KILOGRAMS,
|
||||
),
|
||||
MideaNumberEntityDescription(
|
||||
key="heating_level",
|
||||
translation_key="heating_level",
|
||||
|
||||
@@ -226,6 +226,9 @@
|
||||
"leak_water_protection_value": {
|
||||
"name": "Leak water protection value"
|
||||
},
|
||||
"salt_setting": {
|
||||
"name": "Salt setting"
|
||||
},
|
||||
"seat_temp_level": {
|
||||
"name": "Seat temperature level"
|
||||
},
|
||||
|
||||
@@ -359,6 +359,67 @@
|
||||
'state': '500.0',
|
||||
})
|
||||
# ---
|
||||
# name: test_number_state_snapshot[ed][number.water_drinking_appliance_salt_setting-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': list([
|
||||
None,
|
||||
]),
|
||||
'area_id': None,
|
||||
'capabilities': dict({
|
||||
<NumberEntityCapabilityAttribute.MAX: 'max'>: 255,
|
||||
<NumberEntityCapabilityAttribute.MIN: 'min'>: 0,
|
||||
<NumberEntityCapabilityAttribute.MODE: 'mode'>: <NumberMode.AUTO: 'auto'>,
|
||||
<NumberEntityCapabilityAttribute.STEP: 'step'>: 1,
|
||||
}),
|
||||
'config_entry_id': <ANY>,
|
||||
'config_subentry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'number',
|
||||
'entity_category': None,
|
||||
'entity_id': 'number.water_drinking_appliance_salt_setting',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'object_id_base': 'Salt setting',
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': <NumberDeviceClass.WEIGHT: 'weight'>,
|
||||
'original_icon': None,
|
||||
'original_name': 'Salt setting',
|
||||
'platform': 'midea',
|
||||
'previous_unique_id': None,
|
||||
'suggested_object_id': None,
|
||||
'supported_features': 0,
|
||||
'translation_key': 'salt_setting',
|
||||
'unique_id': '12345678_salt_setting',
|
||||
'unit_of_measurement': <UnitOfMass.KILOGRAMS: 'kg'>,
|
||||
})
|
||||
# ---
|
||||
# name: test_number_state_snapshot[ed][number.water_drinking_appliance_salt_setting-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
<EntityStateAttribute.DEVICE_CLASS: 'device_class'>: 'weight',
|
||||
<EntityStateAttribute.FRIENDLY_NAME: 'friendly_name'>: 'Water Drinking Appliance Salt setting',
|
||||
<NumberEntityCapabilityAttribute.MAX: 'max'>: 255,
|
||||
<NumberEntityCapabilityAttribute.MIN: 'min'>: 0,
|
||||
<NumberEntityCapabilityAttribute.MODE: 'mode'>: <NumberMode.AUTO: 'auto'>,
|
||||
<NumberEntityCapabilityAttribute.STEP: 'step'>: 1,
|
||||
<EntityStateAttribute.UNIT_OF_MEASUREMENT: 'unit_of_measurement'>: <UnitOfMass.KILOGRAMS: 'kg'>,
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'number.water_drinking_appliance_salt_setting',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': '25.0',
|
||||
})
|
||||
# ---
|
||||
# name: test_number_state_snapshot[ed][number.water_drinking_appliance_water_hardness-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': list([
|
||||
|
||||
@@ -62,6 +62,7 @@ def _ed_device() -> DummyDevice:
|
||||
EDAttributes.water_hardness: 120,
|
||||
EDAttributes.flushing_days: 14,
|
||||
EDAttributes.leak_water_protection_value: 500,
|
||||
EDAttributes.salt_setting: 25,
|
||||
},
|
||||
)
|
||||
|
||||
@@ -181,7 +182,7 @@ async def test_ed_number_entities(
|
||||
hass: HomeAssistant,
|
||||
mock_config_entry: Callable[[DummyDevice], MockConfigEntry],
|
||||
) -> None:
|
||||
"""Test ED exposes water_hardness, flushing_days and leak_water_protection_value."""
|
||||
"""Test ED exposes water_hardness, flushing_days, leak_water_protection_value and salt_setting."""
|
||||
device = _ed_device()
|
||||
config_entry = mock_config_entry(device)
|
||||
with patch("homeassistant.components.midea._PLATFORMS", [Platform.NUMBER]):
|
||||
@@ -191,6 +192,7 @@ async def test_ed_number_entities(
|
||||
assert f"{TEST_DEVICE_ID}_water_hardness" in entities
|
||||
assert f"{TEST_DEVICE_ID}_flushing_days" in entities
|
||||
assert f"{TEST_DEVICE_ID}_leak_water_protection_value" in entities
|
||||
assert f"{TEST_DEVICE_ID}_salt_setting" in entities
|
||||
|
||||
leak_entry = entities[f"{TEST_DEVICE_ID}_leak_water_protection_value"]
|
||||
await _assert_service_call(
|
||||
@@ -201,6 +203,20 @@ async def test_ed_number_entities(
|
||||
device,
|
||||
)
|
||||
|
||||
salt_entry = entities[f"{TEST_DEVICE_ID}_salt_setting"]
|
||||
assert (salt_state := hass.states.get(salt_entry.entity_id)) is not None
|
||||
assert float(salt_state.state) == 25
|
||||
assert salt_state.attributes[ATTR_MIN] == 0
|
||||
assert salt_state.attributes[ATTR_MAX] == 255
|
||||
|
||||
await _assert_service_call(
|
||||
hass,
|
||||
salt_entry.entity_id,
|
||||
30,
|
||||
[("set_attribute", "salt_setting", 30)],
|
||||
device,
|
||||
)
|
||||
|
||||
|
||||
async def test_fb_heating_level(
|
||||
hass: HomeAssistant,
|
||||
|
||||
Reference in New Issue
Block a user