Some quality-of-life fixes for the HomeKit plugin (#448)

* homekit: don't add fan services to devices without fan interfaces

* homekit: set minimum step for fan based on maxSpeed

* homekit: disable 'auto' mode if not supported by thermostat
This commit is contained in:
Fiach Antaw
2022-12-02 14:23:46 +10:00
committed by GitHub
parent 5f0c9dc94e
commit 4cbbf64495
2 changed files with 12 additions and 0 deletions

View File

@@ -69,6 +69,9 @@ export function addCarbonDioxideSensor(device: ScryptedDevice & CO2Sensor, acces
}
export function addFan(device: ScryptedDevice & Fan & OnOff, accessory: Accessory): Service {
if (!device.interfaces.includes(ScryptedInterface.OnOff) && !device.interfaces.includes(ScryptedInterface.Fan))
return undefined;
const service = accessory.addService(Service.Fanv2, device.name);
if (device.interfaces.includes(ScryptedInterface.OnOff)) {
@@ -128,6 +131,9 @@ export function addFan(device: ScryptedDevice & Fan & OnOff, accessory: Accessor
speed,
});
});
service.getCharacteristic(Characteristic.RotationSpeed).setProps({
minStep: 100 / device.fan?.maxSpeed,
});
}
if (device.fan?.availableModes !== undefined) {

View File

@@ -96,6 +96,12 @@ addSupportedType({
bindCharacteristic(device, ScryptedInterface.TemperatureSetting, service, Characteristic.TargetHeatingCoolingState,
() => toTargetMode(device.thermostatMode));
if (!device.thermostatAvailableModes.includes(ThermostatMode.Auto)) {
service.getCharacteristic(Characteristic.TargetHeatingCoolingState).setProps({
maxValue: Characteristic.TargetHeatingCoolingState.COOL // Disable 'Auto' mode
});
}
service.getCharacteristic(Characteristic.TargetTemperature)
.on(CharacteristicEventTypes.SET, (value: CharacteristicValue, callback: CharacteristicSetCallback) => {