Skip to content

feat(matter): add SBMD thermostat driver with optional fan control#213

Draft
tleacmcsa wants to merge 2 commits intomainfrom
tlea/dev/matter-thermostat
Draft

feat(matter): add SBMD thermostat driver with optional fan control#213
tleacmcsa wants to merge 2 commits intomainfrom
tlea/dev/matter-thermostat

Conversation

@tleacmcsa
Copy link
Copy Markdown
Contributor

Add Matter Thermostat device type (0x0301) support via SBMD spec with:

  • Thermostat cluster (0x0201) read/write mappers for temperature setpoints, system mode, and control sequence
  • Optional Fan Control cluster (0x0202) resources (fanMode, fanOn) gated by prerequisite presence checks
  • Fix readableAttributeLookup to use unordered_multimap so multiple resources can read from the same cluster attribute

Testing:

  • ThermostatDevice.js virtual device with side-band operations
  • ThermostatWithFanDevice.js subclass adding Fan Control cluster
  • Python fixtures (MatterThermostat, MatterThermostatWithFan)
  • Integration tests for commission, read, write, and sideband updates
  • Fan-specific tests for fanMode and fanOn resource reads

Refs: BARTON-376

Add Matter Thermostat device type (0x0301) support via SBMD spec with:
- Thermostat cluster (0x0201) read/write mappers for temperature
  setpoints, system mode, and control sequence
- Optional Fan Control cluster (0x0202) resources (fanMode, fanOn)
  gated by prerequisite presence checks
- Fix readableAttributeLookup to use unordered_multimap so multiple
  resources can read from the same cluster attribute

Testing:
- ThermostatDevice.js virtual device with side-band operations
- ThermostatWithFanDevice.js subclass adding Fan Control cluster
- Python fixtures (MatterThermostat, MatterThermostatWithFan)
- Integration tests for commission, read, write, and sideband updates
- Fan-specific tests for fanMode and fanOn resource reads

Refs: BARTON-376
@tleacmcsa
Copy link
Copy Markdown
Contributor Author

@copilot review this PR

- Move null-cache guard before the loop in OnAttributeChanged; use
  continue instead of return on per-binding cache Get failure so a
  single miss does not abort remaining bindings
- Remove dead `var schema` from heatSetpoint write script
- Add null-value guards to setpoint-limit and controlSequenceOfOperation
  read scripts, matching the pattern used in localTemperature/setpoint
  scripts
- Pass matterjs_entry_point through MatterThermostat.__init__ so
  MatterThermostatWithFan can pass it cleanly rather than patching
  internal state after construction

Agent-Logs-Url: https://github.com/rdkcentral/BartonCore/sessions/e0e8d2c0-6174-418d-8b19-4d934b4087fe

Co-authored-by: tleacmcsa <35579828+tleacmcsa@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 27, 2026

@copilot review this PR

Review complete. Four issues were found and fixed in 86c2e9b:

MatterDevice.cppOnAttributeChanged

  • The cache == nullptr guard was inside the per-binding loop and caused an early return (aborting all remaining bindings) even when only one binding's Get() failed. The null-cache check is now lifted before the loop, and the per-binding Get() failure uses continue so the other bindings still run.

thermostat.sbmd — dead code

  • var schema = { value: {tag: null, type: 'int16'} }; in the heatSetpoint write script was defined but never referenced. Removed.

thermostat.sbmd — missing null guards

  • The read scripts for absoluteMinHeatLimit, absoluteMaxHeatLimit, absoluteMinCoolLimit, absoluteMaxCoolLimit, and controlSequenceOfOperation called value.toString() without first checking for null (unlike localTemperature, heatSetpoint, and coolSetpoint which all guard). Null checks added to match the existing pattern.

matter_thermostat.py / matter_thermostat_with_fan.py — fragile internal-state override

  • MatterThermostatWithFan was assigning self._matterjs_entry_point directly after super().__init__(), reaching into internal state. Added a matterjs_entry_point parameter to MatterThermostat.__init__ so the subclass can pass "ThermostatWithFanDevice.js" cleanly via the constructor chain.

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