Skip to content

[bug] MatterThermostat: invalid initial heating setpoint (0.2°C) and setpoint clamped against absolute limits only #189

Description

@lboue

Hardware

N/A - static code review finding, reproducible by inspection on any Matter-capable board (e.g. Arduino Nano Matter)

Core version

main / 4.0.0

Arduino IDE version

N/A

Operating system

N/A

Radio stack variant

Matter

OpenThread Border Router device (if using Matter)

N/A

Issue description

DeviceThermostat is constructed with raw local temperature/heating setpoint
values of 20 (MatterThermostat.cpp:93), which is 0.2°C - below both
abs_min_heating_setpoint (700 = 7°C) and min_heating_setpoint
(1600 = 16°C) initialized right below in the same constructor
(DeviceThermostat.cpp:36-39). This mirrors a bug just fixed for
MatterWaterHeater in PR #181 - the intended value was very likely
2000 (20°C), not 20 (0.2°C).

Separately, DeviceThermostat::SetHeatingSetpointValue()
(DeviceThermostat.cpp:66) only clamps against abs_min_heating_setpoint/
abs_max_heating_setpoint, ignoring the writable
min_heating_setpoint/max_heating_setpoint limits, and computes the
changed flag before clamping, which can fire a spurious attribute
report when an out-of-range write clamps back to the current value.

Suggested fix (same pattern applied to MatterWaterHeater in PR #181):

  • Use a valid initial heating setpoint (e.g. within [min_heating_setpoint, max_heating_setpoint])
  • Clamp against min_heating_setpoint/max_heating_setpoint instead of the absolute limits
  • Compute changed after clamping

Serial output

No response

RTT output (if using Matter)

No response

Minimal reproducer code

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions