mirror of
https://github.com/koush/scrypted.git
synced 2026-02-12 10:02:04 +00:00
homekit: fixup fan service on thermostat
This commit is contained in:
4
plugins/homekit/package-lock.json
generated
4
plugins/homekit/package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@scrypted/homekit",
|
||||
"version": "0.0.102",
|
||||
"version": "0.0.110",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@scrypted/homekit",
|
||||
"version": "0.0.102",
|
||||
"version": "0.0.110",
|
||||
"dependencies": {
|
||||
"hap-nodejs": "file:../../external/HAP-NodeJS",
|
||||
"lodash": "^4.17.21",
|
||||
|
||||
@@ -40,5 +40,5 @@
|
||||
"@types/qrcode": "^1.4.1",
|
||||
"@types/url-parse": "^1.4.3"
|
||||
},
|
||||
"version": "0.0.102"
|
||||
"version": "0.0.110"
|
||||
}
|
||||
|
||||
@@ -36,7 +36,6 @@ export function bindCharacteristic(device: ScryptedDevice, event: ScryptedInterf
|
||||
service.getCharacteristic(characteristic).on(CharacteristicEventTypes.GET, callback => {
|
||||
try {
|
||||
if (device.interfaces.includes(ScryptedInterface.Refresh)) {
|
||||
console.log('refreshing', device.name);
|
||||
(device as ScryptedDevice & Refresh).refresh(event, true);
|
||||
}
|
||||
callback(null, map());
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { ScryptedDevice } from "@scrypted/sdk";
|
||||
import { uuid, Accessory } from '../hap';
|
||||
|
||||
export function makeAccessory(device: ScryptedDevice): Accessory {
|
||||
return new Accessory(device.name, uuid.generate(device.id));
|
||||
export function makeAccessory(device: ScryptedDevice, suffix?: string): Accessory {
|
||||
return new Accessory(device.name, uuid.generate(device.id + (suffix ? '-' + suffix : '')));
|
||||
}
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
|
||||
import { HumiditySensor, OnOff, ScryptedDevice, ScryptedDeviceType, ScryptedInterface, ScryptedInterfaceProperty, TemperatureSetting, TemperatureUnit, Thermometer, ThermostatMode } from '@scrypted/sdk'
|
||||
import { access } from 'fs';
|
||||
import { Fanv2 } from 'hap-nodejs/dist/lib/definitions';
|
||||
import { HumiditySensor, OnOff, ScryptedDevice, ScryptedDeviceType, ScryptedInterface, TemperatureSetting, TemperatureUnit, Thermometer, ThermostatMode } from '@scrypted/sdk'
|
||||
import { Accessory } from 'hap-nodejs';
|
||||
import { addSupportedType, bindCharacteristic, DummyDevice } from '../common'
|
||||
import { Characteristic, CharacteristicEventTypes, CharacteristicSetCallback, CharacteristicValue, NodeCallback, Service } from '../hap';
|
||||
import { Characteristic, CharacteristicEventTypes, CharacteristicSetCallback, CharacteristicValue, Service } from '../hap';
|
||||
import { makeAccessory } from './common';
|
||||
|
||||
addSupportedType({
|
||||
@@ -66,7 +65,7 @@ addSupportedType({
|
||||
})
|
||||
|
||||
bindCharacteristic(device, ScryptedInterface.TemperatureSetting, service, Characteristic.TargetHeatingCoolingState,
|
||||
() => toTargetMode(device.thermostatActiveMode));
|
||||
() => toTargetMode(device.thermostatMode));
|
||||
|
||||
function getTargetTemperature() {
|
||||
return device.thermostatSetpoint ||
|
||||
@@ -96,11 +95,19 @@ addSupportedType({
|
||||
}
|
||||
|
||||
if (device.interfaces.includes(ScryptedInterface.OnOff)) {
|
||||
const fanService = accessory.addService(Fanv2);
|
||||
bindCharacteristic(device, ScryptedInterface.OnOff, fanService, Characteristic.Active,
|
||||
() => device.on ? Characteristic.Active.ACTIVE : Characteristic.Active.INACTIVE);
|
||||
const fanService = accessory.addService(Service.Fan);
|
||||
bindCharacteristic(device, ScryptedInterface.OnOff, fanService, Characteristic.On,
|
||||
() => !!device.on);
|
||||
|
||||
fanService.getCharacteristic(Characteristic.On).on(CharacteristicEventTypes.SET, (value, callback) => {
|
||||
callback();
|
||||
if (value)
|
||||
device.turnOn();
|
||||
else
|
||||
device.turnOff();
|
||||
});
|
||||
}
|
||||
|
||||
return accessory;
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user