Skip to content

Commit 202f37d

Browse files
authored
Add docs for extract_from_target websocket api (#2749)
1 parent 406be3a commit 202f37d

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

docs/api/websocket.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,57 @@ The server will respond with the validation results. Only fields will be include
529529
}
530530
```
531531

532+
## Extract from target
533+
534+
This command allows you to extract entities, devices, and areas from one or multiple targets.
535+
536+
```json
537+
{
538+
"id": 19,
539+
"type": "extract_from_target",
540+
"target": {
541+
"entity_id": ["group.kitchen"],
542+
"device_id": ["device_abc123"],
543+
"area_id": ["kitchen"],
544+
"label_id": ["smart_lights"]
545+
},
546+
// Optional: expand group entities to their members (default: false)
547+
"expand_group": true
548+
}
549+
```
550+
551+
The target parameter follows the same structure as service call targets.
552+
553+
The server will respond with the information extracted from the target:
554+
555+
```json
556+
{
557+
"id": 19,
558+
"type": "result",
559+
"success": true,
560+
"result": {
561+
"referenced_entities": ["light.kitchen", "switch.kitchen", "light.living_room", "switch.bedroom"],
562+
"referenced_devices": ["device_abc123", "device_def456"],
563+
"referenced_areas": ["kitchen", "living_room"],
564+
"missing_devices": [],
565+
"missing_areas": [],
566+
"missing_floors": [],
567+
"missing_labels": []
568+
}
569+
}
570+
```
571+
572+
The response includes:
573+
- `referenced_entities`: All entity IDs that would be targeted (includes entities from devices/areas/labels)
574+
- `referenced_devices`: All device IDs that were referenced
575+
- `referenced_areas`: All area IDs that were referenced
576+
- `missing_devices`: Device IDs that don't exist
577+
- `missing_areas`: Area IDs that don't exist
578+
- `missing_floors`: Floor IDs that don't exist
579+
- `missing_labels`: Label IDs that don't exist
580+
581+
When `expand_group` is set to `true`, group entities will be expanded to include their member entities instead of the group entity itself.
582+
532583
## Error handling
533584

534585
If an error occurs, the `success` key in the `result` message will be set to `false`. It will contain an `error` key containing an object with two keys: `code` and `message`.

0 commit comments

Comments
 (0)