Skip to content

Commit a23c08a

Browse files
authored
Add resolution to complex field schema (#418)
1 parent 9e5cf94 commit a23c08a

3 files changed

Lines changed: 6 additions & 1 deletion

File tree

src/components/knx-payload-selector.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,12 +297,13 @@ export class KnxPayloadSelector extends LitElement {
297297

298298
private _fieldToKnxHaSelector(field: DPTComplexFieldSchema): KnxHaSelector {
299299
if (field.type === "integer" || field.type === "float") {
300+
const step = field.resolution ?? (field.type === "float" ? 0.01 : 1);
300301
return this._knxHaSelector(field, {
301302
number: {
302303
mode: "box",
303304
min: field.value_min,
304305
max: field.value_max,
305-
step: field.type === "float" ? 0.01 : 1,
306+
step,
306307
},
307308
});
308309
}

src/types/websocket.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export interface DPTComplexFieldSchema {
2424
options?: string[];
2525
value_min?: number;
2626
value_max?: number;
27+
resolution?: number;
2728
}
2829

2930
export interface DPTMetadata {

src/views/dpt_reference.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,9 @@ export class KnxDptReference extends LitElement {
145145
if (field.value_max != null) {
146146
details.push(`max: ${field.value_max}`);
147147
}
148+
if (field.resolution != null) {
149+
details.push(`resolution: ${field.resolution}`);
150+
}
148151
if (field.options?.length) {
149152
const pythonList = `[${field.options.map((opt) => this._pythonRepr(opt)).join(", ")}]`;
150153
details.push(html`options: <code>${pythonList}</code>`);

0 commit comments

Comments
 (0)