-
Notifications
You must be signed in to change notification settings - Fork 4
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
Farbtemperatur LED/Panel steuern #54
Comments
In meine FORK ist der Handler 'CTLight.js' zu finden. Damit lässt sich die Farbtemperatur in Kelvin einstellen, allerdings wurde der Pull request node-eibd für DPT7 von @farmio noch nich angenommen. Gruß, |
Ist er jetzt schon. |
Ich wäre auch sehr interessiert an der Steuerung von TunableWhite Leuchten - ich habe deinen Handler kopiert und die entsprechenden Zeilen in mein config file kopiert, allerdings bekomme ich dann folgenden Fehler:
ich nutze knxd als Schnittstelle zum KNX-Bus. Müsste es mit diesem Plugin nicht gehen? |
Da der Handler von @slev1n bei mir nicht richtig funktionierte, habe ich für meine LED Controller (MDT AKD-0xxx) kurzerhand selbst einen Custom Handler geschrieben, den ich mich euch teilen möchte: Custom Handler for Tunable White Lights - CWWW.js /* Lightbulb extension for Tunable White Lights
* Infos:
* - used in combination with KNX LED-Controller MDT AKD-0xxx
* - controls the "absolute" adresses for brightness and color temperature in percent [DPT5.001]
* Issues:
* - The LED-Controller offers smooth switch on and off effects for HCL-Mode (Human Centered Lighting). However, it also sends the current brightness value during that, which triggers the handler to adjust the brightness
* --> Workaround: Deactivate status information during HCL changes.
*/
/* jshint esversion: 6, strict: true, node: true */
'use strict';
/**
* @type {./handlerpattern.js~HandlerPattern}
*/
var HandlerPattern = require('./handlerpattern.js');
var log = require('debug')('CWWW');
/**
* @classdesc A custom handler for light apperatures with tunable white functionality
* @extends HandlerPattern
*/
class CWWW extends HandlerPattern {
/****
* onKNXValueChange is invoked if a Bus value for one of the bound addresses is received
*
*/
onKNXValueChange(field, oldValue, knxValue) {
log('INFO: onKNXValueChange(' + field + ", " + oldValue + ", " + knxValue + ")");
switch (field) {
case "On":
this.myAPI.setValue(field, knxValue); // knxValue: values either 0 or 1
break;
case "Brightness":
this.myAPI.setValue(field, knxValue/255*100); // knxValue: values between 0-255
break;
case "ColorTemperature":
let currentwhite_M = this.convertBetweenMiredandAbsolute(knxValue) // knxValue: values between 0-255
this.myAPI.setValue(field, currentwhite_M);
break;
}
}
convertBetweenMiredandAbsolute(value) {
// K=Kelvin, M=Mired
var warmwhite_K = this.myAPI.getLocalConstant("max_warmwhite");
var coldwhite_K = this.myAPI.getLocalConstant("max_coldwhite");
var currentwhite_K = ((value/255)*(coldwhite_K - warmwhite_K)) + warmwhite_K;
var currentwhite_M = (Math.pow(10, 6) / currentwhite_K)
return currentwhite_M;
}
// onBusValueChange
/* ********************************************************************************************************************** */
/****
* onHKValueChange is invoked if HomeKit is changing characteristic values
*
*/
onHKValueChange(field, oldValue, newValue) {
log('INFO: onHKValueChange(' + field + ", " + oldValue + ", " + newValue + ")");
switch (field) {
case "On":
//skip "turn on" knx message if brightness has just been set
if ((newValue? 1:0) !== (oldValue? 1:0)) {
if (newValue !== 1 || !this.brightnessSet) {
this.myAPI.knxWrite(field, newValue, "DPT1");
}
}
break;
case "Brightness":
this.myAPI.knxWrite(field, newValue, "DPT5.001");
// set "brightness has just been set" flag to true for next 2s
this.brightnessSet = true;
var that = this;
if (this.timer) clearTimeout(this.timer);
this.timer = setTimeout(function () {
that.brightnessSet = false;
},2000);
break;
case "ColorTemperature":
var absolute = this.convertBetweenAbsoluteAndMired(newValue);
log('INFO Writing color temperature in absolute value of ' + absolute + ' to KNX bus');
this.myAPI.knxWrite(field, absolute, "DPT5.001");
break;
}
}
convertBetweenAbsoluteAndMired(value) {
// K=Kelvin, PC=Percent
var warmwhite_K = this.myAPI.getLocalConstant("max_warmwhite");
var coldwhite_K = this.myAPI.getLocalConstant("max_coldwhite");
var currentwhite_K = Math.round(Math.pow(10, 6) / value);
let currentwhite_PC = ((currentwhite_K - warmwhite_K) / (coldwhite_K - warmwhite_K))*100;
return currentwhite_PC;
}
// onHKValueChange
} // class
module.exports = CWWW;
/* ********************************************************************************************************************** config.json "Services": [
{
"DeviceName": "Panel",
"Services": [
{
"ServiceType": "Lightbulb",
"Handler": "CWWW",
"ServiceName": "Panel",
"Characteristics": [
{
"Type": "On",
"Set": [
"5/0/23"
],
"Listen": [
"5/0/24"
],
"DPT": "DPT1"
},
{
"Type": "Brightness",
"Set": [
"5/0/33"
],
"Listen": [
"5/0/34"
],
"DPT": "DPT5.001"
},
{
"Type": "ColorTemperature",
"Set": [
"5/0/29"
],
"Listen": [
"5/0/30"
],
"DPT": "DPT5.001"
}
],
"KNXReadRequests": [
"5/0/24",
"5/0/30",
"5/0/34"
],
"LocalConstants": {
"max_warmwhite": 2700,
"max_coldwhite": 6500
}
}
]
}
] |
Hallo zusammen,
ich möchte gerne meine Beleuchtung mit Farbtemperatur steuern. An/Aus und dimmen funktioniert bereits:
"DeviceName": "Bett",
"Services": [
{
"ServiceType": "Lightbulb",
"Handler": "millis",
"ServiceName": "Bett",
"Characteristics": [
{
"Type": "On",
"Set": [
"0/0/13"
],
"Listen": [
"0/0/14"
],
"DPT": "DPT1"
},
{
"Type": "Brightness",
"Set": [
"0/0/20"
],
"Listen": [
"0/0/17"
],
"DPT": "DPT5.001"
}
],
"subtype": ""
}
],
"UUID": ""
Aber wie füge ich die Farbtemperatur steuerung hinzu?
Mit meinen MDT Led Controller kann ich folgendes steuern:
Kann mir da jemand helfen bzw. mir sagen wo ich das einbauen kann?
Gruß,
Matthias
The text was updated successfully, but these errors were encountered: