13 Commits
Author SHA1 Message Date
Serge Wagener 43e3fdf35f Remover "homebridge verified" until official approval 2022-03-18 08:24:17 +01:00
Serge Wagener d07d621e45 Added check for empty accessories list 2022-03-18 08:23:38 +01:00
Serge Wagener c8d117a894 Changed badge order 2022-03-17 16:45:58 +01:00
Serge Wagener 9a6c9e681d Links to 3rd party installation instructions 2022-03-16 17:41:14 +01:00
Serge Wagener 0394d789f8 Plugin now verified by homebridge dev's 2022-03-15 22:00:46 +01:00
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
5 changed files with 148 additions and 138 deletions

No files matched your search

+20 -36
View File
@@ -29,32 +29,15 @@ This plugin currently supports the following services (and characteristics):
| [Thermostat](#thermostat) | Thermostat with temperature sensor and heating state |
| [WindowCovering](#window-covering) | Window covering (shutters, blinds, ...) |
Other accessories are being worked on and will be added as soon as ready.
## Requirements
* [SmartHomeNG](https://github.com/smarthomeNG/smarthome)
* [homebridge](https://www.npmjs.com/package/homebridge)
* [Node.js >=14.18.1](https://nodejs.org/en/)
* [Homebridge](https://homebridge.io)
## Installation
### Install nodejs >=14.18.1
See [NodeJS](https://nodejs.org/en/) website for details depending on your OS.
## Installation of plugin
### Install libavahi-compat-libdnssd-dev lib
For me i needed these libraries to be installed for my homebridge to work. See their [Homepage](https://homebridge.io) for installation instructions.
Below is what i did on my Debian Bullseye installation:
sudo apt install libavahi-compat-libdnssd-dev
### Install homebridge >=1.3.5 from NPM repository
npm install -g homebridge --unsafe-perm
### Install this plugin from NPM repository
npm install -g homebridge-smarthomeng --unsafe-perm
Use [Homebridge Config UI X](https://github.com/oznu/homebridge-config-ui-x#readme) or install manually using ```npm install -g homebridge-smarthomeng```
## Configuration
@@ -63,13 +46,13 @@ If you already have a working homebridge installation just add the platform sect
### Platform configuration
The following parameters are available to configure the plugin as platform in homebridge.
| Parameter | Possible values | Mandatory | Description |
|:----------|:---------------------------------------|:----------|:----------------------------------------------------|
| platform | Any \<string> | Yes | Internal name of your platform |
| name | Any \<string> | Yes | Visible name in HomeKit |
| host | IP address or FQDN of your SHNG server | Yes | Your SHNG host |
| port | Port \<number> | No | Listening port of websocket module. Default is 2424 |
| tls | \<boolean> | No | Should TLS encryption be used. Defaults is 'false' |
| Parameter | Possible values | Mandatory | Default | Description |
|:----------|:---------------------------------------|:----------|:--------|:------------------------------------|
| platform | Any \<string> | Yes | | Internal name of your platform |
| name | Any \<string> | Yes | | Visible name in HomeKit |
| host | IP address or FQDN of your SHNG server | Yes | | Your SHNG host |
| port | Port \<number> | No | 2424 | Listening port of websocket module. |
| tls | \<boolean> | No | False | Should TLS encryption be used. |
#### Example configuration:
```json
@@ -141,9 +124,10 @@ Further investigation is needed, but for now it still works.
For now this accessory only supports turning the fan on and off. Further improvements are possible, but i don't have the needed hardware for testing.
#### 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 |
| Parameter | Possible values | Mandatory | Description |
|:--------------|:----------------|:----------|:------------------------------------------------|
| 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:
@@ -159,11 +143,11 @@ For now this accessory only supports turning the fan on and off. Further improve
This accessory is used for opening/closing garage doors or any other automatic gate.
#### Characteristics in addition to [common characteristics](#common-accessories-characteristics)
| Parameter | Possible values | Mandatory | Default | Description |
|:---------------------------|:----------------|:----------|:--------|:------------------------------------------------------------------|
| CurrentDoorState | \<item> | Yes | | SHNG item to monitor the current door state |
| TargetDoorState | \<item> | Yes | | SHNG item to monitor and set the target position |
| ObstructionDetected | \<item> | No | | SHNG item to monitor if the door is blocked |
| Parameter | Possible values | Mandatory | Description |
|:--------------------|:----------------|:----------|:------------------------------------------------------------------|
| CurrentDoorState | \<item> | Yes | SHNG item to monitor the current door state |
| TargetDoorState | \<item> | Yes | SHNG item to monitor and set the target position |
| ObstructionDetected | \<item> | No | SHNG item to monitor if the door is blocked |
#### Additional comments
+1 -1
View File
@@ -2,7 +2,7 @@
"private": false,
"displayName": "SmartHomeNG",
"name": "homebridge-smarthomeng",
"version": "2.0.4",
"version": "2.0.6",
"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);
}
}
}
+3 -8
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));
@@ -34,7 +33,7 @@ export class GarageDoor implements AccessoryPlugin {
.onGet(this.getCurrentDoorState.bind(this))
.onSet(this.setCurrentDoorState.bind(this));
} else {
this.platform.log.error('GarageDoor: missing \"currentdoorstate\" in config.json!');
this.platform.log.error('GarageDoor: missing \"currentdoorstate\" in config.json!');
}
if (accessory.targetdoorstate) {
@@ -43,7 +42,7 @@ export class GarageDoor implements AccessoryPlugin {
.onGet(this.getTargetDoorState.bind(this))
.onSet(this.setTargetDoorState.bind(this));
} else {
this.platform.log.error('GarageDoor: missing \"targetdoorstate\" in config.json!');
this.platform.log.error('GarageDoor: missing \"targetdoorstate\" in config.json!');
}
if (accessory.obstructiondetected) {
@@ -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;
}
+92 -89
View File
@@ -75,97 +75,100 @@ export class SmartHomeNGPlatform implements StaticPlatformPlugin {
// convert all configured accessory keys to lowercase to tolerate user case errors
const accessories = JSON.parse(JSON.stringify(uncapitalizeKeys(this.config.accessories)));
for (const accessory of accessories) {
if (!accessory.manufacturer) {
accessory.manufacturer = 'SmartHomeNG';
}
if (!accessory.model) {
accessory.model = 'SHNG Item';
}
if (accessory.type !== '') {
this.log.info('Parsing accessory:', accessory.name, 'of type', accessory.type);
// set lo lowercase to ignore user case errors
switch (accessory.type.toLowerCase()) {
// Presence sensor
case 'occupancysensor':
devices.push(new OccupancySensor(this, accessory));
break;
// Motion sensor
case 'motionsensor':
devices.push(new MotionSensor(this, accessory));
break;
// Contact sensor
case 'contactsensor':
devices.push(new ContactSensor(this, accessory));
break;
// Doorbell
case 'doorbell':
devices.push(new Doorbell(this, accessory));
break;
// Security system
case 'securitysystem':
devices.push(new SecuritySystem(this, accessory));
break;
// Switch
case 'switch':
devices.push(new Switch(this, accessory));
break;
// Lightbulb
case 'lightbulb':
devices.push(new Lightbulb(this, accessory));
break;
// Outlet
case 'outlet':
devices.push(new Outlet(this, accessory));
break;
// Fan (uses Fanv2)
case 'fan':
devices.push(new Fan(this, accessory));
break;
// Temperature sensor
case 'temperaturesensor':
devices.push(new TemperatureSensor(this, accessory));
break;
// Thermostat
case 'thermostat':
devices.push(new Thermostat(this, accessory));
break;
// WindowCovering
case 'windowcovering':
devices.push(new WindowCovering(this, accessory));
break;
// Garage door
case 'garagedoor':
devices.push(new GarageDoor(this, accessory));
break;
// Humidity sensor
case 'humiditysensor':
devices.push(new HumiditySensor(this, accessory));
break;
// Show error for (yet ?) unsupported device
default:
this.log.warn('Accessory type', accessory.type, 'for', accessory.name, 'not recognized !');
break;
this.log.debug(accessories);
if (Object.keys(accessories).length > 0) {
for (const accessory of accessories) {
if (!accessory.manufacturer) {
accessory.manufacturer = 'SmartHomeNG';
}
if (!accessory.model) {
accessory.model = 'SHNG Item';
}
if (accessory.type !== '') {
this.log.info('Parsing accessory:', accessory.name, 'of type', accessory.type);
// set lo lowercase to ignore user case errors
switch (accessory.type.toLowerCase()) {
// Presence sensor
case 'occupancysensor':
devices.push(new OccupancySensor(this, accessory));
break;
// Motion sensor
case 'motionsensor':
devices.push(new MotionSensor(this, accessory));
break;
// Contact sensor
case 'contactsensor':
devices.push(new ContactSensor(this, accessory));
break;
// Doorbell
case 'doorbell':
devices.push(new Doorbell(this, accessory));
break;
// Security system
case 'securitysystem':
devices.push(new SecuritySystem(this, accessory));
break;
// Switch
case 'switch':
devices.push(new Switch(this, accessory));
break;
// Lightbulb
case 'lightbulb':
devices.push(new Lightbulb(this, accessory));
break;
// Outlet
case 'outlet':
devices.push(new Outlet(this, accessory));
break;
// Fan (uses Fanv2)
case 'fan':
devices.push(new Fan(this, accessory));
break;
// Temperature sensor
case 'temperaturesensor':
devices.push(new TemperatureSensor(this, accessory));
break;
// Thermostat
case 'thermostat':
devices.push(new Thermostat(this, accessory));
break;
// WindowCovering
case 'windowcovering':
devices.push(new WindowCovering(this, accessory));
break;
// Garage door
case 'garagedoor':
devices.push(new GarageDoor(this, accessory));
break;
// Humidity sensor
case 'humiditysensor':
devices.push(new HumiditySensor(this, accessory));
break;
// Show error for (yet ?) unsupported device
default:
this.log.warn('Accessory type', accessory.type, 'for', accessory.name, 'not recognized !');
break;
}
} else {
this.log.warn('Ignoring accessory (no type given): ' + accessory);
}
} else {
this.log.warn('Ignoring accessory (no type given): ' + accessory);
}
}
callback(devices);
this.log.debug('Finished building accessories list');