forked from LRuesink-WebArray/homey-matic
-
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.
- Loading branch information
Showing
9 changed files
with
649 additions
and
12 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,88 @@ | ||
'use strict'; | ||
|
||
const Device = require('../../lib/device.js'); | ||
const capabilityMap = { | ||
"onoff.channel2": { channel: 2, key: "STATE", set: { key: "STATE", channel: 2 } }, | ||
"onoff.channel3": { channel: 3, key: "STATE", set: { key: "STATE", channel: 3 } }, | ||
"onoff.channel4": { channel: 4, key: "STATE", set: { key: "STATE", channel: 4 } }, | ||
"onoff.channel6": { channel: 6, key: "STATE", set: { key: "STATE", channel: 6 } }, | ||
"onoff.channel7": { channel: 7, key: "STATE", set: { key: "STATE", channel: 7 } }, | ||
"onoff.channel8": { channel: 8, key: "STATE", set: { key: "STATE", channel: 8 } }, | ||
"dim": { channel: 11, key: "LEVEL", set: { key: "LEVEL", channel: 11 } }, | ||
}; | ||
|
||
class HomematicDevice extends Device { | ||
|
||
// Define a getter for the channels to avoid duplication | ||
get channels() { | ||
return [ | ||
{ id: "onoff.channel2", showKey: "ShowButtonChannel2", titleKey: "TitleButtonChannel2" }, | ||
{ id: "onoff.channel3", showKey: "ShowButtonChannel3", titleKey: "TitleButtonChannel3" }, | ||
{ id: "onoff.channel4", showKey: "ShowButtonChannel4", titleKey: "TitleButtonChannel4" }, | ||
{ id: "onoff.channel6", showKey: "ShowButtonChannel6", titleKey: "TitleButtonChannel6" }, | ||
{ id: "onoff.channel7", showKey: "ShowButtonChannel7", titleKey: "TitleButtonChannel7" }, | ||
{ id: "onoff.channel8", showKey: "ShowButtonChannel8", titleKey: "TitleButtonChannel8" }, | ||
]; | ||
} | ||
|
||
async onInit() { | ||
super.onInit(capabilityMap); | ||
|
||
const settings = this.getSettings(); | ||
|
||
// Configure each channel | ||
for (const channel of this.channels) { | ||
await this.configureChannel(channel, settings); | ||
} | ||
|
||
// Configure dimmer | ||
await this.configureDimmer(settings); | ||
} | ||
|
||
async onSettings({ oldSettings, newSettings, changedKeys }) { | ||
const quickActionChanged = changedKeys.includes("QuickActionChannel"); | ||
|
||
for (const channel of this.channels) { | ||
if ( | ||
quickActionChanged || // Reconfigure all channels if the quick action was changed | ||
changedKeys.includes(channel.showKey) || | ||
changedKeys.includes(channel.titleKey) | ||
) { | ||
await this.configureChannel(channel, newSettings); | ||
} | ||
} | ||
|
||
// Handle dimmer settings change | ||
if (changedKeys.includes("ShowDimmer") || changedKeys.includes("TitleDimmer")) { | ||
await this.configureDimmer(newSettings); | ||
} | ||
} | ||
|
||
async configureChannel(channel, settings) { | ||
const { id, showKey, titleKey } = channel; | ||
const isQuickAction = settings.QuickActionChannel === id; | ||
|
||
if (!settings[showKey]) { | ||
await this.setCapabilityOptions(id, { uiComponent: null, uiQuickAction: isQuickAction }); | ||
} else { | ||
await this.setCapabilityOptions(id, { | ||
uiComponent: "toggle", | ||
title: settings[titleKey], | ||
uiQuickAction: isQuickAction, | ||
}); | ||
} | ||
} | ||
|
||
async configureDimmer(settings) { | ||
if (!settings.ShowDimmer) { | ||
await this.setCapabilityOptions("dim", { uiComponent: null }); | ||
} else { | ||
await this.setCapabilityOptions("dim", { | ||
uiComponent: "slider", | ||
title: settings.TitleDimmer, | ||
}); | ||
} | ||
} | ||
} | ||
|
||
module.exports = HomematicDevice; |
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,280 @@ | ||
{ | ||
"id": "HmIP-MIOB", | ||
"name": { | ||
"en": "HmIP-MIOB" | ||
}, | ||
"class": "socket", | ||
"capabilities": [], | ||
"capabilitiesOptions": { | ||
"onoff.channel2": { | ||
"title": "Schalter Kanal 2" | ||
}, | ||
"onoff.channel3": { | ||
"title": "Schalter Kanal 3" | ||
}, | ||
"onoff.channel4": { | ||
"title": "Schalter Kanal 4" | ||
}, | ||
"onoff.channel6": { | ||
"title": "Schalter Kanal 6" | ||
}, | ||
"onoff.channel7": { | ||
"title": "Schalter Kanal 7" | ||
}, | ||
"onoff.channel8": { | ||
"title": "Schalter Kanal 8" | ||
}, | ||
"dim": { | ||
"title": "Regler" | ||
} | ||
}, | ||
"images": { | ||
"large": "/drivers/HmIP-MIOB/assets/images/large.png", | ||
"small": "/drivers/HmIP-MIOB/assets/images/small.png" | ||
}, | ||
"pair": [ | ||
{ | ||
"id": "list_bridges", | ||
"template": "list_devices", | ||
"options": { | ||
"singular": true | ||
}, | ||
"navigation": { | ||
"next": "list_devices" | ||
} | ||
}, | ||
{ | ||
"id": "list_devices", | ||
"template": "list_devices", | ||
"navigation": { | ||
"next": "add_devices" | ||
} | ||
}, | ||
{ | ||
"id": "add_devices", | ||
"template": "add_devices" | ||
} | ||
], | ||
"settings": [ | ||
{ | ||
"type": "group", | ||
"label": { | ||
"en": "Device data" | ||
}, | ||
"children": [ | ||
{ | ||
"id": "app", | ||
"type": "label", | ||
"label": { | ||
"en": "App" | ||
}, | ||
"value": "Homematic" | ||
}, | ||
{ | ||
"id": "driver", | ||
"type": "label", | ||
"label": { | ||
"en": "Driver" | ||
}, | ||
"value": "", | ||
"hint": { | ||
"en": "In most cases the driver name is the same as the device type, but some drivers support multiple device types. In those cases they might not match." | ||
} | ||
}, | ||
{ | ||
"id": "address", | ||
"type": "label", | ||
"label": { | ||
"en": "Device Address" | ||
}, | ||
"value": "" | ||
}, | ||
{ | ||
"id": "ccuIP", | ||
"type": "label", | ||
"label": { | ||
"en": "CCU IP" | ||
}, | ||
"value": "" | ||
}, | ||
{ | ||
"id": "ccuSerial", | ||
"type": "text", | ||
"label": { | ||
"en": "CCU Serial" | ||
}, | ||
"value": "" | ||
} | ||
] | ||
}, | ||
{ | ||
"type": "group", | ||
"label": { | ||
"en": "Device settings" | ||
}, | ||
"children": [ | ||
{ | ||
"id": "ShowButtonChannel2", | ||
"type": "checkbox", | ||
"label": { | ||
"en": "Show Button Channel 2" | ||
}, | ||
"value": true | ||
}, | ||
{ | ||
"id": "TitleButtonChannel2", | ||
"type": "text", | ||
"label": { | ||
"en": "Title Button Channel 2" | ||
}, | ||
"value": "Schalter Kanal 2" | ||
}, | ||
{ | ||
"id": "ShowButtonChannel3", | ||
"type": "checkbox", | ||
"label": { | ||
"en": "Show Button Channel 3" | ||
}, | ||
"value": true | ||
}, | ||
{ | ||
"id": "TitleButtonChannel3", | ||
"type": "text", | ||
"label": { | ||
"en": "Title Button Channel 3" | ||
}, | ||
"value": "Schalter Kanal 3" | ||
}, | ||
{ | ||
"id": "ShowButtonChannel4", | ||
"type": "checkbox", | ||
"label": { | ||
"en": "Show Button Channel 4" | ||
}, | ||
"value": true | ||
}, | ||
{ | ||
"id": "TitleButtonChannel4", | ||
"type": "text", | ||
"label": { | ||
"en": "Title Button Channel 4" | ||
}, | ||
"value": "Schalter Kanal 4" | ||
}, | ||
{ | ||
"id": "ShowButtonChannel6", | ||
"type": "checkbox", | ||
"label": { | ||
"en": "Show Button Channel 6" | ||
}, | ||
"value": true | ||
}, | ||
{ | ||
"id": "TitleButtonChannel6", | ||
"type": "text", | ||
"label": { | ||
"en": "Title Button Channel 6" | ||
}, | ||
"value": "Schalter Kanal 6" | ||
}, | ||
{ | ||
"id": "ShowButtonChannel7", | ||
"type": "checkbox", | ||
"label": { | ||
"en": "Show Button Channel 7" | ||
}, | ||
"value": true | ||
}, | ||
{ | ||
"id": "TitleButtonChannel7", | ||
"type": "text", | ||
"label": { | ||
"en": "Title Button Channel 7" | ||
}, | ||
"value": "Schalter Kanal 7" | ||
}, | ||
{ | ||
"id": "ShowButtonChannel8", | ||
"type": "checkbox", | ||
"label": { | ||
"en": "Show Button Channel 8" | ||
}, | ||
"value": true | ||
}, | ||
{ | ||
"id": "TitleButtonChannel8", | ||
"type": "text", | ||
"label": { | ||
"en": "Title Button Channel 8" | ||
}, | ||
"value": "Schalter Kanal 8" | ||
}, | ||
{ | ||
"id": "ShowDimmer", | ||
"type": "checkbox", | ||
"label": { | ||
"en": "Show Dimmer" | ||
}, | ||
"value": true | ||
}, | ||
{ | ||
"id": "TitleDimmer", | ||
"type": "text", | ||
"label": { | ||
"en": "Title Dimmer" | ||
}, | ||
"value": "Regler" | ||
}, | ||
{ | ||
"id": "QuickActionChannel", | ||
"type": "dropdown", | ||
"label": { | ||
"en": "Quick Action Channel" | ||
}, | ||
"hint": { | ||
"en": "Select which channel should have the Quick Action button." | ||
}, | ||
"value": "onoff.channel2", | ||
"values": [ | ||
{ | ||
"id": "onoff.channel2", | ||
"label": { | ||
"en": "Channel 2" | ||
} | ||
}, | ||
{ | ||
"id": "onoff.channel3", | ||
"label": { | ||
"en": "Channel 3" | ||
} | ||
}, | ||
{ | ||
"id": "onoff.channel4", | ||
"label": { | ||
"en": "Channel 4" | ||
} | ||
}, | ||
{ | ||
"id": "onoff.channel6", | ||
"label": { | ||
"en": "Channel 6" | ||
} | ||
}, | ||
{ | ||
"id": "onoff.channel7", | ||
"label": { | ||
"en": "Channel 7" | ||
} | ||
}, | ||
{ | ||
"id": "onoff.channel8", | ||
"label": { | ||
"en": "Channel 8" | ||
} | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} |
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,26 @@ | ||
'use strict'; | ||
|
||
const Homey = require('homey'); | ||
const Driver = require('../../lib/driver.js'); | ||
|
||
class HomematicDriver extends Driver { | ||
|
||
onInit() { | ||
super.onInit(); | ||
this.capabilities = [ | ||
'onoff.channel2', | ||
'onoff.channel3', | ||
'onoff.channel4', | ||
'onoff.channel6', | ||
'onoff.channel7', | ||
'onoff.channel8', | ||
'dim' | ||
] | ||
this.homematicTypes = ['HmIP-MIOB']; | ||
this.log(this.homematicTypes.join(','), 'has been inited'); | ||
} | ||
|
||
|
||
} | ||
|
||
module.exports = HomematicDriver; |
Oops, something went wrong.