Skip to content

Commit

Permalink
Thermostat cluster override (#1417)
Browse files Browse the repository at this point in the history
* Add FieldValue.None

* Add Thermostat override

* Regen model

* Changelog
  • Loading branch information
Apollon77 authored Nov 22, 2024
1 parent 2078d66 commit e3f909a
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ The main work (all changes without a GitHub username in brackets in the below li

- @matter/nodejs
- Feature: New export @matter/nodejs/config allows for fine-grained configuration of Node.js bootstrap logic
- Fix: Restores backward compatibility to sync storages from matter.js <0.11 in case ideas used special characters (uncommon)

- @matter/create
- Feature: Added command line option "--verbose" to enable informational NPM messages during initialization
Expand All @@ -28,7 +29,10 @@ The main work (all changes without a GitHub username in brackets in the below li
- Multi-project test runs now use a single process to improve performance

- Matter cluster definitions and implementations
- Enhancement: Removes default value from attribute ControlSequenceOfOperation of Thermostat cluster because feature specific enum value was used
- Fix: Reverts MoveToLevel workaround from 0.11.4
- Fix: ColorControl: Round calculated Kelvin values when calculated from Mireds
- Fix: GeneralDiagnostics: Network interface names are now correctly shortened to 32 characters

- matter.js git repository
- Feature: We've added project configuration for VS code including recommended extensions, code snippets and launch configurations
Expand Down
7 changes: 7 additions & 0 deletions models/src/local/ThermostatOverrides.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { FieldValue } from "@matter/model";
import { LocalMatter } from "../local.js";

LocalMatter.children.push({
Expand All @@ -19,5 +20,11 @@ LocalMatter.children.push({
name: "OccupancyBitmap",
type: "OccupancySensing.OccupancyBitmap",
},
{
tag: "attribute",
id: 0x1b,
name: "ControlSequenceOfOperation",
default: FieldValue.None,
},
],
});
25 changes: 23 additions & 2 deletions packages/model/src/common/FieldValue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ export type FieldValue =
| FieldValue.Reference
| FieldValue.Percent
| FieldValue.Celsius
| FieldValue.Bytes;
| FieldValue.Bytes
| FieldValue.None;

export namespace FieldValue {
// Typing with constants should be just as type safe as using an enum but simplifies type definitions
Expand All @@ -43,10 +44,13 @@ export namespace FieldValue {
export const bytes = "bytes";
export type bytes = typeof bytes;

export const none = "none";
export type none = typeof none;

/**
* If a field value isn't a primitive type, it's an object with a type field indicating one of these types.
*/
export type Type = percent | celsius | reference | properties | bytes;
export type Type = percent | celsius | reference | properties | bytes | none;

/**
* Test for one of the special placeholder types.
Expand All @@ -62,6 +66,17 @@ export namespace FieldValue {
export const Invalid: unique symbol = Symbol("invalid");
export type Invalid = typeof Invalid;

/**
* Flag for an "Undefined"/No value. Can be used in overrides to reset fields
*/
export type None = {
type: none;
};

export const None: None = {
type: none,
};

/**
* Reference to a named field
*/
Expand Down Expand Up @@ -125,6 +140,9 @@ export namespace FieldValue {
if (value === null) {
return "null";
}
if (is(value, none)) {
return "";
}
if (is(value, reference)) {
return (value as Reference).name;
}
Expand Down Expand Up @@ -204,6 +222,9 @@ export namespace FieldValue {
// This needs to be handled at a higher level
return;

case "none":
return; // undefined

case "percent":
case "celsius":
return numericValue(value, typeName);
Expand Down
2 changes: 1 addition & 1 deletion packages/model/src/standard/elements/Thermostat.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 1 addition & 5 deletions packages/types/src/clusters/thermostat.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e3f909a

Please sign in to comment.