Improve miele climate test coverage (#149859)

This commit is contained in:
Åke Strandberg 2025-08-03 11:19:08 +02:00 committed by GitHub
parent 08f7b708a4
commit b2349ac2bd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 383 additions and 20 deletions

View File

@ -648,5 +648,129 @@
},
"batteryLevel": null
}
},
"DummyAppliance_12": {
"ident": {
"type": {
"key_localized": "Device type",
"value_raw": 12,
"value_localized": "Oven"
},
"deviceName": "",
"protocolVersion": 4,
"deviceIdentLabel": {
"fabNumber": "**REDACTED**",
"fabIndex": "16",
"techType": "H7660BP",
"matNumber": "11120960",
"swids": []
},
"xkmIdentLabel": {
"techType": "EK057",
"releaseVersion": "08.32"
}
},
"state": {
"ProgramID": {
"value_raw": 356,
"value_localized": "Defrost",
"key_localized": "Program name"
},
"status": {
"value_raw": 5,
"value_localized": "In use",
"key_localized": "status"
},
"programType": {
"value_raw": 1,
"value_localized": "Program",
"key_localized": "Program type"
},
"programPhase": {
"value_raw": 3073,
"value_localized": "Heating-up phase",
"key_localized": "Program phase"
},
"remainingTime": [0, 5],
"startTime": [0, 0],
"targetTemperature": [
{
"value_raw": 2500,
"value_localized": 25.0,
"unit": "Celsius"
},
{
"value_raw": -32768,
"value_localized": null,
"unit": "Celsius"
},
{
"value_raw": -32768,
"value_localized": null,
"unit": "Celsius"
}
],
"coreTargetTemperature": [
{
"value_raw": -32768,
"value_localized": null,
"unit": "Celsius"
}
],
"temperature": [
{
"value_raw": 1954,
"value_localized": 19.54,
"unit": "Celsius"
},
{
"value_raw": -32768,
"value_localized": null,
"unit": "Celsius"
},
{
"value_raw": -32768,
"value_localized": null,
"unit": "Celsius"
}
],
"coreTemperature": [
{
"value_raw": 2200,
"value_localized": 22.0,
"unit": "Celsius"
}
],
"signalInfo": false,
"signalFailure": false,
"signalDoor": false,
"remoteEnable": {
"fullRemoteControl": true,
"smartGrid": false,
"mobileStart": true
},
"ambientLight": null,
"light": 1,
"elapsedTime": [0, 0],
"spinningSpeed": {
"unit": "rpm",
"value_raw": null,
"value_localized": null,
"key_localized": "Spin speed"
},
"dryingStep": {
"value_raw": null,
"value_localized": "",
"key_localized": "Drying level"
},
"ventilationStep": {
"value_raw": null,
"value_localized": "",
"key_localized": "Fan level"
},
"plateStep": [],
"ecoFeedback": null,
"batteryLevel": null
}
}
}

View File

@ -0,0 +1,31 @@
{
"processAction": [6],
"light": [],
"ambientLight": [],
"startTime": [],
"ventilationStep": [],
"programId": [],
"targetTemperature": [
{
"zone": 1,
"min": 1,
"max": 9
},
{
"zone": 2,
"min": -28,
"max": -14
},
{
"zone": 3,
"min": -30,
"max": -15
}
],
"deviceName": true,
"powerOn": false,
"powerOff": false,
"colors": [],
"modes": [1],
"runOnTime": []
}

View File

@ -53,6 +53,11 @@
"value_raw": -1800,
"value_localized": -18.0,
"unit": "Celsius"
},
{
"value_raw": -2500,
"value_localized": -25.0,
"unit": "Celsius"
}
],
"coreTargetTemperature": [],
@ -68,8 +73,8 @@
"unit": "Celsius"
},
{
"value_raw": -32768,
"value_localized": null,
"value_raw": -2800,
"value_localized": -28.0,
"unit": "Celsius"
}
],

View File

