mirror of
https://github.com/koush/scrypted.git
synced 2026-09-18 01:30:39 +01:00
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:
@@ -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) {
|
||||
|
||||
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user