Skip to content

Commit

Permalink
hmip-fsm/-fsm16 service type (#191)
Browse files Browse the repository at this point in the history
  • Loading branch information
hobbyquaker committed Nov 15, 2019
1 parent 92f9d36 commit 3b7242a
Showing 1 changed file with 39 additions and 5 deletions.
44 changes: 39 additions & 5 deletions homematic-devices/hmip-fsm.js
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);
}
}
};

0 comments on commit 3b7242a

Please sign in to comment.