8 Commits
Author SHA1 Message Date
Serge Wagener 84ed5cc74a Removed unneeded import 2022-03-15 16:40:24 +01:00
Serge Wagener 59fe9963a1 Merge branch 'master' of github.com:Foxi352/homebridge-smarthomeng 2022-03-15 16:39:23 +01:00
Serge Wagener 0beada795f Update README.md
Added fan rotation speed to doc
2022-03-15 07:38:07 +01:00
Serge Wagener e2d30353fb Update Fan.ts 2022-03-15 07:36:22 +01:00
Serge Wagener 1a2e5c051d Merge pull request #14 from thomas-kaltenbach/master
Add rotationspeed as fan charasteristics
2022-03-15 07:34:13 +01:00
Thomas Kaltenbach 5f0b025e25 Add rotationspped as charasteristics 2022-03-13 19:06:30 +01:00
Serge Wagener f4700332cc Preparing for v2.0.5 release 2022-03-08 16:51:24 +01:00
Serge Wagener 323c313f3c Code formating 2022-03-08 16:51:01 +01:00
4 changed files with 37 additions and 13 deletions

No files matched your search

+3 -2
View File
@@ -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
View File
@@ -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
View File
@@ -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);
}
}
}
+1 -6
View File
@@ -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;
}