Fix bug in miele diagnostics (#143569)

Fix bug when redacting identifiers in diagnostics
This commit is contained in:
Åke Strandberg 2025-04-24 14:16:31 +02:00 committed by GitHub
parent f3ea11bbc1
commit e4fe7ba985
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 334 additions and 5 deletions

View File

@ -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(

View File

@ -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

View File

@ -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": "<fabNumber3>",
"fabIndex": "64",
"techType": "Fläkt",
"matNumber": "<matNumber3>",
"swids": ["<swid1>", "<swid2>", "<swid3>", "<...>"]
},
"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
}
}
}

View File

@ -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': '<matNumber3>',
'swids': list([
'<swid1>',
'<swid2>',
'<swid3>',
'<...>',
]),
'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({

View File

@ -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': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'sensor',
'entity_category': None,
'entity_id': 'sensor.hood',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <SensorDeviceClass.ENUM: 'enum'>,
'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': <ANY>,
'entity_id': 'sensor.hood',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---
# name: test_sensor_states[platforms0][sensor.refrigerator-entry]
EntityRegistryEntrySnapshot({
'aliases': set({

View File

@ -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(