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)
|
#### Characteristics in addition to [common characteristics](#common-accessories-characteristics)
|
||||||
| Parameter | Possible values | Mandatory | Description |
|
| 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:
|
#### Example:
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
"private": false,
|
"private": false,
|
||||||
"displayName": "SmartHomeNG",
|
"displayName": "SmartHomeNG",
|
||||||
"name": "homebridge-smarthomeng",
|
"name": "homebridge-smarthomeng",
|
||||||
"version": "2.0.4",
|
"version": "2.0.5",
|
||||||
"description": "SmartHomeNG plugin for Homebridge",
|
"description": "SmartHomeNG plugin for Homebridge",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|||||||
+32
-4
@@ -13,6 +13,7 @@ export class Fan implements AccessoryPlugin {
|
|||||||
|
|
||||||
public name: string;
|
public name: string;
|
||||||
private active = false;
|
private active = false;
|
||||||
|
private rotationSpeed = 100;
|
||||||
|
|
||||||
constructor(private readonly platform: SmartHomeNGPlatform, private readonly accessory) {
|
constructor(private readonly platform: SmartHomeNGPlatform, private readonly accessory) {
|
||||||
this.name = accessory.name;
|
this.name = accessory.name;
|
||||||
@@ -22,14 +23,20 @@ export class Fan implements AccessoryPlugin {
|
|||||||
this.deviceService.getCharacteristic(this.platform.Characteristic.Active)
|
this.deviceService.getCharacteristic(this.platform.Characteristic.Active)
|
||||||
.onGet(this.getActive.bind(this))
|
.onGet(this.getActive.bind(this))
|
||||||
.onSet(this.setActive.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 =
|
this.informationService =
|
||||||
new this.platform.Service.AccessoryInformation()
|
new this.platform.Service.AccessoryInformation()
|
||||||
.setCharacteristic(this.platform.Characteristic.Manufacturer, accessory.manufacturer)
|
.setCharacteristic(this.platform.Characteristic.Manufacturer, accessory.manufacturer)
|
||||||
.setCharacteristic(this.platform.Characteristic.Model, accessory.model)
|
.setCharacteristic(this.platform.Characteristic.Model, accessory.model)
|
||||||
.setCharacteristic(this.platform.Characteristic.SerialNumber, accessory.active);
|
.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);
|
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);
|
this.platform.shng.setItem(this.accessory.active, this.active);
|
||||||
}
|
}
|
||||||
|
|
||||||
shngCallback(value: unknown): void {
|
getRotationSpeed(): Nullable<CharacteristicValue> {
|
||||||
this.platform.log.debug('shngCallback:', this.accessory.name, '=', value, '(' + typeof value + ')');
|
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') {
|
if (typeof value === 'boolean') {
|
||||||
this.active = value;
|
this.active = value;
|
||||||
this.deviceService.updateCharacteristic(this.platform.Characteristic.Active, this.active);
|
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);
|
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);
|
this.deviceService = new this.platform.Service.GarageDoorOpener(accessory.name);
|
||||||
|
|
||||||
// create handlers for required characteristics
|
// create handlers for required characteristics
|
||||||
|
|
||||||
this.informationService =
|
this.informationService =
|
||||||
new this.platform.Service.AccessoryInformation()
|
new this.platform.Service.AccessoryInformation()
|
||||||
.setCharacteristic(this.platform.Characteristic.Manufacturer, accessory.manufacturer)
|
.setCharacteristic(this.platform.Characteristic.Manufacturer, accessory.manufacturer)
|
||||||
.setCharacteristic(this.platform.Characteristic.Model, accessory.model)
|
.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) {
|
if (accessory.currentdoorstate) {
|
||||||
this.platform.shng.addMonitor(accessory.currentdoorstate, this.shngCurrentDoorStateCallback.bind(this));
|
this.platform.shng.addMonitor(accessory.currentdoorstate, this.shngCurrentDoorStateCallback.bind(this));
|
||||||
@@ -66,8 +65,6 @@ export class GarageDoor implements AccessoryPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getCurrentDoorState(): Nullable<CharacteristicValue> {
|
getCurrentDoorState(): Nullable<CharacteristicValue> {
|
||||||
//getCurrentDoorState(value: CharacteristicValue) {
|
|
||||||
// this.currentDoorState = value as number;
|
|
||||||
this.platform.log.info('getCurrentDoorState:', this.accessory.name, 'is currently', this.currentDoorState);
|
this.platform.log.info('getCurrentDoorState:', this.accessory.name, 'is currently', this.currentDoorState);
|
||||||
return this.currentDoorState;
|
return this.currentDoorState;
|
||||||
}
|
}
|
||||||
@@ -79,8 +76,6 @@ export class GarageDoor implements AccessoryPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getTargetDoorState(): Nullable<CharacteristicValue> {
|
getTargetDoorState(): Nullable<CharacteristicValue> {
|
||||||
//getTargetDoorState(value: CharacteristicValue) {
|
|
||||||
// this.targetDoorState = value as number;
|
|
||||||
this.platform.log.info('getTargetDoorState:', this.accessory.name, 'is currently', this.targetDoorState);
|
this.platform.log.info('getTargetDoorState:', this.accessory.name, 'is currently', this.targetDoorState);
|
||||||
return this.targetDoorState;
|
return this.targetDoorState;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user