generated from homebridge/homebridge-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added new service WindowCovering and corresponding characteristics
Improved validity checks for state-characteristics on data passed to homekit by characteristics
- Loading branch information
Showing
10 changed files
with
150 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { HomeServerConnector } from '../hs'; | ||
import { API } from 'homebridge'; | ||
|
||
import { HsdPlatformAccessory } from '../hsdPlatformAccessory'; | ||
import { addCurrentPositionCharacteristic } from './characteristic/CurrentPosition'; | ||
import { addPositionStateCharacteristic } from './characteristic/PositionState'; | ||
import { addTargetPositionCharacteristic } from './characteristic/TargetPosition'; | ||
import { addObstructionDetectedCharacteristic } from './characteristic/ObstructionDetected'; | ||
import { addHoldPositionCharacteristic } from './characteristic/HoldPosition'; | ||
import { HsdServiceConfig } from '../config'; | ||
import { AbstractHsdService } from './AbstractHsdService'; | ||
// import { addListener } from 'process'; | ||
|
||
export class WindowCovering extends AbstractHsdService { | ||
|
||
public constructor (api: API, hsd: HomeServerConnector, accessory: HsdPlatformAccessory, config: HsdServiceConfig) { | ||
super(api, hsd, accessory, config); | ||
|
||
const service = this.getService(this.api.hap.Service.Window); | ||
//service.setCharacteristic(this.api.hap.Service.name, config.serviceName); | ||
|
||
for (const characteristic of config.characteristics) { | ||
if (characteristic.characteristicName === 'CurrentPosition') { | ||
addCurrentPositionCharacteristic(api, service, hsd, characteristic.endpoints[0]); | ||
} else if (characteristic.characteristicName === 'PositionState') { | ||
addPositionStateCharacteristic(api, service, hsd, characteristic.endpoints[0]); | ||
} else if (characteristic.characteristicName === 'TargetPosition') { | ||
addTargetPositionCharacteristic(api, service, hsd, characteristic.endpoints[0], characteristic.endpoints[1]); | ||
} else if (characteristic.characteristicName === 'ObstructionDetected') { | ||
addObstructionDetectedCharacteristic(api, service, hsd, characteristic.endpoints[0]); | ||
} else if (characteristic.characteristicName === 'HoldPosition') { | ||
addHoldPositionCharacteristic(api, service, hsd, characteristic.endpoints[0]); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { API, Service } from 'homebridge'; | ||
import { HomeServerConnector } from '../../hs'; | ||
|
||
export const addHoldPositionCharacteristic = (api: API, | ||
service: Service, | ||
hsd: HomeServerConnector, | ||
setEndpoint: string): void => { | ||
|
||
const holdPosition = service.getCharacteristic(api.hap.Characteristic.HoldPosition); | ||
|
||
// Add subscription | ||
hsd.addListener(reading => { | ||
holdPosition.updateValue(Boolean(reading)); | ||
}, setEndpoint); | ||
|
||
holdPosition.onSet(async hold => { | ||
hsd.setCo(setEndpoint, Boolean(hold)); | ||
}); | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters