Ausgehend vom Bedarf von Filtrer les scènes qui utilisent un élément précis (appareil MQTT, appareil Zigbee,...) und basierend auf dem Vorschlag von @mutmut in https://community.gladysassistant.com/t/nouvelle-page-appareils-qui-affichent-tous-les-appareils-de-linstance/10547/4:
Es wäre hilfreich, wenn die neue Seite „Geräte“ Dashboards und Szenen anzeigen könnte, in denen ein Gerät verwendet wird. Dadurch könnte man insbesondere die Dashboards und Szenen identifizieren, die angepasst werden müssen, bevor ein Gerät gelöscht wird, oder ein Gerät, das nirgends verwendet wird.
Ich frage mich, ob es ausreicht, dies für das Gerät (global) zu tun, oder ob man die Verwendungen für jede Funktionalität des Geräts unterscheiden müsste. Was denkt ihr?
Hallo zusammen!
Dieses Thema ist nun in Entwicklung .
Ein Pull Request wurde eröffnet, um die Dashboards und Szenen aufzulisten, die jedes Gerät verwenden:
master ← claude/devices-usage-list
ouvert 02:54AM - 17 Aug 26 UTC
Implements feature request: https://community.gladysassistant.com/t/dans-la-page… -appareils-lister-les-dashboard-et-scene-utilisant-un-appareil/10579
### Description
On the new "Devices" page, it is now possible to see at a glance where each device is used: which dashboards display it, and which scenes reference it. This makes it easy to know what will break before deleting a device, and to spot devices that are not used anywhere.
**Open question raised in the forum topic (device-level vs per-feature usage):** this PR implements **device-level** usage. A device is considered "used" as soon as the device itself **or any of its features** is referenced by a dashboard or a scene. This keeps the list readable (one short cell per device) and answers the two use cases from the topic — "what will break if I delete this device" and "which devices are used nowhere". Per-feature granularity would fit better in a device detail view and is left out of scope.
**Server**
- New `device.getUsage(userId)` (`server/lib/device/device.getUsage.js`). It walks the dashboard `boxes` JSON and the scene `actions` / `triggers` JSON and collects every `device`, `devices`, `camera`, `device_feature` and `device_features` selector. The walk is recursive, so nested scene action blocks (`if` / `then` / `else`) are covered too. Collected feature selectors are resolved to their device.
- Exposed as a single endpoint `GET /api/v1/device/usage`, which returns the usage of **every** device in one call — the list never does one request per device. The response is an object indexed by device selector; a device missing from the response is used nowhere:
```json
{
"test-device": {
"dashboards": [{ "id": "...", "name": "Main", "selector": "main", "type": "main" }],
"scenes": [{ "id": "...", "name": "Good morning", "selector": "good-morning", "icon": "fe fe-bell" }]
}
}
```
- Dashboards are scoped exactly like `dashboard.get`: a user sees his own dashboards and the public ones. Scenes are global, as everywhere else.
**Front**
- New "Used in" column on the Devices page, listing the dashboards and the scenes as links (to `/dashboard/:selector` and `/dashboard/scene/:selector`), or "Nowhere" when the device is unused. Above 3 entries the rest is collapsed into a `+N` counter.
- New filter next to the room and integration filters: all devices / used in a dashboard or a scene / used nowhere.
- The usage is also shown on the mobile list (as plain tags, since the whole mobile row is already a link).
- New translation keys added to `en`, `fr` and `de`.
**Tests**
- `server/test/lib/device/device.getUsage.test.js`: no usage, dashboard usage (through a feature, through a direct device selector and through a camera selector), scene usage in actions (including nested `if/then/else`) and in triggers, merge of dashboards and scenes for the same device, and the dashboard visibility rule (another user's private dashboard is hidden, his public one is returned).
- `server/test/controllers/device/device.controller.test.js`: a test for the new `GET /api/v1/device/usage` route.
This pull request was produced by an automated run.
## Forum
Forum: https://community.gladysassistant.com/t/dans-la-page-appareils-lister-les-dashboard-et-scene-utilisant-un-appareil/10579
### Checklist
- [x] Tests pass: `cd server && npm run coverage` (Codecov requires 100% coverage on changed lines) and Cypress (`npm run cypress:run`) if the UI changed
- [x] Linter and prettier pass on both front and server (`npm run eslint`, `npm run prettier`)
- [x] No undocumented breaking change
---
_Generated by [Claude Code](https://claude.ai/code/session_01REGRUvErzpwtSrsi9gKh4J)_
## Summary by CodeRabbit
* **New Features**
* Added device usage information showing where devices are used in dashboards and scenes.
* Added “all,” “used,” and “not used” filters to the device list.
* Added usage details to desktop and mobile device views, including additional-use counts.
* Added localized English, German, and French labels and error messages.
* **Bug Fixes**
* Added clear error handling when device usage cannot be loaded.
* Usage filters remain unavailable until usage information finishes loading.
Zögert nicht, den Pull Request zu verfolgen, so früh wie möglich zu testen und euer Feedback hier zu hinterlassen.