Skip to content

Commit cc64fa6

Browse files
authored
Add KNX UI entity config to diagnostics (home-assistant#151620)
1 parent 84140ba commit cc64fa6

File tree

3 files changed

+69
-7
lines changed

3 files changed

+69
-7
lines changed

homeassistant/components/knx/diagnostics.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,10 @@ async def async_get_config_entry_diagnostics(
5252
try:
5353
CONFIG_SCHEMA(raw_config)
5454
except vol.Invalid as ex:
55-
diag["configuration_error"] = str(ex)
55+
diag["yaml_configuration_error"] = str(ex)
5656
else:
57-
diag["configuration_error"] = None
57+
diag["yaml_configuration_error"] = None
58+
59+
diag["config_store"] = knx_module.config_store.data
5860

5961
return diag

tests/components/knx/snapshots/test_diagnostic.ambr

Lines changed: 60 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99
'rate_limit': 0,
1010
'state_updater': True,
1111
}),
12-
'configuration_error': "extra keys not allowed @ data['knx']['wrong_key']",
12+
'config_store': dict({
13+
'entities': dict({
14+
}),
15+
}),
1316
'configuration_yaml': dict({
1417
'wrong_key': dict({
1518
}),
@@ -19,6 +22,7 @@
1922
'current_address': '0.0.0',
2023
'version': '0.0.0',
2124
}),
25+
'yaml_configuration_error': "extra keys not allowed @ data['knx']['wrong_key']",
2226
})
2327
# ---
2428
# name: test_diagnostic_redact[hass_config0]
@@ -35,13 +39,17 @@
3539
'state_updater': True,
3640
'user_password': '**REDACTED**',
3741
}),
38-
'configuration_error': None,
42+
'config_store': dict({
43+
'entities': dict({
44+
}),
45+
}),
3946
'configuration_yaml': None,
4047
'project_info': None,
4148
'xknx': dict({
4249
'current_address': '0.0.0',
4350
'version': '0.0.0',
4451
}),
52+
'yaml_configuration_error': None,
4553
})
4654
# ---
4755
# name: test_diagnostics[hass_config0]
@@ -54,13 +62,17 @@
5462
'rate_limit': 0,
5563
'state_updater': True,
5664
}),
57-
'configuration_error': None,
65+
'config_store': dict({
66+
'entities': dict({
67+
}),
68+
}),
5869
'configuration_yaml': None,
5970
'project_info': None,
6071
'xknx': dict({
6172
'current_address': '0.0.0',
6273
'version': '0.0.0',
6374
}),
75+
'yaml_configuration_error': None,
6476
})
6577
# ---
6678
# name: test_diagnostics_project[hass_config0]
@@ -73,7 +85,50 @@
7385
'rate_limit': 0,
7486
'state_updater': True,
7587
}),
76-
'configuration_error': None,
88+
'config_store': dict({
89+
'entities': dict({
90+
'light': dict({
91+
'knx_es_01J85ZKTFHSZNG4X9DYBE592TF': dict({
92+
'entity': dict({
93+
'device_info': None,
94+
'entity_category': 'config',
95+
'name': 'test',
96+
}),
97+
'knx': dict({
98+
'color_temp_max': 6000,
99+
'color_temp_min': 2700,
100+
'ga_switch': dict({
101+
'passive': list([
102+
]),
103+
'state': '1/0/21',
104+
'write': '1/1/21',
105+
}),
106+
'sync_state': True,
107+
}),
108+
}),
109+
}),
110+
'switch': dict({
111+
'knx_es_9d97829f47f1a2a3176a7c5b4216070c': dict({
112+
'entity': dict({
113+
'device_info': 'knx_vdev_4c80a564f5fe5da701ed293966d6384d',
114+
'entity_category': None,
115+
'name': 'test',
116+
}),
117+
'knx': dict({
118+
'ga_switch': dict({
119+
'passive': list([
120+
]),
121+
'state': '1/0/45',
122+
'write': '1/1/45',
123+
}),
124+
'invert': False,
125+
'respond_to_read': False,
126+
'sync_state': True,
127+
}),
128+
}),
129+
}),
130+
}),
131+
}),
77132
'configuration_yaml': None,
78133
'project_info': dict({
79134
'created_by': 'ETS5',
@@ -91,5 +146,6 @@
91146
'current_address': '0.0.0',
92147
'version': '0.0.0',
93148
}),
149+
'yaml_configuration_error': None,
94150
})
95151
# ---

tests/components/knx/test_diagnostic.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,13 @@ async def test_diagnostics_project(
120120
snapshot: SnapshotAssertion,
121121
) -> None:
122122
"""Test diagnostics."""
123-
await knx.setup_integration()
123+
await knx.setup_integration(
124+
config_store_fixture="config_store_light_switch.json",
125+
state_updater=False,
126+
)
124127
knx.xknx.version = "0.0.0"
125128
# snapshot will contain project specific fields in `project_info`
129+
# and UI configuration in `config_store`
126130
assert (
127131
await get_diagnostics_for_config_entry(hass, hass_client, mock_config_entry)
128132
== snapshot

0 commit comments

Comments
 (0)