Move name config to be per device for easier management of the config#6
Conversation
…uration file for many devices
There was a problem hiding this comment.
Pull request overview
This pull request updates the card configuration schema to make device name overrides live alongside each device’s coordinates, improving manageability for large device lists (Solves #5).
Changes:
- Rename
device_coordinates→devicesand update rendering logic to use the new config key. - Move manual label overrides from
friendly_namesintodevices[ieee].nameand adjust label priority accordingly. - Update documentation/examples and the coordinate picker to emit the new
devices:YAML format.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| zigbee-floorplan-card.js | Switches config to devices and reads per-device name overrides for labels. |
| tools/coordinate-picker.html | Generates YAML with devices: instead of device_coordinates:. |
| README.md | Updates main docs and examples to the new devices + optional name format. |
| examples/configuration-example.yaml | Replaces device_coordinates with devices in examples. |
| examples/card-config-example.yaml | Updates example config to devices and demonstrates per-device name. |
| docs/QUICKSTART.md | Updates quickstart snippets to use devices. |
| docs/PROJECT-INFO.md | Updates config template to use devices (but still contains stale friendly_names content). |
| docs/MQTT-SETUP.md | Updates snippets to use devices (but still contains stale friendly_names override example). |
Comments suppressed due to low confidence (1)
docs/MQTT-SETUP.md:162
- This section says manual name overrides can be configured via
friendly_names, but the implementation no longer supportsfriendly_names. Update the example to usedevices: <ieeeAddr>: { x, y, name }(or remove the override section) to avoid misleading setup instructions.
### Manual Friendly Name Override
You can still override individual device names:
```yaml
type: custom:zigbee-floorplan-card
entity: sensor.zigbee2mqtt_networkmap
image: /local/floorplan.png
devices:
# ...
friendly_names:
"0x00124b005678efgh": "My Custom Name" # Override the Z2M name
</details>
---
💡 <a href="/TheLarsinator/zigbee-floorplan-card/new/main?filename=.github/instructions/*.instructions.md" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Add Copilot custom instructions</a> for smarter, more guided reviews. <a href="https://docs.github.com/en/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Learn how to get started</a>.
| @@ -32,13 +32,12 @@ class ZigbeeFloorplanCard extends HTMLElement { | |||
| this._config = { | |||
| entity: this._sanitizeString(config.entity), | |||
| image: this._sanitizeUrl(config.image), | |||
| device_coordinates: config.device_coordinates, | |||
| devices: config.devices, | |||
There was a problem hiding this comment.
setConfig now requires config.devices and will throw for existing configurations that still use the documented device_coordinates key from prior versions. To avoid a breaking change (or at least provide a smoother migration), consider accepting device_coordinates as a fallback/alias (and/or emitting a clear deprecation warning) before throwing an error.
There was a problem hiding this comment.
I can live with that. I will bump the mayor version.
| show_link_lqi: false # Show LQI numbers on connections (default: false) | ||
| mqtt_base_topic: zigbee2mqtt | ||
| friendly_names: # Optional overrides | ||
| '0xbc026efffe29c7de': 'Main Coordinator' | ||
| device_coordinates: | ||
| devices: |
There was a problem hiding this comment.
This documentation example still uses friendly_names, but the card code no longer reads friendly_names from config. Update this section to demonstrate per-device overrides via the name field under devices (or remove the friendly_names block) so users don't configure an option that has no effect.
| this._config = { | ||
| entity: this._sanitizeString(config.entity), | ||
| image: this._sanitizeUrl(config.image), | ||
| device_coordinates: config.device_coordinates, | ||
| devices: config.devices, | ||
| image_width: imageWidth, | ||
| image_height: imageHeight, | ||
| circle_radius: circleRadius, | ||
| show_labels: config.show_labels !== false, | ||
| show_link_lqi: config.show_link_lqi === true, | ||
| friendly_names: config.friendly_names || {}, | ||
| mqtt_base_topic: this._sanitizeString(config.mqtt_base_topic || 'zigbee2mqtt') | ||
| }; |
There was a problem hiding this comment.
This change removes friendly_names support entirely (it is no longer stored on _config and getDeviceLabel no longer checks it). That’s a breaking config change for existing users; consider supporting friendly_names as a deprecated fallback by mapping entries into devices[ieee].name (or, at minimum, detect friendly_names and surface a targeted migration error/warning).
There was a problem hiding this comment.
I can live with that. I will bump the mayor version.
Solves #5