@ -1,5 +1,5 @@
# serializer version: 1
# name: test_climate_states[platforms0-freezer][climate.freezer-entry]
# name: test_climate_states[freezer-platforms0][climate.freezer-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
@ -41,7 +41,7 @@
'unit_of_measurement': None,
})
# ---
# name: test_climate_states[platforms0-freezer][climate.freezer-state]
# name: test_climate_states[freezer-platforms0][climate.freezer-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'current_temperature': -18,
@ -63,7 +63,7 @@
'state': 'cool',
})
# ---
# name: test_climate_states[platforms0-freezer][climate.refrigerator-entry]
# name: test_climate_states[freezer-platforms0][climate.refrigerator-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
@ -105,7 +105,7 @@
'unit_of_measurement': None,
})
# ---
# name: test_climate_states[platforms0-freezer][climate.refrigerator-state]
# name: test_climate_states[freezer-platforms0][climate.refrigerator-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'current_temperature': 4,
@ -127,7 +127,7 @@
'state': 'cool',
})
# ---
# name: test_climate_states_api_push[platforms0-freezer][climate.freezer-entry]
# name: test_climate_states_api_push[freezer-platforms0][climate.freezer-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
@ -169,7 +169,7 @@
'unit_of_measurement': None,
})
# ---
# name: test_climate_states_api_push[platforms0-freezer][climate.freezer-state]
# name: test_climate_states_api_push[freezer-platforms0][climate.freezer-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'current_temperature': -18,
@ -191,7 +191,7 @@
'state': 'cool',
})
# ---
# name: test_climate_states_api_push[platforms0-freezer][climate.refrigerator-entry]
# name: test_climate_states_api_push[freezer-platforms0][climate.refrigerator-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
@ -233,7 +233,7 @@
'unit_of_measurement': None,
})
# ---
# name: test_climate_states_api_push[platforms0-freezer][climate.refrigerator-state]
# name: test_climate_states_api_push[freezer-platforms0][climate.refrigerator-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'current_temperature': 4,
@ -255,3 +255,195 @@
'state': 'cool',
})
# ---
# name: test_climate_states_mulizone[fridge_freezer-fridge_freezer.json-platforms0][climate.fridge_freezer_freezer-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'hvac_modes': list([
<HVACMode.COOL: 'cool'>,
]),
'max_temp': -14,
'min_temp': -28,
'target_temp_step': 1.0,
}),
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'climate',
'entity_category': None,
'entity_id': 'climate.fridge_freezer_freezer',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Freezer',
'platform': 'miele',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': <ClimateEntityFeature: 1>,
'translation_key': 'freezer',
'unique_id': 'DummyAppliance_Fridge_Freezer-thermostat2-2',
'unit_of_measurement': None,
})
# ---
# name: test_climate_states_mulizone[fridge_freezer-fridge_freezer.json-platforms0][climate.fridge_freezer_freezer-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'current_temperature': -18,
'friendly_name': 'Fridge freezer Freezer',
'hvac_modes': list([
<HVACMode.COOL: 'cool'>,
]),
'max_temp': -14,
'min_temp': -28,
'supported_features': <ClimateEntityFeature: 1>,
'target_temp_step': 1.0,
'temperature': -18,
}),
'context': <ANY>,
'entity_id': 'climate.fridge_freezer_freezer',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'cool',
})
# ---
# name: test_climate_states_mulizone[fridge_freezer-fridge_freezer.json-platforms0][climate.fridge_freezer_refrigerator-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'hvac_modes': list([
<HVACMode.COOL: 'cool'>,
]),
'max_temp': 9,
'min_temp': 1,
'target_temp_step': 1.0,
}),
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'climate',
'entity_category': None,
'entity_id': 'climate.fridge_freezer_refrigerator',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Refrigerator',
'platform': 'miele',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': <ClimateEntityFeature: 1>,
'translation_key': 'refrigerator',
'unique_id': 'DummyAppliance_Fridge_Freezer-thermostat-1',
'unit_of_measurement': None,
})
# ---
# name: test_climate_states_mulizone[fridge_freezer-fridge_freezer.json-platforms0][climate.fridge_freezer_refrigerator-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'current_temperature': 4,
'friendly_name': 'Fridge freezer Refrigerator',
'hvac_modes': list([
<HVACMode.COOL: 'cool'>,
]),
'max_temp': 9,
'min_temp': 1,
'supported_features': <ClimateEntityFeature: 1>,
'target_temp_step': 1.0,
'temperature': 4,
}),
'context': <ANY>,
'entity_id': 'climate.fridge_freezer_refrigerator',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'cool',
})
# ---
# name: test_climate_states_mulizone[fridge_freezer-fridge_freezer.json-platforms0][climate.fridge_freezer_zone_3-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'hvac_modes': list([
<HVACMode.COOL: 'cool'>,
]),
'max_temp': -15,
'min_temp': -30,
'target_temp_step': 1.0,
}),
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'climate',
'entity_category': None,
'entity_id': 'climate.fridge_freezer_zone_3',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Zone 3',
'platform': 'miele',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': <ClimateEntityFeature: 1>,
'translation_key': 'zone_3',
'unique_id': 'DummyAppliance_Fridge_Freezer-thermostat3-3',
'unit_of_measurement': None,
})
# ---
# name: test_climate_states_mulizone[fridge_freezer-fridge_freezer.json-platforms0][climate.fridge_freezer_zone_3-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'current_temperature': -28,
'friendly_name': 'Fridge freezer Zone 3',
'hvac_modes': list([
<HVACMode.COOL: 'cool'>,
]),
'max_temp': -15,
'min_temp': -30,
'supported_features': <ClimateEntityFeature: 1>,
'target_temp_step': 1.0,
'temperature': -25,
}),
'context': <ANY>,
'entity_id': 'climate.fridge_freezer_zone_3',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'cool',
})
# ---

