From 65728967eacd87a44247249dddc7895772fe8fdc Mon Sep 17 00:00:00 2001 From: Nick Berardi Date: Mon, 3 Oct 2022 14:13:23 -0400 Subject: [PATCH] updated the sensor bindings (#392) --- plugins/homekit/src/types/sensor.ts | 6 +++--- plugins/homekit/src/types/thermostat.ts | 12 ++++++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/plugins/homekit/src/types/sensor.ts b/plugins/homekit/src/types/sensor.ts index f6cd4e77b..1645cb72c 100644 --- a/plugins/homekit/src/types/sensor.ts +++ b/plugins/homekit/src/types/sensor.ts @@ -1,4 +1,4 @@ -import { AmbientLightSensor, AudioSensor, BinarySensor, FloodSensor, HumiditySensor, MotionSensor, OccupancySensor, PM25Sensor, AirQualitySensor, ScryptedDevice, ScryptedDeviceType, ScryptedInterface, Thermometer, VOCSensor, AirQuality, EntrySensor, TamperSensor, CO2Sensor } from '@scrypted/sdk'; +import { AmbientLightSensor, AudioSensor, BinarySensor, FloodSensor, HumiditySensor, MotionSensor, OccupancySensor, PM10Sensor, PM25Sensor, AirQualitySensor, ScryptedDevice, ScryptedDeviceType, ScryptedInterface, Thermometer, VOCSensor, NOXSensor, AirQuality, EntrySensor, TamperSensor, CO2Sensor } from '@scrypted/sdk'; import { addSupportedType, bindCharacteristic, DummyDevice, } from '../common'; import { Characteristic, Service } from '../hap'; import { makeAccessory } from './common'; @@ -110,7 +110,7 @@ addSupportedType({ () => airQualityToHomekit(device.airQuality)); if (device.interfaces.includes(ScryptedInterface.PM10Sensor)) { - bindCharacteristic(device, ScryptedInterface.PM10Sensor, service, Characteristic.PM2_5Density, + bindCharacteristic(device, ScryptedInterface.PM10Sensor, service, Characteristic.PM10Density, () => device.pm10Density || 0); } if (device.interfaces.includes(ScryptedInterface.PM25Sensor)) { @@ -122,7 +122,7 @@ addSupportedType({ () => device.vocDensity || 0); } if (device.interfaces.includes(ScryptedInterface.NOXSensor)) { - bindCharacteristic(device, ScryptedInterface.NOXSensor, service, Characteristic.PM2_5Density, + bindCharacteristic(device, ScryptedInterface.NOXSensor, service, Characteristic.NitrogenDioxideDensity, () => device.noxDensity || 0); } } diff --git a/plugins/homekit/src/types/thermostat.ts b/plugins/homekit/src/types/thermostat.ts index 348a8f3aa..f2aa267e9 100644 --- a/plugins/homekit/src/types/thermostat.ts +++ b/plugins/homekit/src/types/thermostat.ts @@ -1,4 +1,4 @@ -import { Fan, FanMode, HumidityMode, HumiditySensor, HumiditySetting, OnOff, ScryptedDevice, ScryptedDeviceType, ScryptedInterface, TemperatureSetting, TemperatureUnit, Thermometer, ThermostatMode, AirQualitySensor, AirQuality, PM25Sensor, VOCSensor, CO2Sensor } from '@scrypted/sdk'; +import { Fan, FanMode, HumidityMode, HumiditySensor, HumiditySetting, OnOff, ScryptedDevice, ScryptedDeviceType, ScryptedInterface, TemperatureSetting, TemperatureUnit, Thermometer, ThermostatMode, AirQualitySensor, AirQuality, PM10Sensor, PM25Sensor, VOCSensor, NOXSensor, CO2Sensor } from '@scrypted/sdk'; import { addSupportedType, bindCharacteristic, DummyDevice, } from '../common'; import { Characteristic, CharacteristicEventTypes, CharacteristicSetCallback, CharacteristicValue, Service } from '../hap'; import { makeAccessory } from './common'; @@ -11,7 +11,7 @@ addSupportedType({ return false; return true; }, - getAccessory: async (device: ScryptedDevice & TemperatureSetting & Thermometer & HumiditySensor & OnOff & Fan & HumiditySetting & AirQualitySensor & PM25Sensor & VOCSensor & CO2Sensor, homekitPlugin: HomeKitPlugin) => { + getAccessory: async (device: ScryptedDevice & TemperatureSetting & Thermometer & HumiditySensor & OnOff & Fan & HumiditySetting & AirQualitySensor & PM10Sensor & PM25Sensor & VOCSensor & NOXSensor & CO2Sensor, homekitPlugin: HomeKitPlugin) => { const accessory = makeAccessory(device, homekitPlugin); const service = accessory.addService(Service.Thermostat, device.name); service.setPrimaryService(); @@ -300,6 +300,10 @@ addSupportedType({ bindCharacteristic(device, ScryptedInterface.AirQualitySensor, airQualityService, Characteristic.AirQuality, () => airQualityToHomekit(device.airQuality)); + if (device.interfaces.includes(ScryptedInterface.PM10Sensor)) { + bindCharacteristic(device, ScryptedInterface.PM10Sensor, airQualityService, Characteristic.PM10Density, + () => device.pm10Density || 0); + } if (device.interfaces.includes(ScryptedInterface.PM25Sensor)) { bindCharacteristic(device, ScryptedInterface.PM25Sensor, airQualityService, Characteristic.PM2_5Density, () => device.pm25Density || 0); @@ -308,6 +312,10 @@ addSupportedType({ bindCharacteristic(device, ScryptedInterface.VOCSensor, airQualityService, Characteristic.VOCDensity, () => device.vocDensity || 0); } + if (device.interfaces.includes(ScryptedInterface.NOXSensor)) { + bindCharacteristic(device, ScryptedInterface.NOXSensor, airQualityService, Characteristic.NitrogenDioxideDensity, + () => device.noxDensity || 0); + } } if (device.interfaces.includes(ScryptedInterface.CO2Sensor)) {