Skip to content

Commit ab84146

Browse files
committed
Use 2024.3.0 native config entry JSON
1 parent 9f68ae7 commit ab84146

File tree

6 files changed

+21
-20
lines changed

6 files changed

+21
-20
lines changed

custom_components/lock_code_manager/websocket.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,13 @@ async def get_config_entry_entities(
134134
"""Return lock_code_manager config entry data."""
135135
connection.send_result(
136136
msg["id"],
137-
[
138-
config_entry.entry_id,
139-
config_entry.title,
140-
[
137+
{
138+
"config_entry": config_entry.as_json_fragment,
139+
"entities": [
141140
entity.as_partial_dict
142141
for entity in er.async_entries_for_config_entry(
143142
er.async_get(hass), config_entry.entry_id
144143
)
145144
],
146-
],
145+
},
147146
)

custom_components/lock_code_manager/www/lock-code-manager-strategy.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

hacs.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
"name": "lock_code_manager",
33
"zip_release": true,
44
"filename": "lock_code_manager.zip",
5-
"homeassistant": "2024.2.0",
5+
"homeassistant": "2024.3.0",
66
"render_readme": true
77
}

js/types.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ export interface LockCodeManagerViewStrategyConfig extends LockCodeManagerStrate
2929
type: 'custom:lock-code-manager';
3030
}
3131

32-
export type LockCodeManagerEntitiesResponse = [string, string, EntityRegistryEntry[]];
32+
export interface LockCodeManagerEntitiesResponse {
33+
config_entry: ConfigEntryJSONFragment;
34+
entities: EntityRegistryEntry[];
35+
}
3336

3437
export interface LockCodeManagerConfigEntryData {
3538
locks: string[];

js/view-strategy.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,15 @@ export class LockCodeManagerViewStrategy extends ReactiveElement {
2626
};
2727
}
2828
try {
29-
const [configEntryId, configEntryTitle, entities] =
30-
await hass.callWS<LockCodeManagerEntitiesResponse>({
31-
config_entry_id,
32-
config_entry_title,
33-
type: 'lock_code_manager/get_config_entry_entities'
34-
});
29+
const { config_entry, entities } = await hass.callWS<LockCodeManagerEntitiesResponse>({
30+
config_entry_id,
31+
config_entry_title,
32+
type: 'lock_code_manager/get_config_entry_entities'
33+
});
3534
return generateView(
3635
hass,
37-
configEntryId,
38-
configEntryTitle,
36+
config_entry.entry_id,
37+
config_entry.title,
3938
entities,
4039
config.include_code_slot_sensors ?? DEFAULT_INCLUDE_CODE_SLOT_SENSORS
4140
);

tests/test_websocket.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ async def test_get_config_entry_entities(
103103
)
104104
msg = await ws_client.receive_json()
105105
assert msg["success"]
106-
[entry_id, title, entities] = msg["result"]
107-
assert entry_id == lock_code_manager_config_entry.entry_id
108-
assert title == "Mock Title"
109-
assert len(entities) == 15
106+
result = msg["result"]
107+
assert result["entry_id"] == lock_code_manager_config_entry.entry_id
108+
assert result["title"] == "Mock Title"
109+
assert len(result["entities"]) == 15

0 commit comments

Comments
 (0)