Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
84ed5cc74a | ||
|
|
59fe9963a1 | ||
|
|
0beada795f | ||
|
|
e2d30353fb | ||
|
|
1a2e5c051d | ||
|
|
5f0b025e25 | ||
|
|
f4700332cc | ||
|
|
323c313f3c |
No files matched your search
@@ -142,8 +142,9 @@ For now this accessory only supports turning the fan on and off. Further improve
|
||||
|
||||
#### Characteristics in addition to [common characteristics](#common-accessories-characteristics)
|
||||
| Parameter | Possible values | Mandatory | Description |
|
||||
|:----------|:----------------|:----------|:---------------------------------------|
|
||||
| Active | \<item> | Yes | SHNG item to set and get the fan state |
|
||||
|:--------------|:----------------|:----------|:------------------------------------------------|
|
||||
| Active | \<item> | Yes | SHNG item to set and get the fan state. |
|
||||
| RotationSpeed | \<item> | No | SHNG item to set and get the fan rotation speed |
|
||||
|
||||
#### Example:
|
||||
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
"private": false,
|
||||
"displayName": "SmartHomeNG",
|
||||
"name": "homebridge-smarthomeng",
|
||||
"version": "2.0.4",
|
||||
"version": "2.0.5",
|
||||
"description": "SmartHomeNG plugin for Homebridge",
|
||||
"license": "Apache-2.0",
|
||||
"repository": {
|
||||
|
||||
+32
-4
@@ -13,6 +13,7 @@ export class Fan implements AccessoryPlugin {
|
||||
|
||||
public name: string;
|
||||
private active = false;
|
||||
private rotationSpeed = 100;
|
||||
|
||||
constructor(private readonly platform: SmartHomeNGPlatform, private readonly accessory) {
|
||||
this.name = accessory.name;
|
||||
@@ -22,14 +23,20 @@ export class Fan implements AccessoryPlugin {
|
||||
this.deviceService.getCharacteristic(this.platform.Characteristic.Active)
|
||||
.onGet(this.getActive.bind(this))
|
||||
.onSet(this.setActive.bind(this));
|
||||
this.platform.shng.addMonitor(accessory.active, this.shngActiveCallback.bind(this));
|
||||
|
||||
if (accessory.rotationspeed) {
|
||||
this.deviceService.getCharacteristic(this.platform.Characteristic.RotationSpeed)
|
||||
.onGet(this.getRotationSpeed.bind(this))
|
||||
.onSet(this.setRotationSpeed.bind(this));
|
||||
this.platform.shng.addMonitor(accessory.rotationspeed, this.shngRotationSpeedCallback.bind(this));
|
||||
}
|
||||
|
||||
this.informationService =
|
||||
new this.platform.Service.AccessoryInformation()
|
||||
.setCharacteristic(this.platform.Characteristic.Manufacturer, accessory.manufacturer)
|
||||
.setCharacteristic(this.platform.Characteristic.Model, accessory.model)
|
||||
.setCharacteristic(this.platform.Characteristic.SerialNumber, accessory.active);
|
||||
|
||||
this.platform.shng.addMonitor(accessory.active, this.shngCallback.bind(this));
|
||||
this.platform.log.info("Fan '%s' created!", accessory.name);
|
||||
}
|
||||
|
||||
@@ -52,8 +59,19 @@ export class Fan implements AccessoryPlugin {
|
||||
this.platform.shng.setItem(this.accessory.active, this.active);
|
||||
}
|
||||
|
||||
shngCallback(value: unknown): void {
|
||||
this.platform.log.debug('shngCallback:', this.accessory.name, '=', value, '(' + typeof value + ')');
|
||||
getRotationSpeed(): Nullable<CharacteristicValue> {
|
||||
this.platform.log.info('getRotationSpeed:', this.accessory.name, 'is currently', this.rotationSpeed);
|
||||
return this.rotationSpeed;
|
||||
}
|
||||
|
||||
setRotationSpeed(value: CharacteristicValue) {
|
||||
this.rotationSpeed = value as number;
|
||||
this.platform.log.info('setRotationSpeed:', this.accessory.name, 'was set to', this.rotationSpeed);
|
||||
this.platform.shng.setItem(this.accessory.rotationspeed, this.rotationSpeed);
|
||||
}
|
||||
|
||||
shngActiveCallback(value: unknown): void {
|
||||
this.platform.log.debug('shngActiveCallback:', this.accessory.name, '=', value, '(' + typeof value + ')');
|
||||
if (typeof value === 'boolean') {
|
||||
this.active = value;
|
||||
this.deviceService.updateCharacteristic(this.platform.Characteristic.Active, this.active);
|
||||
@@ -61,4 +79,14 @@ export class Fan implements AccessoryPlugin {
|
||||
this.platform.log.warn('Unknown type ', typeof value, 'received for', this.accessory.name + ':', value);
|
||||
}
|
||||
}
|
||||
|
||||
shngRotationSpeedCallback(value: unknown): void {
|
||||
this.platform.log.debug('shngRotationSpeedCallback:', this.accessory.name, '=', value, '(' + typeof value + ')');
|
||||
if (typeof value === 'number') {
|
||||
this.rotationSpeed = value;
|
||||
this.deviceService.updateCharacteristic(this.platform.Characteristic.RotationSpeed, this.rotationSpeed);
|
||||
} else {
|
||||
this.platform.log.warn('Unknown type ', typeof value, 'received for', this.accessory.name + ':', value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,12 +21,11 @@ export class GarageDoor implements AccessoryPlugin {
|
||||
this.deviceService = new this.platform.Service.GarageDoorOpener(accessory.name);
|
||||
|
||||
// create handlers for required characteristics
|
||||
|
||||
this.informationService =
|
||||
new this.platform.Service.AccessoryInformation()
|
||||
.setCharacteristic(this.platform.Characteristic.Manufacturer, accessory.manufacturer)
|
||||
.setCharacteristic(this.platform.Characteristic.Model, accessory.model)
|
||||
.setCharacteristic(this.platform.Characteristic.SerialNumber, accessory.currentdoorstate); // FIXME
|
||||
.setCharacteristic(this.platform.Characteristic.SerialNumber, accessory.currentdoorstate);
|
||||
|
||||
if (accessory.currentdoorstate) {
|
||||
this.platform.shng.addMonitor(accessory.currentdoorstate, this.shngCurrentDoorStateCallback.bind(this));
|
||||
@@ -66,8 +65,6 @@ export class GarageDoor implements AccessoryPlugin {
|
||||
}
|
||||
|
||||
getCurrentDoorState(): Nullable<CharacteristicValue> {
|
||||
//getCurrentDoorState(value: CharacteristicValue) {
|
||||
// this.currentDoorState = value as number;
|
||||
this.platform.log.info('getCurrentDoorState:', this.accessory.name, 'is currently', this.currentDoorState);
|
||||
return this.currentDoorState;
|
||||
}
|
||||
@@ -79,8 +76,6 @@ export class GarageDoor implements AccessoryPlugin {
|
||||
}
|
||||
|
||||
getTargetDoorState(): Nullable<CharacteristicValue> {
|
||||
//getTargetDoorState(value: CharacteristicValue) {
|
||||
// this.targetDoorState = value as number;
|
||||
this.platform.log.info('getTargetDoorState:', this.accessory.name, 'is currently', this.targetDoorState);
|
||||
return this.targetDoorState;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user