From 7358592699c5014a10a15c1f38bccb7f05377c2a Mon Sep 17 00:00:00 2001 From: David Miller Date: Mon, 4 May 2020 00:28:22 +0100 Subject: [PATCH] Codec - list properties --- README.md | 2 +- docs/Codecs.md | 118 +++++++++++++++++++++++++++++++++++++++++++- index.js | 10 ++-- test/empty-codec.js | 2 +- 4 files changed, 124 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 533fa72..8ca88e6 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ MQTT topics used fall into two categories: * Control topics, of the form `setXXX`, are published by MQTT-Thing in order to control device state (e.g. to turn on a light). * Status/notification topics, of the form `getXXX`, are published by the device to notify MQTT-Thing that something has occurred (e.g. that a sensor has detected something or a control topic action has been performed). -For further details, see [docs/Configuration.md](docs/Configuration.md). +For further details, see [docs/Configuration.md](docs/Configuration.md) and [docs/Codecs.md](docs/Codecs.md). ## Supported Accessories diff --git a/docs/Codecs.md b/docs/Codecs.md index 19b6081..9f6070f 100644 --- a/docs/Codecs.md +++ b/docs/Codecs.md @@ -80,7 +80,7 @@ function init() { properties: { targetProp1: { encode: encodeFunction1, - decode: decodeFunction2 + decode: decodeFunction1 }, targetProp2: { encode: encodeFunction2 @@ -121,3 +121,119 @@ The `decode()` function may either return the decoded message, or it may deliver ## Empty Codec When writing a codec, you may find it helpful to start with the no-op implementation in [`test/empty-codec.js`](../test/empty-codec.js). + +## Properties + +This section lists the properties available for each accessory type. All accessories may also support `batteryLevel`, `chargingState` and `statusLowBattery`. + +### Air Pressure Sensor + +`airPressure`, `statusActive`, `statusFault`, `statusTampered`, `statusLowBattery` + +### Air Quality Sensor + +`airQuality`, `statusActive`, `statusFault`, `statusTampered`, `statusLowBattery`, `carbonDioxideLevel`, `pm10density`, `pm2_5density`, `ozonedensity`, `nitrogenDioxideDensity`, `sulphurDioxideDensity`, `VOCDensity`, `carbonMonoxideLevel`, `airQualityPPM`, `currentTemperature`, `currentRelativeHumidity` + +### Carbon Dioxide Sensor + +`carbonDioxideDetected`, `carbonDioxideLevel`, `carbonDioxidePeakLevel`, `statusActive`, `statusFault`, `statusTampered`, `statusLowBattery` + +### Contact Sensor + +`contactSensorState`, `statusActive`, `statusFault`, `statusTampered`, `statusLowBattery` + +### Doorbell + +`switch`, `brightness`, `volume`, `motionDetected` + +### Fan + +`on`, `rotationDirection`, `rotationSpeed` + +### Garage door opener + +`targetDoorState`, `currentDoorState`, `doorMoving`, `obstructionDetected`, `lockTargetState`, `lockCurrentState` + +### Heater Cooler + +`active`, `currentHeaterCoolerState`, `targetHeaterCoolerState`, `currentTemperature`, `lockPhysicalControls`, `swingMode`, `coolingThresholdTemperature`, `heatingThresholdTemperature`, `temperatureDisplayUnits`, `rotationSpeed` + +### Humidity Sensor + +`currentRelativeHumidity`, `statusActive`, `statusFault`, `statusTampered`, `statusLowBattery` + +### Leak Sensor + +`leakDetected`, `statusActive`, `statusFault`, `statusTampered`, `statusLowBattery` + +### Light bulb + +`on`, `brightness`, `hue`, `saturation`, `colorTemperature`, `white`, `HSV`, `RGB`, `RGBW`, `RGBWW` + +### Light Sensor + +`currentAmbientLightLevel`, `statusActive`, `statusFault`, `statusTampered`, `statusLowBattery` + +### Lock Mechanism + +`lockTargetState`, `lockCurrentState` + +### Microphone + +`mute`, `volume` + +### Motion Sensor + +`motionDetected`, `statusActive`, `statusFault`, `statusTampered`, `statusLowBattery` + +### Occupancy Sensor + +`occupancyDetected`, `statusActive`, `statusFault`, `statusTampered`, `statusLowBattery` + +### Outlet + +`on`, `outletInUse`, `currentConsumption`, `voltage`, `electricCurrent`, `totalConsumption` + +### Security System + +`targetState`, `currentState`, `statusFault`, `statusTampered` + +### Speaker + +`mute`, `volume` + +### StatelessProgrammableSwitch + +`switch`, `switch0`, `switch1`, `switch2`, ... + +### Switch + +`on` + +### Television + +`active`, `input`XX + +### Temperature Sensor + +`currentTemperature`, `statusActive`, `statusFault`, `statusTampered`, `statusLowBattery` + +### Thermostat + +`currentHeatingCoolingState`, `targetHeatingCoolingState`, `currentTemperature`, `targetTemperature`, `temperatureDisplayUnits`, `currentRelativeHumidity`, `targetRelativeHumidity`, `coolingThresholdTemperature`, `heatingThresholdTemperature` + +### Valve (Sprinkler, Shower, Faucet) + +`active`, `inUse`, `setDuration`, `remainingDuration` + +### Weather Station + +`currentTemperature`, `statusActive`, `statusFault`, `statusTampered`, `statusLowBattery`, `currentRelativeHumidity`, `airPressure`, `weatherCondition`, `rain1h`, `rain24h`, `uvIndex`, `visibility`, `windDirection`, `windSpeed` + +### Window + +`currentPosition`, `targetPosition`, `positionState`, `holdPosition`, `obstructionDetected` + +### Window Covering (Blinds) + +`currentPosition`, `targetPosition`, `positionState`, `holdPosition`, `obstructionDetected`, `targetHorizontalTiltAngle`, `currentHorizontalTiltAngle`, `targetVerticalTiltAngle`, `currentVerticalTiltAngle` diff --git a/index.js b/index.js index 664a50f..1da7857 100644 --- a/index.js +++ b/index.js @@ -1677,22 +1677,22 @@ function makeThing(log, config) { // Characteristic.OzoneDensity function characteristic_OzoneDensity( service ) { - floatCharacteristic( service, 'Ozonedensity', Characteristic.OzoneDensity, null, config.topics.getOzoneDensity ); + floatCharacteristic( service, 'ozoneDensity', Characteristic.OzoneDensity, null, config.topics.getOzoneDensity ); } // Characteristic.NitrogenDioxideDensity function characteristic_NitrogenDioxideDensity( service ) { - floatCharacteristic( service, 'NitrogenDioxidedensity', Characteristic.NitrogenDioxideDensity, null, config.topics.getNitrogenDioxideDensity ); + floatCharacteristic( service, 'nitrogenDioxideDensity', Characteristic.NitrogenDioxideDensity, null, config.topics.getNitrogenDioxideDensity ); } // Characteristic.SulphurDioxideDensity function characteristic_SulphurDioxideDensity( service ) { - floatCharacteristic( service, 'SulphurDioxidedensity', Characteristic.SulphurDioxideDensity, null, config.topics.getSulphurDioxideDensity ); + floatCharacteristic( service, 'sulphurDioxideDensity', Characteristic.SulphurDioxideDensity, null, config.topics.getSulphurDioxideDensity ); } // Characteristic.VOCDensity function characteristic_VOCDensity( service ) { - floatCharacteristic( service, 'VOCdensity', Characteristic.VOCDensity, null, config.topics.getVOCDensity ); + floatCharacteristic( service, 'VOCDensity', Characteristic.VOCDensity, null, config.topics.getVOCDensity ); } // Characteristic.CarbonMonoxideDensity @@ -1736,7 +1736,7 @@ function makeThing(log, config) { // Characteristic.CarbonDioxideLevel function characteristic_CarbonDioxidePeakLevel( service ) { - floatCharacteristic( service, 'carbonDioxidePeak', Characteristic.CarbonDioxidePeakLevel, null, config.topics.getCarbonDioxidePeakLevel, 0 ); + floatCharacteristic( service, 'carbonDioxidePeakLevel', Characteristic.CarbonDioxidePeakLevel, null, config.topics.getCarbonDioxidePeakLevel, 0 ); } // Characteristic.CurrentHeatingCoolingState diff --git a/test/empty-codec.js b/test/empty-codec.js index 0837c3f..b6a2fa8 100644 --- a/test/empty-codec.js +++ b/test/empty-codec.js @@ -64,7 +64,7 @@ function init( params ) { * properties: { * targetProp1: { * encode: encodeFunction1, - * decode: decodeFunction2 + * decode: decodeFunction1 * }, * targetProp2: { * encode: encodeFunction2