Thermostat HeatingCoolingState with `validValues: [OFF, COOL]` causes "No Response"
Analysis
I was investigating this bug in my plugin. The user is seeing odd behavior when setting validValues to COOL and OFF for Thermostat service.
In the Home app, clicking on the temperature immediately causes the accessory to become unresponsive.
https://github.com/user-attachments/assets/81764493-f547-4a09-a69a-c39fc16a3ce9
Expected Behavior
This ONLY happens when validValues are COOL and OFF. If, for example, you set the values to HEAT and OFF, then the accessory behaves as expected.
https://github.com/user-attachments/assets/fd7f70b2-d36a-4802-8035-f023191995a5
Steps To Reproduce
I have forked homebridge-plugin-template and made the minimal set of changes necessary to demonstrate the issue in the videos above.
https://github.com/mpatfield/homebridge-thermostat-bug
The relevant code is in platformAccessory.ts
const validValues = [
platform.Characteristic.CurrentHeatingCoolingState.OFF,
platform.Characteristic.CurrentHeatingCoolingState.COOL, // !!! Broken with COOL but works with HEAT !!!
];
service.getCharacteristic(platform.Characteristic.CurrentHeatingCoolingState)
.onGet(async () => state)
.setProps({ validValues });
service.getCharacteristic(platform.Characteristic.TargetHeatingCoolingState)
.onGet(async () => state)
.onSet(async (value) => {
platform.log.info('Called TargetHeatingCoolingState.onSet()');
state = value;
service.getCharacteristic(platform.Characteristic.CurrentHeatingCoolingState).updateValue(value);
})
.setProps({ validValues });
Logs
There is nothing of note in the logs.
If you run the code, you'll notice that `TargetHeatingCoolingState.onSet()` is not called when the values are COOL/OFF but it is called when values are HEAT/OFF
Configuration
N/A
Environment
Likely environment-agnostic, as I can reproduce this on various setups including RPi and MacOS on Homebridge v1 and v2.
Process Supervisor
hb-service
Additional Context
There's a chance that this is an even deeper issue than Homebridge, but I'm working my way down the rabbit hole.
Source: homebridge/homebridge