View File

@ -15,21 +15,13 @@ from homeassistant.helpers import entity_registry as er
from tests.common import MockConfigEntry, snapshot_platform
TEST_PLATFORM = CLIMATE_DOMAIN
pytestmark = [
pytest.mark.parametrize("platforms", [(TEST_PLATFORM,)]),
pytest.mark.parametrize(
"load_action_file",
["action_freezer.json"],
ids=[
"freezer",
],
),
]
pytestmark = pytest.mark.parametrize("platforms", [(TEST_PLATFORM,)])
ENTITY_ID = "climate.freezer"
SERVICE_SET_TEMPERATURE = "set_temperature"
@pytest.mark.parametrize("load_action_file", ["action_freezer.json"], ids=["freezer"])
async def test_climate_states(
hass: HomeAssistant,
mock_miele_client: MagicMock,
@ -42,7 +34,24 @@ async def test_climate_states(
await snapshot_platform(hass, entity_registry, snapshot, setup_platform.entry_id)
@pytest.mark.parametrize("load_device_file", ["fridge_freezer.json"])
@pytest.mark.parametrize(
"load_action_file", ["action_fridge_freezer.json"], ids=["fridge_freezer"]
)
async def test_climate_states_mulizone(
hass: HomeAssistant,
mock_miele_client: MagicMock,
snapshot: SnapshotAssertion,
entity_registry: er.EntityRegistry,
setup_platform: MockConfigEntry,
) -> None:
"""Test climate entity state."""
await snapshot_platform(hass, entity_registry, snapshot, setup_platform.entry_id)
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
@pytest.mark.parametrize("load_action_file", ["action_freezer.json"], ids=["freezer"])
async def test_climate_states_api_push(
hass: HomeAssistant,
mock_miele_client: MagicMock,
@ -56,6 +65,7 @@ async def test_climate_states_api_push(
await snapshot_platform(hass, entity_registry, snapshot, setup_platform.entry_id)
@pytest.mark.parametrize("load_action_file", ["action_freezer.json"], ids=["freezer"])
async def test_set_target(
hass: HomeAssistant,
mock_miele_client: MagicMock,
@ -74,6 +84,7 @@ async def test_set_target(
)
@pytest.mark.parametrize("load_action_file", ["action_freezer.json"], ids=["freezer"])
async def test_api_failure(
hass: HomeAssistant,
mock_miele_client: MagicMock,