Add DPT dialog-selector for classes of DPTs#290
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #290 +/- ##
==========================================
+ Coverage 27.89% 30.81% +2.92%
==========================================
Files 19 20 +1
Lines 760 795 +35
Branches 188 204 +16
==========================================
+ Hits 212 245 +33
- Misses 548 550 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR introduces DPT (Datapoint Type) class-based selection via a new dialog interface, enabling users to select from groups of DPTs organized by their semantic class (numeric, enum, complex, string). This functionality is required for sensor entity creation in the related Home Assistant core PR #158498.
Key Changes
- Added
DPTMetadatatype to track DPT classification and properties from the backend - Implemented
knx-dpt-select-dialogcomponent with searchable, grouped DPT selection - Created
knx-dpt-dialog-selectorcomponent to integrate the dialog into entity creation flows - Extended schema and selector logic to support
dptClassesfiltering alongside existingdptSelectandvalidDPTsoptions
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
src/types/websocket.ts |
Added DPTMetadata interface with DPT classification fields and integration metadata |
src/types/schema.ts |
Extended GASelectorOptions with dptClasses field for class-based filtering |
src/types/knx.ts |
Added dptMetadata field to KNX interface for metadata access |
src/knx.ts |
Initialized dptMetadata from backend data in KNX object |
src/utils/dpt.ts |
Updated validDPTsForSchema to accept and process dptMetadata for class filtering |
src/views/entities_create.ts |
Passed dptMetadata to validDPTsForSchema call for project tree filtering |
src/dialogs/knx-dpt-select-dialog.ts |
New dialog component with search, grouping, and selection UI for DPTs |
src/dialogs/show-knx-dpt-select-dialog.ts |
Dialog helper function following Home Assistant patterns |
src/components/knx-dpt-option-selector.ts |
Renamed from knx-dpt-selector for clarity with new dialog selector |
src/components/knx-dpt-dialog-selector.ts |
New selector component that opens DPT selection dialog |
src/components/knx-group-address-selector.ts |
Integrated both option and dialog selectors, added class-based DPT filtering logic |
eslint.config.mjs |
Added TypeScript project configuration for enhanced type checking |
| <ha-icon-button | ||
| class="menu-button" | ||
| .path=${mdiMenuOpen} | ||
| @click=${this._openDialog} | ||
| .label=${this.hass.localize("component.knx.selector.dpt.fields.label")} | ||
| ></ha-icon-button> | ||
|
|
||
| ${this.value | ||
| ? html`<div class="selected"> | ||
| <div class="dpt-number">${this.value}</div> | ||
| <div class="dpt-name">${this.knx.dptMetadata[this.value]?.name}</div> | ||
| <div class="dpt-unit">${this.knx.dptMetadata[this.value]?.unit ?? ""}</div> | ||
| </div> | ||
| <ha-icon-button | ||
| class="clear-button" | ||
| .path=${mdiClose} | ||
| .label=${this.hass.localize ? this.hass.localize("ui.common.clear") : "Clear"} | ||
| @click=${this._clearSelection} |
There was a problem hiding this comment.
The disabled property is declared but never used in the component. The menu button and clear button should respect this property to prevent user interaction when the selector is disabled.
This is needed for sensor entity creation home-assistant/core#158498
cc @Abestanis