diff --git a/homeassistant/components/miele/diagnostics.py b/homeassistant/components/miele/diagnostics.py index 2dbb88fbca6..20a08191bb6 100644 --- a/homeassistant/components/miele/diagnostics.py +++ b/homeassistant/components/miele/diagnostics.py @@ -21,9 +21,10 @@ def hash_identifier(key: str) -> str: def redact_identifiers(in_data: dict[str, Any]) -> dict[str, Any]: """Redact identifiers from the data.""" - for key in in_data: - in_data[hash_identifier(key)] = in_data.pop(key) - return in_data + out_data = {} + for key, value in in_data.items(): + out_data[hash_identifier(key)] = value + return out_data async def async_get_config_entry_diagnostics( diff --git a/tests/components/miele/conftest.py b/tests/components/miele/conftest.py index 077428d07df..6df5b73ccc2 100644 --- a/tests/components/miele/conftest.py +++ b/tests/components/miele/conftest.py @@ -70,7 +70,7 @@ async def setup_credentials(hass: HomeAssistant) -> None: @pytest.fixture(scope="package") def load_device_file() -> str: """Fixture for loading device file.""" - return "3_devices.json" + return "4_devices.json" @pytest.fixture diff --git a/tests/components/miele/fixtures/3_devices.json b/tests/components/miele/fixtures/4_devices.json similarity index 78% rename from tests/components/miele/fixtures/3_devices.json rename to tests/components/miele/fixtures/4_devices.json index 58447740ca4..b63c60ff4d3 100644 --- a/tests/components/miele/fixtures/3_devices.json +++ b/tests/components/miele/fixtures/4_devices.json @@ -366,5 +366,105 @@ }, "batteryLevel": null } + }, + "DummyAppliance_18": { + "ident": { + "type": { + "key_localized": "Device type", + "value_raw": 18, + "value_localized": "Cooker Hood" + }, + "deviceName": "", + "protocolVersion": 2, + "deviceIdentLabel": { + "fabNumber": "", + "fabIndex": "64", + "techType": "Fläkt", + "matNumber": "", + "swids": ["", "", "", "<...>"] + }, + "xkmIdentLabel": { + "techType": "EK039W", + "releaseVersion": "02.72" + } + }, + "state": { + "ProgramID": { + "value_raw": 1, + "value_localized": "Off", + "key_localized": "Program name" + }, + "status": { + "value_raw": 1, + "value_localized": "Off", + "key_localized": "status" + }, + "programType": { + "value_raw": 0, + "value_localized": "Program", + "key_localized": "Program type" + }, + "programPhase": { + "value_raw": 4608, + "value_localized": "", + "key_localized": "Program phase" + }, + "remainingTime": [0, 0], + "startTime": [0, 0], + "targetTemperature": [ + { + "value_raw": -32768, + "value_localized": null, + "unit": "Celsius" + } + ], + "temperature": [ + { + "value_raw": -32768, + "value_localized": null, + "unit": "Celsius" + }, + { + "value_raw": -32768, + "value_localized": null, + "unit": "Celsius" + }, + { + "value_raw": -32768, + "value_localized": null, + "unit": "Celsius" + } + ], + "signalInfo": false, + "signalFailure": false, + "signalDoor": false, + "remoteEnable": { + "fullRemoteControl": true, + "smartGrid": false, + "mobileStart": false + }, + "ambientLight": 2, + "light": 1, + "elapsedTime": {}, + "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": 0, + "value_localized": "0", + "key_localized": "Fan level" + }, + "plateStep": [], + "ecoFeedback": null, + "batteryLevel": null + } } } diff --git a/tests/components/miele/snapshots/test_diagnostics.ambr b/tests/components/miele/snapshots/test_diagnostics.ambr index 63afcdecb42..2aac726cbad 100644 --- a/tests/components/miele/snapshots/test_diagnostics.ambr +++ b/tests/components/miele/snapshots/test_diagnostics.ambr @@ -37,6 +37,31 @@ 'ventilationStep': list([ ]), }), + '**REDACTED_4b870e84d3e80013': dict({ + 'ambientLight': list([ + ]), + 'colors': list([ + ]), + 'deviceName': True, + 'light': list([ + ]), + 'modes': list([ + ]), + 'powerOff': False, + 'powerOn': True, + 'processAction': list([ + ]), + 'programId': list([ + ]), + 'runOnTime': list([ + ]), + 'startTime': list([ + ]), + 'targetTemperature': list([ + ]), + 'ventilationStep': list([ + ]), + }), '**REDACTED_57d53e72806e88b4': dict({ 'ambientLight': list([ ]), @@ -213,6 +238,119 @@ }), }), }), + '**REDACTED_4b870e84d3e80013': dict({ + 'ident': dict({ + 'deviceIdentLabel': dict({ + 'fabIndex': '64', + 'fabNumber': '**REDACTED**', + 'matNumber': '', + 'swids': list([ + '', + '', + '', + '<...>', + ]), + 'techType': 'Fläkt', + }), + 'deviceName': '', + 'protocolVersion': 2, + 'type': dict({ + 'key_localized': 'Device type', + 'value_localized': 'Cooker Hood', + 'value_raw': 18, + }), + 'xkmIdentLabel': dict({ + 'releaseVersion': '02.72', + 'techType': 'EK039W', + }), + }), + 'state': dict({ + 'ProgramID': dict({ + 'key_localized': 'Program name', + 'value_localized': 'Off', + 'value_raw': 1, + }), + 'ambientLight': 2, + 'batteryLevel': None, + 'dryingStep': dict({ + 'key_localized': 'Drying level', + 'value_localized': '', + 'value_raw': None, + }), + 'ecoFeedback': None, + 'elapsedTime': dict({ + }), + 'light': 1, + 'plateStep': list([ + ]), + 'programPhase': dict({ + 'key_localized': 'Program phase', + 'value_localized': '', + 'value_raw': 4608, + }), + 'programType': dict({ + 'key_localized': 'Program type', + 'value_localized': 'Program', + 'value_raw': 0, + }), + 'remainingTime': list([ + 0, + 0, + ]), + 'remoteEnable': dict({ + 'fullRemoteControl': True, + 'mobileStart': False, + 'smartGrid': False, + }), + 'signalDoor': False, + 'signalFailure': False, + 'signalInfo': False, + 'spinningSpeed': dict({ + 'key_localized': 'Spin speed', + 'unit': 'rpm', + 'value_localized': None, + 'value_raw': None, + }), + 'startTime': list([ + 0, + 0, + ]), + 'status': dict({ + 'key_localized': 'status', + 'value_localized': 'Off', + 'value_raw': 1, + }), + 'targetTemperature': list([ + dict({ + 'unit': 'Celsius', + 'value_localized': None, + 'value_raw': -32768, + }), + ]), + 'temperature': list([ + dict({ + 'unit': 'Celsius', + 'value_localized': None, + 'value_raw': -32768, + }), + dict({ + 'unit': 'Celsius', + 'value_localized': None, + 'value_raw': -32768, + }), + dict({ + 'unit': 'Celsius', + 'value_localized': None, + 'value_raw': -32768, + }), + ]), + 'ventilationStep': dict({ + 'key_localized': 'Fan level', + 'value_localized': '0', + 'value_raw': 0, + }), + }), + }), '**REDACTED_57d53e72806e88b4': dict({ 'ident': dict({ 'deviceIdentLabel': dict({ diff --git a/tests/components/miele/snapshots/test_sensor.ambr b/tests/components/miele/snapshots/test_sensor.ambr index 0a29ec46472..72878482c08 100644 --- a/tests/components/miele/snapshots/test_sensor.ambr +++ b/tests/components/miele/snapshots/test_sensor.ambr @@ -141,6 +141,96 @@ 'state': '-18.0', }) # --- +# name: test_sensor_states[platforms0][sensor.hood-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'options': list([ + 'off', + 'on', + 'programmed', + 'waiting_to_start', + 'in_use', + 'pause', + 'program_ended', + 'failure', + 'program_interrupted', + 'idle', + 'rinse_hold', + 'service', + 'superfreezing', + 'supercooling', + 'superheating', + 'supercooling_superfreezing', + 'autocleaning', + 'not_connected', + ]), + }), + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': None, + 'entity_id': 'sensor.hood', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': 'mdi:turbine', + 'original_name': None, + 'platform': 'miele', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'status', + 'unique_id': 'DummyAppliance_18-state_status', + 'unit_of_measurement': None, + }) +# --- +# name: test_sensor_states[platforms0][sensor.hood-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'enum', + 'friendly_name': 'Hood', + 'icon': 'mdi:turbine', + 'options': list([ + 'off', + 'on', + 'programmed', + 'waiting_to_start', + 'in_use', + 'pause', + 'program_ended', + 'failure', + 'program_interrupted', + 'idle', + 'rinse_hold', + 'service', + 'superfreezing', + 'supercooling', + 'superheating', + 'supercooling_superfreezing', + 'autocleaning', + 'not_connected', + ]), + }), + 'context': , + 'entity_id': 'sensor.hood', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'off', + }) +# --- # name: test_sensor_states[platforms0][sensor.refrigerator-entry] EntityRegistryEntrySnapshot({ 'aliases': set({ diff --git a/tests/components/miele/test_init.py b/tests/components/miele/test_init.py index e4f1d27e565..e32830c7540 100644 --- a/tests/components/miele/test_init.py +++ b/tests/components/miele/test_init.py @@ -101,7 +101,7 @@ async def test_devices_multiple_created_count( """Test that multiple devices are created.""" await setup_integration(hass, mock_config_entry) - assert len(device_registry.devices) == 3 + assert len(device_registry.devices) == 4 async def test_device_info(