-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
92f9d36
commit 3b7242a
Showing
1 changed file
with
39 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,43 @@ | ||
const Accessory = require('./lib/accessory'); | ||
|
||
module.exports = class HmipBsm extends Accessory { | ||
init(config) { | ||
this.addService('Switch', config.name) | ||
.get('On', config.deviceAddress + ':2.STATE') | ||
.set('On', config.deviceAddress + ':2.STATE'); | ||
module.exports = class HmipFsm extends Accessory { | ||
init(config, node) { | ||
const {ccu} = node; | ||
const dp = config.deviceAddress + ':2.STATE'; | ||
const name = ccu.channelNames[config.deviceAddress + ':2']; | ||
const type = this.option('2', 'type') || 'Outlet'; | ||
|
||
switch (type) { | ||
case 'ValveIrrigation': | ||
// intentional fallthrough | ||
case 'Valve': { | ||
const service = this.addService('Valve', name, type); | ||
|
||
service.update('ValveType', type === 'ValveIrrigation' ? 1 : 0); | ||
|
||
service | ||
.get('Active', dp, val => val ? 1 : 0) | ||
.get('InUse', dp, val => val ? 1 : 0) | ||
.set('Active', dp, val => { | ||
service.update('InUse', val); | ||
return Boolean(val); | ||
}); | ||
break; | ||
} | ||
|
||
case 'Lightbulb': | ||
// intentional fallthrough | ||
case 'Fan': | ||
// intentional fallthrough | ||
case 'Outlet': | ||
this.addService(type, name, type) | ||
.get('On', dp) | ||
.set('On', dp); | ||
break; | ||
default: | ||
this.addService('Switch', name) | ||
.get('On', dp) | ||
.set('On', dp); | ||
} | ||
} | ||
}; |