Added NOXSensor and PM10Sensor for use (#384)

This commit is contained in:
Nick Berardi
2022-09-22 20:58:18 -04:00
committed by GitHub
parent 4ee4b757c8
commit b08d945dfc
8 changed files with 110 additions and 2 deletions

View File

@@ -33,6 +33,8 @@ aggregators.set(ScryptedInterface.LuminanceSensor, average);
aggregators.set(ScryptedInterface.UltravioletSensor, average);
aggregators.set(ScryptedInterface.CO2Sensor, average);
aggregators.set(ScryptedInterface.PM25Sensor, average);
aggregators.set(ScryptedInterface.PM10Sensor, average);
aggregators.set(ScryptedInterface.NOXSensor, average);
aggregators.set(ScryptedInterface.FloodSensor, allFalse);
aggregators.set(ScryptedInterface.Lock,
values => values.reduce((prev, cur) => cur === LockState.Unlocked ? cur : prev, LockState.Locked));

View File

@@ -31,8 +31,10 @@ const supportedSensors: string[] = [
ScryptedInterface.HumiditySensor,
ScryptedInterface.FloodSensor,
ScryptedInterface.AirQualitySensor,
ScryptedInterface.PM10Sensor,
ScryptedInterface.PM25Sensor,
ScryptedInterface.VOCSensor,
ScryptedInterface.NOXSensor,
ScryptedInterface.EntrySensor,
ScryptedInterface.CO2Sensor,
];
@@ -46,7 +48,7 @@ addSupportedType({
}
return false;
},
getAccessory: async (device: ScryptedDevice & OccupancySensor & AmbientLightSensor & AmbientLightSensor & AudioSensor & BinarySensor & MotionSensor & Thermometer & HumiditySensor & FloodSensor & AirQualitySensor & PM25Sensor & VOCSensor & EntrySensor & TamperSensor & CO2Sensor, homekitPlugin: HomeKitPlugin) => {
getAccessory: async (device: ScryptedDevice & OccupancySensor & AmbientLightSensor & AmbientLightSensor & AudioSensor & BinarySensor & MotionSensor & Thermometer & HumiditySensor & FloodSensor & AirQualitySensor & PM10Sensor & PM25Sensor & VOCSensor & NOXSensor & EntrySensor & TamperSensor & CO2Sensor, homekitPlugin: HomeKitPlugin) => {
const accessory = makeAccessory(device, homekitPlugin);
if (device.interfaces.includes(ScryptedInterface.EntrySensor)) {
@@ -106,7 +108,11 @@ addSupportedType({
const service = accessory.addService(Service.AirQualitySensor, device.name);
bindCharacteristic(device, ScryptedInterface.AirQualitySensor, service, Characteristic.AirQuality,
() => airQualityToHomekit(device.airQuality));
if (device.interfaces.includes(ScryptedInterface.PM10Sensor)) {
bindCharacteristic(device, ScryptedInterface.PM10Sensor, service, Characteristic.PM2_5Density,
() => device.pm10Density || 0);
}
if (device.interfaces.includes(ScryptedInterface.PM25Sensor)) {
bindCharacteristic(device, ScryptedInterface.PM25Sensor, service, Characteristic.PM2_5Density,
() => device.pm25Density || 0);
@@ -115,6 +121,10 @@ addSupportedType({
bindCharacteristic(device, ScryptedInterface.VOCSensor, service, Characteristic.VOCDensity,
() => device.vocDensity || 0);
}
if (device.interfaces.includes(ScryptedInterface.NOXSensor)) {
bindCharacteristic(device, ScryptedInterface.NOXSensor, service, Characteristic.PM2_5Density,
() => device.noxDensity || 0);
}
}

View File

@@ -960,12 +960,18 @@ export interface Position {
export interface PositionSensor {
position?: Position;
}
export interface PM10Sensor {
pm10Density?: number;
}
export interface PM25Sensor {
pm25Density?: number;
}
export interface VOCSensor {
vocDensity?: number;
}
export interface NOXSensor {
noxDensity?: number;
}
export interface CO2Sensor {
co2ppm?: number;
}
@@ -1583,8 +1589,10 @@ export enum ScryptedInterface {
LuminanceSensor = "LuminanceSensor",
PositionSensor = "PositionSensor",
SecuritySystem = 'SecuritySystem',
PM10Sensor = "PM10Sensor",
PM25Sensor = "PM25Sensor",
VOCSensor = "VOCSensor",
NOXSensor = "NOXSensor",
CO2Sensor = "CO2Sensor",
AirQualitySensor = "AirQualitySensor",
Readme = "Readme",

View File

@@ -106,12 +106,14 @@ class ScryptedInterface(Enum):
MixinProvider = "MixinProvider"
MotionSensor = "MotionSensor"
Notifier = "Notifier"
NOXSensor = "NOXSensor"
OauthClient = "OauthClient"
ObjectDetection = "ObjectDetection"
ObjectDetector = "ObjectDetector"
OccupancySensor = "OccupancySensor"
OnOff = "OnOff"
Online = "Online"
PM10Sensor = "PM10Sensor"
PM25Sensor = "PM25Sensor"
PanTiltZoom = "PanTiltZoom"
PasswordStore = "PasswordStore"
@@ -804,6 +806,10 @@ class Notifier:
pass
pass
class NOXSensor:
noxDensity: float
pass
class OauthClient:
async def getOauthUrl(self) -> str:
pass
@@ -841,6 +847,10 @@ class Online:
online: bool
pass
class PM10Sensor:
pm10Density: float
pass
class PM25Sensor:
pm25Density: float
pass
@@ -2090,6 +2100,13 @@ ScryptedInterfaceDescriptors = {
"securitySystemState"
]
},
"PM10Sensor": {
"name": "PM10Sensor",
"methods": [],
"properties": [
"pm10Density"
]
},
"PM25Sensor": {
"name": "PM25Sensor",
"methods": [],
@@ -2104,6 +2121,13 @@ ScryptedInterfaceDescriptors = {
"vocDensity"
]
},
"NOXSensor": {
"name": "NOXSensor",
"methods": [],
"properties": [
"noxDensity"
]
},
"CO2Sensor": {
"name": "CO2Sensor",
"methods": [],

View File

@@ -1048,12 +1048,18 @@ export interface Position {
export interface PositionSensor {
position?: Position;
}
export interface PM10Sensor {
pm10Density?: number;
}
export interface PM25Sensor {
pm25Density?: number;
}
export interface VOCSensor {
vocDensity?: number;
}
export interface NOXSensor {
noxDensity?: number;
}
export interface CO2Sensor {
co2ppm?: number;
}
@@ -1616,8 +1622,10 @@ export declare enum ScryptedInterface {
LuminanceSensor = "LuminanceSensor",
PositionSensor = "PositionSensor",
SecuritySystem = "SecuritySystem",
PM10Sensor = "PM10Sensor",
PM25Sensor = "PM25Sensor",
VOCSensor = "VOCSensor",
NOXSensor = "NOXSensor",
CO2Sensor = "CO2Sensor",
AirQualitySensor = "AirQualitySensor",
Readme = "Readme",

View File

@@ -518,6 +518,13 @@ exports.ScryptedInterfaceDescriptors = {
'securitySystemState'
]
},
PM10Sensor: {
name: 'PM10Sensor',
methods: [],
properties: [
'pm10Density'
]
},
PM25Sensor: {
name: 'PM25Sensor',
methods: [],
@@ -532,6 +539,13 @@ exports.ScryptedInterfaceDescriptors = {
'vocDensity'
]
},
NOXSensor: {
name: 'NOXSensor',
methods: [],
properties: [
'noxDensity'
]
},
CO2Sensor: {
name: 'CO2Sensor',
methods: [],
@@ -829,8 +843,10 @@ var ScryptedInterface;
ScryptedInterface["LuminanceSensor"] = "LuminanceSensor";
ScryptedInterface["PositionSensor"] = "PositionSensor";
ScryptedInterface["SecuritySystem"] = "SecuritySystem";
ScryptedInterface["PM10Sensor"] = "PM10Sensor";
ScryptedInterface["PM25Sensor"] = "PM25Sensor";
ScryptedInterface["VOCSensor"] = "VOCSensor";
ScryptedInterface["NOXSensor"] = "NOXSensor";
ScryptedInterface["CO2Sensor"] = "CO2Sensor";
ScryptedInterface["AirQualitySensor"] = "AirQualitySensor";
ScryptedInterface["Readme"] = "Readme";

View File

@@ -638,6 +638,13 @@ export const ScryptedInterfaceDescriptors: { [scryptedInterface: string]: Scrypt
'securitySystemState'
]
},
PM10Sensor: {
name: 'PM10Sensor',
methods: [],
properties: [
'pm10Density'
]
},
PM25Sensor: {
name: 'PM25Sensor',
methods: [],
@@ -652,6 +659,13 @@ export const ScryptedInterfaceDescriptors: { [scryptedInterface: string]: Scrypt
'vocDensity'
]
},
NOXSensor: {
name: 'NOXSensor',
methods: [],
properties: [
'noxDensity'
]
},
CO2Sensor: {
name: 'CO2Sensor',
methods: [],
@@ -2369,8 +2383,10 @@ export enum ScryptedInterface {
LuminanceSensor = "LuminanceSensor",
PositionSensor = "PositionSensor",
SecuritySystem = 'SecuritySystem',
PM10Sensor = "PM10Sensor",
PM25Sensor = "PM25Sensor",
VOCSensor = "VOCSensor",
NOXSensor = "NOXSensor",
CO2Sensor = "CO2Sensor",
AirQualitySensor = "AirQualitySensor",
Readme = "Readme",

View File

@@ -106,12 +106,14 @@ class ScryptedInterface(Enum):
MixinProvider = "MixinProvider"
MotionSensor = "MotionSensor"
Notifier = "Notifier"
NOXSensor = "NOXSensor"
OauthClient = "OauthClient"
ObjectDetection = "ObjectDetection"
ObjectDetector = "ObjectDetector"
OccupancySensor = "OccupancySensor"
OnOff = "OnOff"
Online = "Online"
PM10Sensor = "PM10Sensor"
PM25Sensor = "PM25Sensor"
PanTiltZoom = "PanTiltZoom"
PasswordStore = "PasswordStore"
@@ -804,6 +806,10 @@ class Notifier:
pass
pass
class NOXSensor:
noxDensity: float
pass
class OauthClient:
async def getOauthUrl(self) -> str:
pass
@@ -841,6 +847,10 @@ class Online:
online: bool
pass
class PM10Sensor:
pm10Density: float
pass
class PM25Sensor:
pm25Density: float
pass
@@ -2090,6 +2100,13 @@ ScryptedInterfaceDescriptors = {
"securitySystemState"
]
},
"PM10Sensor": {
"name": "PM10Sensor",
"methods": [],
"properties": [
"pm10Density"
]
},
"PM25Sensor": {
"name": "PM25Sensor",
"methods": [],
@@ -2104,6 +2121,13 @@ ScryptedInterfaceDescriptors = {
"vocDensity"
]
},
"NOXSensor": {
"name": "NOXSensor",
"methods": [],
"properties": [
"noxDensity"
]
},
"CO2Sensor": {
"name": "CO2Sensor",
"methods": [],