Skip to content

Commit

Permalink
multi accessory
Browse files Browse the repository at this point in the history
  • Loading branch information
Sinclair81 committed Nov 21, 2023
1 parent eb30ecf commit 810f9b7
Show file tree
Hide file tree
Showing 24 changed files with 1,498 additions and 132 deletions.
89 changes: 66 additions & 23 deletions README.md
Expand Up @@ -77,28 +77,29 @@ __Examples:__

## Platform Main Configuration Parameters ##

Name | Value | Required | Notes
----------------- | ------------------------ | ------------- | ------------------------
`platform` | "LogoPlatform" | yes | Must be set to "LogoPlatform".
`name` | (custom) | yes | Name of platform that will not appear in homekit app.
`interface` | "modbus" or "snap7" | no | Interface for communication, default is: "modbus".
`ip` | "10.0.0.100" | yes | Must be set to the IP of your LOGO!.
`port` | 502 | no (ModBus) | Must be set to the Modbus Port of your LOGO!, default is: 502.
`logoType` | "0BA7" or ... | no (Snap7) | Must be set to the [Type of your LOGO](#type-of-your-logo), default is: "0BA7".
`localTSAP` | "0x1200" | no (Snap7) | Must be set to the local TSAP of your LOGO!, default is: "0x1200".
`remoteTSAP` | "0x2200" | no (Snap7) | Must be set to the remote TSAP of your LOGO!, default is: "0x2200".
`queueInterval` | 100 ... 1000 | no | Interval to send queries from Plugin to LOGO!, in milliseconds, default is: 100.
`queueSize` | 100 ... 1000 | no | Number of items to be hold in send/receive queue, default is: 100.
`updateInterval` | 0 ... ∞ | no | Auto Update Interval in milliseconds, 0 = Off
`debugMsgLog` | 0 or 1 | no | Displays messages of all accessories in the log, default is: 0.
`retryCount` | 0 ... ∞ | no | Retry count for sending the queries messages, default is: 5.
`pushButton` | 0 or 1 | no | If e.g. the network input in the LOGO! a hardware button on the LOGO! simulated, default is: 0. (For all Accessories.)
`loggerType` | "influxDB" or "fakegato" | no | Activates Logging, default is: "none".
`loggerInterval` | 300000 | no | Logging Interval in milliseconds, default is: 300000 (5min)
`influxDBUrl` | "<http://10.0.0.99:8086>" | no (InfluxDB) | IP-Address and Port for InfluxDB
`influxDBToken` | "API Token", | no (InfluxDB) | InfluxDB API token
`influxDBOrg` | "Org", | no (InfluxDB) | InfluxDB organization ID
`influxDBBucket` | "Bucket", | no (InfluxDB) | InfluxDB bucket name
Name | Value | Required | Notes
----------------- | ------------------------- | ------------- | ------------------------
`platform` | "LogoPlatform" | yes | Must be set to "LogoPlatform".
`name` | (custom) | yes | Name of platform that will not appear in homekit app.
`interface` | "modbus" or "snap7" | no | Interface for communication, default is: "modbus".
`ip` | "10.0.0.100" | yes | Must be set to the IP of your LOGO!.
`port` | 502 | no (ModBus) | Must be set to the Modbus Port of your LOGO!, default is: 502.
`logoType` | "0BA7" or ... | no (Snap7) | Must be set to the [Type of your LOGO](#type-of-your-logo), default is: "0BA7".
`localTSAP` | "0x1200" | no (Snap7) | Must be set to the local TSAP of your LOGO!, default is: "0x1200".
`remoteTSAP` | "0x2200" | no (Snap7) | Must be set to the remote TSAP of your LOGO!, default is: "0x2200".
`queueInterval` | 100 ... 1000 | no | Interval to send queries from Plugin to LOGO!, in milliseconds, default is: 100.
`queueSize` | 100 ... 1000 | no | Number of items to be hold in send/receive queue, default is: 100.
`updateInterval` | 0 ... ∞ | no | Auto Update Interval in milliseconds, 0 = Off
`debugMsgLog` | 0 or 1 | no | Displays messages of all accessories in the log, default is: 0.
`retryCount` | 0 ... ∞ | no | Retry count for sending the queries messages, default is: 5.
`pushButton` | 0 or 1 | no | If e.g. the network input in the LOGO! a hardware button on the LOGO! simulated, default is: 0. (For all Accessories.)
`loggerType` | "influxDB" or "fakegato" | no | Activates Logging, default is: "none".
`loggerInterval` | 300000 | no | Logging Interval in milliseconds, default is: 300000 (5min)
`influxDBUrl` | "<http://10.0.0.99:8086>" | no (InfluxDB) | IP-Address and Port for InfluxDB
`influxDBToken` | "API Token" | no (InfluxDB) | InfluxDB API token
`influxDBOrg` | "Org" | no (InfluxDB) | InfluxDB organization ID
`influxDBBucket` | "Bucket" | no (InfluxDB) | InfluxDB bucket name
`parentAccessory` | (custom) | no | Parent accessory name, needed to create this accessory as a sub-accessory of an other accessory. Not for Valve, IrrigationSystem and Other

## Device Main Configuration Parameters ##

Expand Down Expand Up @@ -486,14 +487,56 @@ It opens a detailed view of the sub accessories.

Name | Value | Required | Option for | Notes
------------------------ | ------------------- | -------- | ---------- | ------------------------
`name` | (custom) | yes | Name of accessory that will appear in homekit app.
`type` | "other" | yes | Type of Accessory: "other"

```json
{
"name": "Accessory Name",
"name": "Ventilation",
"type": "other"
},
{
"name": "Level 1",
"type": "switch",
"switchGet": "Q3",
"switchSetOn": "V3.2",
"switchSetOff": "V4.2",
"parentAccessory": "Ventilation"
},
{
"name": "Level 2",
"type": "switch",
"switchGet": "Q4",
"switchSetOn": "V3.3",
"switchSetOff": "V4.3",
"parentAccessory": "Ventilation"
},
{
"name": "Automatic",
"type": "switch",
"switchGet": "M16",
"switchSetOn": "V3.4",
"switchSetOff": "V4.4",
"parentAccessory": "Ventilation"
},
{
"name": "Supply Air",
"type": "temperatureSensor",
"convertValue": 1,
"temperature": "AM5",
"parentAccessory": "Ventilation"
},
{
"name": "Exhaust Air",
"type": "temperatureSensor",
"convertValue": 1,
"temperature": "AM6",
"parentAccessory": "Ventilation"
}
```

<img src="https://raw.githubusercontent.com/Sinclair81/Homebridge-Logo-Platform/dev-1.4.x/other-ventilation.png" align="center" alt="other" height="593" width="500">

## Light Sensor Configuration ##

Name | Value | Required | Option for | Notes
Expand Down
Binary file added other-ventilation.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
129 changes: 127 additions & 2 deletions src/accessories/blindPlatformAccessory.ts
Expand Up @@ -4,6 +4,26 @@ import { QueueSendItem, QueueReceiveItem } from "../queue";
import { ErrorNumber } from "../error";
import { LoggerType, InfluxDBLogItem, InfluxDBFild } from "../logger";
import { md5 } from "../md5";
import { Accessory, SubAccessory } from '../logo';

import { SwitchPlatformAccessory } from './switchPlatformAccessory';
import { LightbulbPlatformAccessory } from './lightbulbPlatformAccessory';
import { WindowPlatformAccessory } from './windowPlatformAccessory';
import { GaragedoorPlatformAccessory } from './garagedoorPlatformAccessory';
import { ThermostatPlatformAccessory } from './thermostatPlatformAccessory';
import { FanPlatformAccessory } from './fanPlatformAccessory';
import { FilterMaintenancePlatformAccessory } from './filterMaintenancePlatformAccessory';
import { OutletPlatformAccessory } from './outletPlatformAccessory';

import { LightSensorPlatformAccessory } from '../sensors/lightSensorPlatformAccessory';
import { MotionSensorPlatformAccessory } from '../sensors/motionSensorPlatformAccessory';
import { ContactSensorPlatformAccessory } from '../sensors/contactSensorPlatformAccessory';
import { SmokeSensorPlatformAccessory } from '../sensors/smokeSensorPlatformAccessory';
import { TemperatureSensorPlatformAccessory } from '../sensors/temperatureSensorPlatformAccessory';
import { HumiditySensorPlatformAccessory } from '../sensors/humiditySensorPlatformAccessory';
import { CarbonDioxideSensorPlatformAccessory } from '../sensors/carbonDioxideSensorPlatformAccessory';
import { AirQualitySensorPlatformAccessory } from '../sensors/airQualitySensorPlatformAccessory';
import { LeakSensorPlatformAccessory } from '../sensors/leakSensorPlatformAccessory';

export class BlindPlatformAccessory implements AccessoryPlugin {

Expand All @@ -13,6 +33,9 @@ export class BlindPlatformAccessory implements AccessoryPlugin {
private service: Service;
private information: Service;

private subs: any[];
public services: Service[];

private platform: any;
private device: any;
private pushButton: number;
Expand All @@ -31,8 +54,9 @@ export class BlindPlatformAccessory implements AccessoryPlugin {
};

name: string;
isParentAccessory: boolean;

constructor( api: API, platform: any, device: any ) {
constructor( api: API, platform: any, device: any, parent?: any ) {

this.name = device.name;
this.api = api;
Expand All @@ -41,11 +65,20 @@ export class BlindPlatformAccessory implements AccessoryPlugin {
this.pushButton = this.device.pushButton || this.platform.pushButton;
this.logging = this.device.logging || 0;

this.subs = [];
this.services = [];

this.isParentAccessory = false;

this.errorCheck();
this.currentPositionIsTargetPositionInLogo = this.checkPosition();

this.service = new this.api.hap.Service.WindowCovering(this.device.name);

if (parent) {
this.service.subtype = 'sub-' + this.model + "-" + this.name.replace(" ", "-");
}

this.service.getCharacteristic(this.platform.Characteristic.CurrentPosition)
.onGet(this.getCurrentPosition.bind(this));

Expand All @@ -62,6 +95,98 @@ export class BlindPlatformAccessory implements AccessoryPlugin {
.setCharacteristic(this.api.hap.Characteristic.SerialNumber, md5(this.device.name + this.model))
.setCharacteristic(this.api.hap.Characteristic.FirmwareRevision, this.platform.firmwareRevision);

const configDevices = this.platform.config.devices;
for (const dev of configDevices) {

if (dev.parentAccessory == this.name) {
this.isParentAccessory = true;

switch (dev.type) {
case Accessory.Switch:
this.subs.push( new SwitchPlatformAccessory(api, platform, dev, this) );
break;

case Accessory.Lightbulb:
this.subs.push( new LightbulbPlatformAccessory(api, platform, dev, this) );
break;

case Accessory.Blind:
this.subs.push( new BlindPlatformAccessory(api, platform, dev, this) );

case Accessory.Window:
this.subs.push( new WindowPlatformAccessory(api, platform, dev, this) );
break;

case Accessory.Garagedoor:
this.subs.push( new GaragedoorPlatformAccessory(api, platform, dev, this) );
break;

case Accessory.Thermostat:
this.subs.push( new ThermostatPlatformAccessory(api, platform, dev, this) );
break;

case Accessory.Fan:
this.subs.push( new FanPlatformAccessory(api, platform, dev, this) );
break;

case Accessory.FilterMaintenance:
this.subs.push( new FilterMaintenancePlatformAccessory(api, platform, dev, this) );
break;

case Accessory.Outlet:
this.subs.push( new OutletPlatformAccessory(api, platform, dev, this) );
break;

case Accessory.LightSensor:
this.subs.push( new LightSensorPlatformAccessory(api, platform, dev, this) );
break;

case Accessory.MotionSensor:
this.subs.push( new MotionSensorPlatformAccessory(api, platform, dev, this) );
break;

case Accessory.ContactSensor:
this.subs.push( new ContactSensorPlatformAccessory(api, platform, dev, this) );
break;

case Accessory.SmokeSensor:
this.subs.push( new SmokeSensorPlatformAccessory(api, platform, dev, this) );
break;

case Accessory.TemperatureSensor:
this.subs.push( new TemperatureSensorPlatformAccessory(api, platform, dev, this) );
break;

case Accessory.HumiditySensor:
this.subs.push( new HumiditySensorPlatformAccessory(api, platform, dev, this) );
break;

case Accessory.CarbonDioxideSensor:
this.subs.push( new CarbonDioxideSensorPlatformAccessory(api, platform, dev, this) );
break;

case Accessory.AirQualitySensor:
this.subs.push( new AirQualitySensorPlatformAccessory(api, platform, dev, this) );
break;

case Accessory.LeakSensor:
this.subs.push( new LeakSensorPlatformAccessory(api, platform, dev, this) );
break;
}
}
}

if (this.isParentAccessory == true) {
this.service.subtype = 'main-' + this.model + "-" + this.name.replace(" ", "-");
}

this.services.push(this.service, this.information);

if (parent) {
parent.service.addLinkedService(this.service);
parent.services.push(this.service);
}

this.updateCurrentPositionAndTargetPositionQueued = false;
this.updateCurrentPositionQueued = false;
this.updateTargetPositionQueued = false;
Expand Down Expand Up @@ -102,7 +227,7 @@ export class BlindPlatformAccessory implements AccessoryPlugin {
}

getServices(): Service[] {
return [ this.information, this.service ];
return this.services;
}

async setTargetPosition(value: CharacteristicValue) {
Expand Down

0 comments on commit 810f9b7

Please sign in to comment.