Added TLS support
This commit is contained in:
parent
0167799c54
commit
b2a287934c
41
README.md
41
README.md
@ -48,23 +48,36 @@ Below is what i did on my Debian Bullseye installation:
|
|||||||
## Configuration
|
## Configuration
|
||||||
If you already have a working homebridge installation just add the platform section into your existing config. If you are a new homebridge user you have to create a `config.json` file in the `.homebridge` directory. You'll find that directory in your home folder.
|
If you already have a working homebridge installation just add the platform section into your existing config. If you are a new homebridge user you have to create a `config.json` file in the `.homebridge` directory. You'll find that directory in your home folder.
|
||||||
|
|
||||||
### Common characteristics
|
### Platform configuration
|
||||||
|
The following parameters are available to configure the plugin as platform in homebridge.
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"platform": "SmartHomeNG",
|
||||||
|
"name": "SmartHomeNG",
|
||||||
|
"host": "<your SHNG server name or IP>",
|
||||||
|
"port": 2425,
|
||||||
|
"tls": true,
|
||||||
|
}
|
||||||
|
```
|
||||||
|
If the `port` and `tls` parameters are not specified the plugin defaults to port 2424 without tls encryption.
|
||||||
|
|
||||||
|
### Common accessories characteristics
|
||||||
The following characteristics are valid for all accessories.
|
The following characteristics are valid for all accessories.
|
||||||
|
|
||||||
Mandatory:
|
Mandatory:
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"type": "OccupancySensor",
|
"type": "OccupancySensor",
|
||||||
"name": "Presence kitchen",
|
"name": "Presence kitchen",
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Optional:
|
Optional:
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"manufacturer": "Preussen",
|
"manufacturer": "Preussen",
|
||||||
"model": "Motion 360 KNX",
|
"model": "Motion 360 KNX",
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
### Doorbell
|
### Doorbell
|
||||||
@ -103,8 +116,8 @@ In addition to the common characteristics the following are available.
|
|||||||
Mandatory:
|
Mandatory:
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"CurrentPosition": "EG.Buero.Rolladen.Position",
|
"CurrentPosition": "EG.Buero.Rolladen.Position",
|
||||||
"TargetPosition": "EG.Buero.Rolladen.ZielPosition",
|
"TargetPosition": "EG.Buero.Rolladen.ZielPosition",
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
The current moving state and direction is automatically derived from the difference between the current and target position.
|
The current moving state and direction is automatically derived from the difference between the current and target position.
|
||||||
@ -112,12 +125,12 @@ The current moving state and direction is automatically derived from the differe
|
|||||||
Optional:
|
Optional:
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"CurrentPositionMin": 0,
|
"CurrentPositionMin": 0,
|
||||||
"CurrentPositionMax": 255,
|
"CurrentPositionMax": 255,
|
||||||
"CurrentPositionInverted": true,
|
"CurrentPositionInverted": true,
|
||||||
"TargetPositionMin": 0,
|
"TargetPositionMin": 0,
|
||||||
"TargetPositionMax": 255,
|
"TargetPositionMax": 255,
|
||||||
"TargetPositionInverted": true
|
"TargetPositionInverted": true
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
HomeKit works with values between 0 and 100 where 0 is completely closed and 100 is open.
|
HomeKit works with values between 0 and 100 where 0 is completely closed and 100 is open.
|
||||||
@ -141,6 +154,8 @@ This is an example config file which just uses this plugin and some example Smar
|
|||||||
"platform": "SmartHomeNG",
|
"platform": "SmartHomeNG",
|
||||||
"name": "SmartHomeNG",
|
"name": "SmartHomeNG",
|
||||||
"host": "smarthome.iot.wagener.family",
|
"host": "smarthome.iot.wagener.family",
|
||||||
|
"port": 2425,
|
||||||
|
"tls": true,
|
||||||
"accessories": [
|
"accessories": [
|
||||||
{
|
{
|
||||||
"type": "Outlet",
|
"type": "Outlet",
|
||||||
|
|||||||
@ -170,19 +170,34 @@ export class Lightbulb implements AccessoryPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateColor(): void {
|
updateColor(): void {
|
||||||
if (this.lightType === LightType.RGBW) {
|
switch (this.lightType) {
|
||||||
const rgbw: RGBW = this.hsb2rgbw(this.hue, this.saturation, this.brightness);
|
|
||||||
this.platform.shng.setItem(this.accessory.r, this.convertRange(rgbw.R, 0, 100, this.RMin, this.RMax));
|
case LightType.RGBW: {
|
||||||
this.platform.shng.setItem(this.accessory.g, this.convertRange(rgbw.G, 0, 100, this.GMin, this.GMax));
|
const rgbw: RGBW = this.hsb2rgbw(this.hue, this.saturation, this.brightness);
|
||||||
this.platform.shng.setItem(this.accessory.b, this.convertRange(rgbw.B, 0, 100, this.BMin, this.BMax));
|
this.platform.shng.setItem(this.accessory.r, this.convertRange(rgbw.R, 0, 100, this.RMin, this.RMax));
|
||||||
this.platform.shng.setItem(this.accessory.w, this.convertRange(rgbw.W, 0, 100, this.WMin, this.WMax));
|
this.platform.shng.setItem(this.accessory.g, this.convertRange(rgbw.G, 0, 100, this.GMin, this.GMax));
|
||||||
} else if (this.lightType === LightType.RGB) {
|
this.platform.shng.setItem(this.accessory.b, this.convertRange(rgbw.B, 0, 100, this.BMin, this.BMax));
|
||||||
const rgb: RGB = this.hsb2rgb(this.hue, this.saturation, this.brightness);
|
this.platform.shng.setItem(this.accessory.w, this.convertRange(rgbw.W, 0, 100, this.WMin, this.WMax));
|
||||||
this.platform.shng.setItem(this.accessory.r, this.convertRange(rgb.R, 0, 100, this.RMin, this.RMax));
|
break;
|
||||||
this.platform.shng.setItem(this.accessory.g, this.convertRange(rgb.G, 0, 100, this.GMin, this.GMax));
|
}
|
||||||
this.platform.shng.setItem(this.accessory.b, this.convertRange(rgb.B, 0, 100, this.BMin, this.BMax));
|
|
||||||
} else {
|
case LightType.RGB: {
|
||||||
this.platform.log.warn('Cannot update color of', this.name, 'because RGB(W) items are missing');
|
const rgb: RGB = this.hsb2rgb(this.hue, this.saturation, this.brightness);
|
||||||
|
this.platform.shng.setItem(this.accessory.r, this.convertRange(rgb.R, 0, 100, this.RMin, this.RMax));
|
||||||
|
this.platform.shng.setItem(this.accessory.g, this.convertRange(rgb.G, 0, 100, this.GMin, this.GMax));
|
||||||
|
this.platform.shng.setItem(this.accessory.b, this.convertRange(rgb.B, 0, 100, this.BMin, this.BMax));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case LightType.HSB:
|
||||||
|
this.platform.shng.setItem(this.accessory.hue, this.hue);
|
||||||
|
this.platform.shng.setItem(this.accessory.saturation, this.saturation);
|
||||||
|
this.platform.shng.setItem(this.accessory.brightness, this.brightness);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
this.platform.log.warn('Cannot update color of', this.name, 'because RGB(W) items are missing');
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -54,7 +54,11 @@ export class SmartHomeNGPlatform implements StaticPlatformPlugin {
|
|||||||
public readonly api: API,
|
public readonly api: API,
|
||||||
) {
|
) {
|
||||||
log.debug('Using config file', api.user.configPath());
|
log.debug('Using config file', api.user.configPath());
|
||||||
this.shng = new SmartHomeNG(this, 'ws://smarthome.iot.wagener.family:2424/');
|
const host = this.config.host ? this.config.host : 'smarthome.local';
|
||||||
|
const port = this.config.port ? this.config.port : '2424';
|
||||||
|
const protocol = this.config.tls ? 'wss' : 'ws';
|
||||||
|
const url = protocol + '://' + host + ':' + port + '/';
|
||||||
|
this.shng = new SmartHomeNG(this, url);
|
||||||
|
|
||||||
this.api.on('didFinishLaunching', () => {
|
this.api.on('didFinishLaunching', () => {
|
||||||
log.debug('Executed didFinishLaunching callback');
|
log.debug('Executed didFinishLaunching callback');
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user