Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix HMIPW-DRD3 Multi accessory #353

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions create-todo.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ const fs = require('fs');

const dir = fs.readdirSync('./homematic-devices');

dir.forEach(file => {
if (file.match(/h.*-.*\.js/)) {
const len = fs.readFileSync('./homematic-devices/' + file).toString().split('\n').length;
if (len > 4) {
for (const file of dir) {
if (/h.*-.*\.js/.test(file)) {
const {length} = fs.readFileSync('./homematic-devices/' + file).toString().split('\n');
if (length > 4) {
console.log('- [ ] ' + file.replace('.js', ''));
}
}
});
}
2 changes: 1 addition & 1 deletion homematic-devices/hb-lc-bl1pbu-fm.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = require('./hm-lc-bl1pbu-fm');
module.exports = require('./hm-lc-bl1pbu-fm.js');
2 changes: 1 addition & 1 deletion homematic-devices/hb-lc-sw1pbu-fm.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = require('./lib/generic-switch');
module.exports = require('./lib/generic-switch.js');
2 changes: 1 addition & 1 deletion homematic-devices/hb-lc-sw2-fm.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = require('./lib/generic-switch');
module.exports = require('./lib/generic-switch.js');
2 changes: 1 addition & 1 deletion homematic-devices/hb-lc-sw2pbu-fm.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = require('./lib/generic-switch');
module.exports = require('./lib/generic-switch.js');
6 changes: 2 additions & 4 deletions homematic-devices/hb-uni-dmx-master.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const Accessory = require('./lib/accessory');
const Accessory = require('./lib/accessory.js');

module.exports = class HmUniDmx extends Accessory {
init(config, node) {
Expand All @@ -13,9 +13,7 @@ module.exports = class HmUniDmx extends Accessory {
const ch = config.description.ADDRESS + ':' + i;
const service = this.addService('Switch', ccu.channelNames[ch]);

service.get('On', () => {
return false;
});
service.get('On', () => false);
service.set('On', (value, callback) => {
if (value) {
ccu.setValue(config.iface, ch, 'PRESS_SHORT', true)
Expand Down
2 changes: 1 addition & 1 deletion homematic-devices/hb-uni-rgb-led-ctrl.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = require('./hm-lc-rgbw-wm');
module.exports = require('./hm-lc-rgbw-wm.js');
10 changes: 3 additions & 7 deletions homematic-devices/hb-uni-sen-press-sc.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
const Accessory = require('./lib/accessory');
const Accessory = require('./lib/accessory.js');

module.exports = class HbUniSenPress extends Accessory {
init(config) {
this.addService('ContactSensor', config.name)
.get('ContactSensorState', config.deviceAddress + ':2.STATE', (value, c) => {
return value ? c.CONTACT_NOT_DETECTED : c.CONTACT_DETECTED;
})
.get('ContactSensorState', config.deviceAddress + ':2.STATE', (value, c) => value ? c.CONTACT_NOT_DETECTED : c.CONTACT_DETECTED)

.get('StatusLowBattery', config.deviceAddress + ':0.LOWBAT', (value, c) => {
return value ? c.BATTERY_LEVEL_LOW : c.BATTERY_LEVEL_NORMAL;
});
.get('StatusLowBattery', config.deviceAddress + ':0.LOWBAT', (value, c) => value ? c.BATTERY_LEVEL_LOW : c.BATTERY_LEVEL_NORMAL);
}
};
7 changes: 3 additions & 4 deletions homematic-devices/hb-uni-sen-temp-ds18b20.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const Accessory = require('./lib/accessory');
const Accessory = require('./lib/accessory.js');

// eslint-disable-next-line unicorn/prevent-abbreviations
module.exports = class HbUniSenTemp extends Accessory {
init(config, node) {
const {ccu} = node;
Expand All @@ -17,9 +18,7 @@ module.exports = class HbUniSenTemp extends Accessory {
this.addService('TemperatureSensor', name)
.setProps('CurrentTemperature', {minValue: -150, maxValue: 150})
.get('CurrentTemperature', dp)
.get('StatusLowBattery', config.deviceAddress + ':0.LOWBAT', (value, c) => {
return value ? c.BATTERY_LEVEL_LOW : c.BATTERY_LEVEL_NORMAL;
});
.get('StatusLowBattery', config.deviceAddress + ':0.LOWBAT', (value, c) => value ? c.BATTERY_LEVEL_LOW : c.BATTERY_LEVEL_NORMAL);
}
}
};
7 changes: 3 additions & 4 deletions homematic-devices/hb-uni-sen-temp-ir.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const Accessory = require('./lib/accessory');
const Accessory = require('./lib/accessory.js');

// eslint-disable-next-line unicorn/prevent-abbreviations
module.exports = class HbUniSenTemp extends Accessory {
init(config, node) {
const {ccu} = node;
Expand All @@ -18,9 +19,7 @@ module.exports = class HbUniSenTemp extends Accessory {
this.addService('TemperatureSensor', name)
.setProps('CurrentTemperature', {minValue: -450, maxValue: 450})
.get('CurrentTemperature', dp)
.get('StatusLowBattery', config.deviceAddress + ':0.LOWBAT', (value, c) => {
return value ? c.BATTERY_LEVEL_LOW : c.BATTERY_LEVEL_NORMAL;
});
.get('StatusLowBattery', config.deviceAddress + ':0.LOWBAT', (value, c) => value ? c.BATTERY_LEVEL_LOW : c.BATTERY_LEVEL_NORMAL);
}
}
};
2 changes: 1 addition & 1 deletion homematic-devices/hb-uni-sen-wea.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const Accessory = require('./lib/accessory');
const Accessory = require('./lib/accessory.js');

module.exports = class HbUniSenWea extends Accessory {
init(config) {
Expand Down
12 changes: 4 additions & 8 deletions homematic-devices/hb-uni-senact-4-4-rc-bat.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const Accessory = require('./lib/accessory');
const Accessory = require('./lib/accessory.js');

module.exports = class HbUniSenAct extends Accessory {
init(config, node) {
Expand All @@ -19,13 +19,9 @@ module.exports = class HbUniSenAct extends Accessory {
.set('On', dp);
}

this.addService('BatteryService')
.get('StatusLowBattery', config.deviceAddress + ':0.LOWBAT', (value, c) => {
return value ? c.BATTERY_LEVEL_LOW : c.BATTERY_LEVEL_NORMAL;
})
.get('BatteryLevel', config.deviceAddress + ':0.LOWBAT', value => {
return value ? 0 : 100;
})
this.addService('Battery')
.get('StatusLowBattery', config.deviceAddress + ':0.LOWBAT', (value, c) => value ? c.BATTERY_LEVEL_LOW : c.BATTERY_LEVEL_NORMAL)
.get('BatteryLevel', config.deviceAddress + ':0.LOWBAT', value => value ? 0 : 100)
.update('ChargingState', 2);
}
};
2 changes: 1 addition & 1 deletion homematic-devices/hb-uni-senact-4-4-rc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const Accessory = require('./lib/accessory');
const Accessory = require('./lib/accessory.js');

module.exports = class HbUniSenAct extends Accessory {
init(config, node) {
Expand Down
16 changes: 5 additions & 11 deletions homematic-devices/hb-uni-senact-4-4-sc-bat.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const Accessory = require('./lib/accessory');
const Accessory = require('./lib/accessory.js');

module.exports = class HbUniSenAct extends Accessory {
init(config, node) {
Expand Down Expand Up @@ -28,18 +28,12 @@ module.exports = class HbUniSenAct extends Accessory {
const dp = config.iface + '.' + channels[i] + '.STATE';

this.addService('ContactSensor', name)
.get('ContactSensorState', dp, (value, c) => {
return value ? c.CONTACT_NOT_DETECTED : c.CONTACT_DETECTED;
});
.get('ContactSensorState', dp, (value, c) => value ? c.CONTACT_NOT_DETECTED : c.CONTACT_DETECTED);
}

this.addService('BatteryService')
.get('StatusLowBattery', config.deviceAddress + ':0.LOWBAT', (value, c) => {
return value ? c.BATTERY_LEVEL_LOW : c.BATTERY_LEVEL_NORMAL;
})
.get('BatteryLevel', config.deviceAddress + ':0.LOWBAT', value => {
return value ? 0 : 100;
})
this.addService('Battery')
.get('StatusLowBattery', config.deviceAddress + ':0.LOWBAT', (value, c) => value ? c.BATTERY_LEVEL_LOW : c.BATTERY_LEVEL_NORMAL)
.get('BatteryLevel', config.deviceAddress + ':0.LOWBAT', value => value ? 0 : 100)
.update('ChargingState', 2);
}
};
6 changes: 2 additions & 4 deletions homematic-devices/hb-uni-senact-4-4-sc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const Accessory = require('./lib/accessory');
const Accessory = require('./lib/accessory.js');

module.exports = class HbUniSenAct extends Accessory {
init(config, node) {
Expand Down Expand Up @@ -28,9 +28,7 @@ module.exports = class HbUniSenAct extends Accessory {
const dp = config.iface + '.' + channels[i] + '.STATE';

this.addService('ContactSensor', name)
.get('ContactSensorState', dp, (value, c) => {
return value ? c.CONTACT_NOT_DETECTED : c.CONTACT_DETECTED;
});
.get('ContactSensorState', dp, (value, c) => value ? c.CONTACT_NOT_DETECTED : c.CONTACT_DETECTED);
}
}
};
12 changes: 4 additions & 8 deletions homematic-devices/hb-uni-senact-8-8-rc-bat.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const Accessory = require('./lib/accessory');
const Accessory = require('./lib/accessory.js');

module.exports = class HbUniSenAct extends Accessory {
init(config, node) {
Expand All @@ -19,13 +19,9 @@ module.exports = class HbUniSenAct extends Accessory {
.set('On', dp);
}

this.addService('BatteryService')
.get('StatusLowBattery', config.deviceAddress + ':0.LOWBAT', (value, c) => {
return value ? c.BATTERY_LEVEL_LOW : c.BATTERY_LEVEL_NORMAL;
})
.get('BatteryLevel', config.deviceAddress + ':0.LOWBAT', value => {
return value ? 0 : 100;
})
this.addService('Battery')
.get('StatusLowBattery', config.deviceAddress + ':0.LOWBAT', (value, c) => value ? c.BATTERY_LEVEL_LOW : c.BATTERY_LEVEL_NORMAL)
.get('BatteryLevel', config.deviceAddress + ':0.LOWBAT', value => value ? 0 : 100)
.update('ChargingState', 2);
}
};
2 changes: 1 addition & 1 deletion homematic-devices/hb-uni-senact-8-8-rc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const Accessory = require('./lib/accessory');
const Accessory = require('./lib/accessory.js');

module.exports = class HbUniSenAct extends Accessory {
init(config, node) {
Expand Down
16 changes: 5 additions & 11 deletions homematic-devices/hb-uni-senact-8-8-sc-bat.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const Accessory = require('./lib/accessory');
const Accessory = require('./lib/accessory.js');

module.exports = class HbUniSenAct extends Accessory {
init(config, node) {
Expand Down Expand Up @@ -28,18 +28,12 @@ module.exports = class HbUniSenAct extends Accessory {
const dp = config.iface + '.' + channels[i] + '.STATE';

this.addService('ContactSensor', name)
.get('ContactSensorState', dp, (value, c) => {
return value ? c.CONTACT_NOT_DETECTED : c.CONTACT_DETECTED;
});
.get('ContactSensorState', dp, (value, c) => value ? c.CONTACT_NOT_DETECTED : c.CONTACT_DETECTED);
}

this.addService('BatteryService')
.get('StatusLowBattery', config.deviceAddress + ':0.LOWBAT', (value, c) => {
return value ? c.BATTERY_LEVEL_LOW : c.BATTERY_LEVEL_NORMAL;
})
.get('BatteryLevel', config.deviceAddress + ':0.LOWBAT', value => {
return value ? 0 : 100;
})
this.addService('Battery')
.get('StatusLowBattery', config.deviceAddress + ':0.LOWBAT', (value, c) => value ? c.BATTERY_LEVEL_LOW : c.BATTERY_LEVEL_NORMAL)
.get('BatteryLevel', config.deviceAddress + ':0.LOWBAT', value => value ? 0 : 100)
.update('ChargingState', 2);
}
};
6 changes: 2 additions & 4 deletions homematic-devices/hb-uni-senact-8-8-sc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const Accessory = require('./lib/accessory');
const Accessory = require('./lib/accessory.js');

module.exports = class HbUniSenAct extends Accessory {
init(config, node) {
Expand Down Expand Up @@ -28,9 +28,7 @@ module.exports = class HbUniSenAct extends Accessory {
const dp = config.iface + '.' + channels[i] + '.STATE';

this.addService('ContactSensor', name)
.get('ContactSensorState', dp, (value, c) => {
return value ? c.CONTACT_NOT_DETECTED : c.CONTACT_DETECTED;
});
.get('ContactSensorState', dp, (value, c) => value ? c.CONTACT_NOT_DETECTED : c.CONTACT_DETECTED);
}
}
};
2 changes: 1 addition & 1 deletion homematic-devices/hm-cc-rt-dn-bom.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = require('./hm-cc-rt-dn');
module.exports = require('./hm-cc-rt-dn.js');
12 changes: 4 additions & 8 deletions homematic-devices/hm-cc-rt-dn.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const Accessory = require('./lib/accessory');
const Accessory = require('./lib/accessory.js');

module.exports = class HmCcRtDn extends Accessory {
init(config, node) {
Expand Down Expand Up @@ -121,10 +121,8 @@ module.exports = class HmCcRtDn extends Accessory {
updateHeatingCoolingState();
});

this.addService('BatteryService', config.name)
.get('StatusLowBattery', config.deviceAddress + ':0.LOWBAT', (value, c) => {
return value ? c.BATTERY_LEVEL_LOW : c.BATTERY_LEVEL_NORMAL;
})
this.addService('Battery', config.name)
.get('StatusLowBattery', config.deviceAddress + ':0.LOWBAT', (value, c) => value ? c.BATTERY_LEVEL_LOW : c.BATTERY_LEVEL_NORMAL)
.get('BatteryLevel', config.deviceAddress + ':4.BATTERY_STATE', this.percent)
.update('ChargingState', 2);

Expand Down Expand Up @@ -165,9 +163,7 @@ module.exports = class HmCcRtDn extends Accessory {
});
}
})
.get('On', config.deviceAddress + ':4.CONTROL_MODE', value => {
return value === 3;
});
.get('On', config.deviceAddress + ':4.CONTROL_MODE', value => value === 3);
}
}
};
6 changes: 2 additions & 4 deletions homematic-devices/hm-cc-scd.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
const Accessory = require('./lib/accessory');
const Accessory = require('./lib/accessory.js');

module.exports = class HmCcScd extends Accessory {
init(config) {
this.addService('CarbonDioxideSensor', config.name)
.get('CarbonDioxideDetected', config.deviceAddress + ':1.STATE', (value, c) => {
return value > 0 ? c.CO2_LEVELS_ABNORMAL : c.CO2_LEVELS_NORMAL;
});
.get('CarbonDioxideDetected', config.deviceAddress + ':1.STATE', (value, c) => value > 0 ? c.CO2_LEVELS_ABNORMAL : c.CO2_LEVELS_NORMAL);
}
};
16 changes: 5 additions & 11 deletions homematic-devices/hm-cc-tc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const Accessory = require('./lib/accessory');
const Accessory = require('./lib/accessory.js');

module.exports = class HmCcTc extends Accessory {
init(config, node) {
Expand Down Expand Up @@ -71,22 +71,16 @@ module.exports = class HmCcTc extends Accessory {
});
}

this.addService('BatteryService', config.name)
.get('StatusLowBattery', config.deviceAddress + ':0.LOWBAT', (value, c) => {
return value ? c.BATTERY_LEVEL_LOW : c.BATTERY_LEVEL_NORMAL;
})
.get('BatteryLevel', config.deviceAddress + ':0.LOWBAT', value => {
return value ? 0 : 100;
})
this.addService('Battery', config.name)
.get('StatusLowBattery', config.deviceAddress + ':0.LOWBAT', (value, c) => value ? c.BATTERY_LEVEL_LOW : c.BATTERY_LEVEL_NORMAL)
.get('BatteryLevel', config.deviceAddress + ':0.LOWBAT', value => value ? 0 : 100)
.update('ChargingState', 2);

if (this.option('HumiditySensor')) {
this.addService('HumiditySensor', config.name)
.get('CurrentRelativeHumidity', config.deviceAddress + ':1.HUMIDITY')

.get('StatusLowBattery', config.deviceAddress + ':0.LOWBAT', (value, c) => {
return value ? c.BATTERY_LEVEL_LOW : c.BATTERY_LEVEL_NORMAL;
});
.get('StatusLowBattery', config.deviceAddress + ':0.LOWBAT', (value, c) => value ? c.BATTERY_LEVEL_LOW : c.BATTERY_LEVEL_NORMAL);
}
}
};
Loading