diff --git a/core/accessories/HumiditySensor.js b/core/accessories/HumiditySensor.js new file mode 100644 index 0000000..9457ff9 --- /dev/null +++ b/core/accessories/HumiditySensor.js @@ -0,0 +1,38 @@ +'use strict' + +const { Service, Characteristic, Categories} = require("hap-nodejs"); +const {SetWithBattery, BaseAccessory} = require("./BaseAccessory") + +class HumiditySensor extends BaseAccessory { + + constructor(Config) { + super(Config, Categories.SENSOR); + + this._service = new Service.HumiditySensor(Config.name, Config.name); + + this._service.setCharacteristic(Characteristic.CurrentRelativeHumidity, 25); + this._service.setCharacteristic(Characteristic.StatusActive, 1); + this._service.setCharacteristic(Characteristic.StatusFault, 0); + this._service.setCharacteristic(Characteristic.StatusTampered, 0); + this._Properties["CurrentRelativeHumidity"] = 25; + this._Properties["StatusActive"] = 1; + this._Properties["StatusFault"] = 0; + this._Properties["StatusTampered"] = 0; + + + const EventStruct = { + "Get": ["CurrentRelativeHumidity", "StatusActive", "StatusTampered", "StatusFault"], + "Set": [] + } + + this._wireUpEvents(this._service, EventStruct); + this._accessory.addService(this._service); + + this._createBatteryService(); + } +} +HumiditySensor.prototype.setCharacteristics = SetWithBattery; + +module.exports = { + HumiditySensor:HumiditySensor +} \ No newline at end of file diff --git a/core/accessories/Icons/HUMIDITY_SENSOR.png b/core/accessories/Icons/HUMIDITY_SENSOR.png new file mode 100644 index 0000000..00fd341 Binary files /dev/null and b/core/accessories/Icons/HUMIDITY_SENSOR.png differ diff --git a/core/accessories/Types.js b/core/accessories/Types.js index c2ab1d8..c297a0b 100644 --- a/core/accessories/Types.js +++ b/core/accessories/Types.js @@ -18,10 +18,19 @@ const { Leak } = require("./LeakSensor") const { LightSensor } = require("./LightSensor") const { Camera } = require("./Camera/Camera") const { MultiSensor } = require("./MultiSensor") +const { HumiditySensor } = require("./HumiditySensor") let Types = { + "HUMIDITY_SENSOR": { + Label: "Humidity Sensor", + Icon: "HUMIDITY_SENSOR.png", + SupportsRouting: true, + Class: HumiditySensor, + Actions: [], + ConfigProperties: [] + }, "CONTACT_SENSOR": { Label: "Contact Sensor", Icon: "CONTACT_SENSOR.png", diff --git a/package.json b/package.json index 0d770d6..350a485 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hap-router", - "version": "1.5.0", + "version": "1.6.0", "description": "A Middleware HAP Router for bringing HomeKit functionality to your Home Automation.", "main": "HAPRouter.js", "keywords": [