Skip to content

Add DPT dialog-selector for classes of DPTs#290

Merged
farmio merged 13 commits into
mainfrom
entity-sensor
Dec 19, 2025
Merged

Add DPT dialog-selector for classes of DPTs#290
farmio merged 13 commits into
mainfrom
entity-sensor

Conversation

@farmio
Copy link
Copy Markdown
Member

@farmio farmio commented Dec 9, 2025

This is needed for sensor entity creation home-assistant/core#158498
cc @Abestanis

@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 9, 2025

Codecov Report

❌ Patch coverage is 73.80952% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 30.81%. Comparing base (08384ef) to head (9b6cac5).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/utils/dpt.ts 81.57% 7 Missing ⚠️
src/dialogs/show-knx-dpt-select-dialog.ts 0.00% 4 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@farmio farmio marked this pull request as ready for review December 9, 2025 22:25
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 DPTMetadata type to track DPT classification and properties from the backend
  • Implemented knx-dpt-select-dialog component with searchable, grouped DPT selection
  • Created knx-dpt-dialog-selector component to integrate the dialog into entity creation flows
  • Extended schema and selector logic to support dptClasses filtering alongside existing dptSelect and validDPTs options

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

Comment thread src/components/knx-dpt-dialog-selector.ts Outdated
Comment thread src/components/knx-dpt-dialog-selector.ts Outdated
Comment thread src/dialogs/knx-dpt-select-dialog.ts Outdated
Comment thread src/dialogs/knx-dpt-select-dialog.ts Outdated
Comment thread src/dialogs/knx-dpt-select-dialog.ts
Comment thread src/components/knx-dpt-dialog-selector.ts
Comment thread src/components/knx-dpt-dialog-selector.ts Outdated
Comment thread src/dialogs/knx-dpt-select-dialog.ts Outdated
Comment thread src/components/knx-group-address-selector.ts Outdated
Comment thread src/dialogs/knx-dpt-select-dialog.ts Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 17 out of 17 changed files in this pull request and generated 3 comments.

Comment thread src/components/knx-group-address-selector.ts Outdated
Comment thread src/dialogs/knx-dpt-select-dialog.ts Outdated
Comment on lines +41 to +58
<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}
Copy link

Copilot AI Dec 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
@farmio farmio merged commit f2a964c into main Dec 19, 2025
6 checks passed
@farmio farmio deleted the entity-sensor branch December 19, 2025 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants