Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RvcOperationalState does not accept derived enum values #1612

Open
t0bst4r opened this issue Jan 6, 2025 · 0 comments
Open

RvcOperationalState does not accept derived enum values #1612

t0bst4r opened this issue Jan 6, 2025 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@t0bst4r
Copy link
Contributor

t0bst4r commented Jan 6, 2025

I am currently implementing vacuum devices with RvcOperationalStateServer. Following the Matter specification,
attribute operationalState should accept all values from OperationalState and in addition all values from
RvcOperationalState:

Value Name Summary Conformance
0x00 Stopped The device is stopped M
0x01 Running The device is operating M
0x02 Paused The device is paused during an operation M
0x03 Error The device is in an error state M
0x40 SeekingCharger The device is en route to the charging dock M
0x41 Charging The device is charging M
0x42 Docked The device is on the dock, not charging M

Unfortunately, matter.js does only accept the rvc specific values (0x40, 0x41, 0x42).
First, the enum only includes those three values and does not derive the other values.
Second, if I just use number as type and pass in 0x02, it fails initializing the behavior / setting the value.

SAME thing happens for operationalError.errorStateId, and probably even more.

I tried with 0.11.9 and 0.12.0-alpha.0-20250103-ba0c01a01.


Minimal repro:

import { RvcOperationalStateServer as Base } from "@matter/main/behaviors/rvc-operational-state";
import { RvcOperationalState } from "@matter/main/clusters/rvc-operational-state";

export class RvcOperationalStateServer extends Base {
  override async initialize() {
    await super.initialize();

    // just 0x02 without typecast will produce a type error, since it's not in the enum
    this.state.operationalState = 0x02 as number; // or as RvcOperationalState.OperationalState
  }
}

Log output

Validating 4b34da8cb2bd4315bba08fee27e02ca6.aggregator.vacuum_roborock_s7_pro_ultra.rvcOperationalState.state: Value "2" is not defined in enum (135)
  at <anonymous> (/Users/t0bst4r/Projects/t0bst4r/home-assistant-matter-hub/node_modules/@matter/node/src/behavior/state/validation/ValueValidator.ts:141:19)
  at <anonymous> (/Users/t0bst4r/Projects/t0bst4r/home-assistant-matter-hub/node_modules/@matter/node/src/behavior/state/validation/conformance.ts:32:13)
  at <anonymous> (/Users/t0bst4r/Projects/t0bst4r/home-assistant-matter-hub/node_modules/@matter/node/src/behavior/state/managed/values/StructManager.ts:230:25)
  at Object.change (/Users/t0bst4r/Projects/t0bst4r/home-assistant-matter-hub/node_modules/@matter/node/src/behavior/state/managed/Datasource.ts:378:13)
  at RvcOperationalState$State.set (/Users/t0bst4r/Projects/t0bst4r/home-assistant-matter-hub/node_modules/@matter/node/src/behavior/state/managed/values/StructManager.ts:182:38)
  at Function.assign (<anonymous>)
  at applyPatchState (/Users/t0bst4r/Projects/t0bst4r/home-assistant-matter-hub/packages/backend/src/utils/apply-patch-state.ts:20:14)
  at RvcOperationalStateServer.update (/Users/t0bst4r/Projects/t0bst4r/home-assistant-matter-hub/packages/backend/src/matter/behaviors/rvc-operational-state-server.ts:20:5)
  at RvcOperationalStateServer.initialize (/Users/t0bst4r/Projects/t0bst4r/home-assistant-matter-hub/packages/backend/src/matter/behaviors/rvc-operational-state-server.ts:14:10)

a bit off topic

When using 0.12.0-alpha.0-20250103-ba0c01a01, the log output does not include the error details anymore.

[ 2025-01-06T10:44:46.038Z ] [ ERROR ] [ Bridge / 4b34da8cb2bd4315bba08fee27e02ca6          ]: Failed to start bridge due to error: EndpointBehaviorsError [AggregateError]: Behaviors have errors
    at <anonymous> (/Users/t0bst4r/Projects/t0bst4r/home-assistant-matter-hub/node_modules/@matter/node/src/endpoint/properties/Behaviors.ts:173:27)
    at all (/Users/t0bst4r/Projects/t0bst4r/home-assistant-matter-hub/node_modules/@matter/general/src/util/Construction.ts:705:25)
    at <anonymous> (/Users/t0bst4r/Projects/t0bst4r/home-assistant-matter-hub/node_modules/@matter/general/src/util/Construction.ts:695:17) {
  [errors]: [Array]
}

I added a try catch and logged the error by myself to validate it's the SAME error message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants