diff --git a/CHANGELOG.md b/CHANGELOG.md
index ff31c86d..90c91022 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -17,6 +17,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fix Lightpack issue (#1015)
+- Fix color calibration for Kodi 18 (Fixes #771)
+
### Removed
- Replace Multi-Lightpack by multi-instance Lightpack configuration
diff --git a/assets/webconfig/i18n/en.json b/assets/webconfig/i18n/en.json
index 6f8d3816..6f9daa59 100644
--- a/assets/webconfig/i18n/en.json
+++ b/assets/webconfig/i18n/en.json
@@ -862,13 +862,13 @@
"wiz_cc_btn_stop": "Stop video",
"wiz_cc_btn_switchpic": "Switch picture",
"wiz_cc_chooseid": "Define a name for this color profile.",
- "wiz_cc_intro1": "This wizard will guide you through your led calibration. If you are using Kodi, the calibration pictures and videos can be sent directly to it without further actions on your side. If not, you will need to download these files yourself and display them when the wizard needs you to adjust the setting.",
- "wiz_cc_kodicon": "Kodi webserver found, proceed with Kodi support.",
- "wiz_cc_kodidiscon": "Kodi webserver not found, proceed without Kodi support.",
+ "wiz_cc_intro1": "This wizard will guide you through your led calibration. If you are using Kodi, the calibration pictures and videos can be sent directly to it. Prerequisite: You need to enable \"Allow remote control from applications on other systems\" in Kodi. Alternatively, you might want downloading these files yourself and display them when the wizard asks you to adjust the setting.",
+ "wiz_cc_kodicon": "Kodi found, proceed with Kodi support.",
+ "wiz_cc_kodidiscon": "Kodi not found, proceed without Kodi support.",
"wiz_cc_kodidisconlink": "Download link pictures:",
"wiz_cc_kodimsg_start": "Test success - time to proceed!",
"wiz_cc_kodishould": "Kodi should show the following picture: $1",
- "wiz_cc_kwebs": "Kodi webserver (IP:Port)",
+ "wiz_cc_kwebs": "Kodi webserver (Hostname or IP)",
"wiz_cc_lettvshow": "Let your TV show the following picture: $1",
"wiz_cc_lettvshowm": "Check this with the following pictures: $1",
"wiz_cc_link": "Click me!",
diff --git a/assets/webconfig/js/wizard.js b/assets/webconfig/js/wizard.js
index 53b4379e..0b48b032 100644
--- a/assets/webconfig/js/wizard.js
+++ b/assets/webconfig/js/wizard.js
@@ -1,19 +1,16 @@
//clear priority and other tasks if people reload the page or lost connection while a wizard was active
-$(window.hyperion).one("ready", function(event) {
- if(getStorage("wizardactive") === 'true')
- {
+$(window.hyperion).one("ready", function (event) {
+ if (getStorage("wizardactive") === 'true') {
requestPriorityClear();
setStorage("wizardactive", false);
- if(getStorage("kodiAddress") != null)
- {
+ if (getStorage("kodiAddress") != null) {
kodiAddress = getStorage("kodiAddress");
sendToKodi("stop");
}
}
});
-function resetWizard(reload)
-{
+function resetWizard(reload) {
$("#wizard_modal").modal('hide');
clearInterval(wIntveralId);
requestPriorityClear();
@@ -22,146 +19,138 @@ function resetWizard(reload)
$('#wizp2').toggle(false);
$('#wizp3').toggle(false);
//cc
- if(withKodi)
+ if (withKodi)
sendToKodi("stop");
step = 0;
- if(!reload) location.reload();
+ if (!reload) location.reload();
}
//rgb byte order wizard
var wIntveralId;
var new_rgb_order;
-function changeColor()
-{
+function changeColor() {
var color = $("#wiz_canv_color").css('background-color');
- if (color == 'rgb(255, 0, 0)')
- {
- $("#wiz_canv_color").css('background-color','rgb(0, 255, 0)');
- requestSetColor('0','255','0');
+ if (color == 'rgb(255, 0, 0)') {
+ $("#wiz_canv_color").css('background-color', 'rgb(0, 255, 0)');
+ requestSetColor('0', '255', '0');
}
- else
- {
- $("#wiz_canv_color").css('background-color','rgb(255, 0, 0)');
- requestSetColor('255','0','0');
+ else {
+ $("#wiz_canv_color").css('background-color', 'rgb(255, 0, 0)');
+ requestSetColor('255', '0', '0');
}
}
-function startWizardRGB()
-{
+function startWizardRGB() {
//create html
- $('#wiz_header').html(' '+$.i18n('wiz_rgb_title'));
- $('#wizp1_body').html('
'+$.i18n('wiz_rgb_title')+' '+$.i18n('wiz_rgb_intro1')+'
'+$.i18n('wiz_rgb_intro2')+'
');
- $('#wizp1_footer').html(' '+$.i18n('general_btn_continue')+' '+$.i18n('general_btn_cancel')+' ');
- $('#wizp2_body').html(''+$.i18n('wiz_rgb_expl')+'
');
- $('#wizp2_body').append('');
- $('#wizp2_body').append(''+$.i18n('wiz_rgb_q')+' ');
- $('#wizp2_body').append(''+$.i18n('wiz_rgb_qrend')+' '+$.i18n('wiz_rgb_qgend')+'
');
- $('#wizp2_footer').html(' '+$.i18n('general_btn_save')+' '+$.i18n('general_btn_ok')+' '+$.i18n('general_btn_cancel')+' ');
+ $('#wiz_header').html(' ' + $.i18n('wiz_rgb_title'));
+ $('#wizp1_body').html('' + $.i18n('wiz_rgb_title') + ' ' + $.i18n('wiz_rgb_intro1') + '
' + $.i18n('wiz_rgb_intro2') + '
');
+ $('#wizp1_footer').html(' ' + $.i18n('general_btn_continue') + ' ' + $.i18n('general_btn_cancel') + ' ');
+ $('#wizp2_body').html('' + $.i18n('wiz_rgb_expl') + '
');
+ $('#wizp2_body').append('');
+ $('#wizp2_body').append('' + $.i18n('wiz_rgb_q') + ' ');
+ $('#wizp2_body').append('' + $.i18n('wiz_rgb_qrend') + ' ' + $.i18n('wiz_rgb_qgend') + '
');
+ $('#wizp2_footer').html(' ' + $.i18n('general_btn_save') + ' ' + $.i18n('general_btn_ok') + ' ' + $.i18n('general_btn_cancel') + ' ');
//open modal
$("#wizard_modal").modal({
- backdrop : "static",
+ backdrop: "static",
keyboard: false,
show: true
});
//listen for continue
- $('#btn_wiz_cont').off().on('click',function() {
+ $('#btn_wiz_cont').off().on('click', function () {
beginWizardRGB();
$('#wizp1').toggle(false);
$('#wizp2').toggle(true);
});
}
-function beginWizardRGB()
-{
- $("#wiz_switchtime_select").off().on('change',function() {
+function beginWizardRGB() {
+ $("#wiz_switchtime_select").off().on('change', function () {
clearInterval(wIntveralId);
var time = $("#wiz_switchtime_select").val();
- wIntveralId = setInterval(function() { changeColor(); }, time*1000);
+ wIntveralId = setInterval(function () { changeColor(); }, time * 1000);
});
$('.wselect').change(function () {
var rgb_order = window.serverConfig.device.colorOrder.split("");
var redS = $("#wiz_r_select").val();
var greenS = $("#wiz_g_select").val();
- var blueS = rgb_order.toString().replace(/,/g,"").replace(redS, "").replace(greenS,"");
+ var blueS = rgb_order.toString().replace(/,/g, "").replace(redS, "").replace(greenS, "");
- for (var i = 0; i '+$.i18n('wiz_cc_kodishould',$.i18n('edt_conf_color_white_title'));
- sendToKodi('playP',"white");
+ h = $.i18n('wiz_cc_adjustit', $.i18n('edt_conf_color_white_title'));
+ if (withKodi) {
+ h += ' ' + $.i18n('wiz_cc_kodishould', $.i18n('edt_conf_color_white_title'));
+ sendToKodi('playP', "white");
}
else
- h += ' '+$.i18n('wiz_cc_lettvshow',$.i18n('edt_conf_color_white_title'));
+ h += ' ' + $.i18n('wiz_cc_lettvshow', $.i18n('edt_conf_color_white_title'));
$('#wiz_cc_desc').html(h);
}
- if(step == 3)
- {
- updateWEditor(["gammaRed","gammaGreen","gammaBlue"]);
- h = ''+$.i18n('wiz_cc_adjustgamma')+'
';
- if(withKodi)
- {
- sendToKodi('playP',"HGradient");
- h +=''+$.i18n('wiz_cc_btn_switchpic')+' ';
+ if (step == 3) {
+ updateWEditor(["gammaRed", "gammaGreen", "gammaBlue"]);
+ h = '' + $.i18n('wiz_cc_adjustgamma') + '
';
+ if (withKodi) {
+ sendToKodi('playP', "HGradient");
+ h += '' + $.i18n('wiz_cc_btn_switchpic') + ' ';
}
else
- h += ''+$.i18n('wiz_cc_lettvshowm', "gey_1, grey_2, grey_3, HGradient, VGradient")+'
';
+ h += '' + $.i18n('wiz_cc_lettvshowm', "gey_1, grey_2, grey_3, HGradient, VGradient") + '
';
$('#wiz_cc_desc').html(h);
- $('#wiz_cc_btn_sp').off().on('click', function(){
- switchPicture(["VGradient","grey_1","grey_2","grey_3","HGradient"]);
+ $('#wiz_cc_btn_sp').off().on('click', function () {
+ switchPicture(["VGradient", "grey_1", "grey_2", "grey_3", "HGradient"]);
});
}
- if(step == 4)
- {
+ if (step == 4) {
updateWEditor(["red"]);
- h = $.i18n('wiz_cc_adjustit',$.i18n('edt_conf_color_red_title'));
- if(withKodi)
- {
- h += ' '+$.i18n('wiz_cc_kodishould',$.i18n('edt_conf_color_red_title'));
- sendToKodi('playP',"red");
+ h = $.i18n('wiz_cc_adjustit', $.i18n('edt_conf_color_red_title'));
+ if (withKodi) {
+ h += ' ' + $.i18n('wiz_cc_kodishould', $.i18n('edt_conf_color_red_title'));
+ sendToKodi('playP', "red");
}
else
- h += ' '+$.i18n('wiz_cc_lettvshow',$.i18n('edt_conf_color_red_title'));
+ h += ' ' + $.i18n('wiz_cc_lettvshow', $.i18n('edt_conf_color_red_title'));
$('#wiz_cc_desc').html(h);
}
- if(step == 5)
- {
+ if (step == 5) {
updateWEditor(["green"]);
- h = $.i18n('wiz_cc_adjustit',$.i18n('edt_conf_color_green_title'));
- if(withKodi)
- {
- h += ' '+$.i18n('wiz_cc_kodishould',$.i18n('edt_conf_color_green_title'));
- sendToKodi('playP',"green");
+ h = $.i18n('wiz_cc_adjustit', $.i18n('edt_conf_color_green_title'));
+ if (withKodi) {
+ h += ' ' + $.i18n('wiz_cc_kodishould', $.i18n('edt_conf_color_green_title'));
+ sendToKodi('playP', "green");
}
else
- h += ' '+$.i18n('wiz_cc_lettvshow',$.i18n('edt_conf_color_green_title'));
+ h += ' ' + $.i18n('wiz_cc_lettvshow', $.i18n('edt_conf_color_green_title'));
$('#wiz_cc_desc').html(h);
}
- if(step == 6)
- {
+ if (step == 6) {
updateWEditor(["blue"]);
- h = $.i18n('wiz_cc_adjustit',$.i18n('edt_conf_color_blue_title'));
- if(withKodi)
- {
- h += ' '+$.i18n('wiz_cc_kodishould',$.i18n('edt_conf_color_blue_title'));
- sendToKodi('playP',"blue");
+ h = $.i18n('wiz_cc_adjustit', $.i18n('edt_conf_color_blue_title'));
+ if (withKodi) {
+ h += ' ' + $.i18n('wiz_cc_kodishould', $.i18n('edt_conf_color_blue_title'));
+ sendToKodi('playP', "blue");
}
else
- h += ' '+$.i18n('wiz_cc_lettvshow',$.i18n('edt_conf_color_blue_title'));
+ h += ' ' + $.i18n('wiz_cc_lettvshow', $.i18n('edt_conf_color_blue_title'));
$('#wiz_cc_desc').html(h);
}
- if(step == 7)
- {
+ if (step == 7) {
updateWEditor(["cyan"]);
- h = $.i18n('wiz_cc_adjustit',$.i18n('edt_conf_color_cyan_title'));
- if(withKodi)
- {
- h += ' '+$.i18n('wiz_cc_kodishould',$.i18n('edt_conf_color_cyan_title'));
- sendToKodi('playP',"cyan");
+ h = $.i18n('wiz_cc_adjustit', $.i18n('edt_conf_color_cyan_title'));
+ if (withKodi) {
+ h += ' ' + $.i18n('wiz_cc_kodishould', $.i18n('edt_conf_color_cyan_title'));
+ sendToKodi('playP', "cyan");
}
else
- h += ' '+$.i18n('wiz_cc_lettvshow',$.i18n('edt_conf_color_cyan_title'));
+ h += ' ' + $.i18n('wiz_cc_lettvshow', $.i18n('edt_conf_color_cyan_title'));
$('#wiz_cc_desc').html(h);
}
- if(step == 8)
- {
+ if (step == 8) {
updateWEditor(["magenta"]);
- h = $.i18n('wiz_cc_adjustit',$.i18n('edt_conf_color_magenta_title'));
- if(withKodi)
- {
- h += ' '+$.i18n('wiz_cc_kodishould',$.i18n('edt_conf_color_magenta_title'));
- sendToKodi('playP',"magenta");
+ h = $.i18n('wiz_cc_adjustit', $.i18n('edt_conf_color_magenta_title'));
+ if (withKodi) {
+ h += ' ' + $.i18n('wiz_cc_kodishould', $.i18n('edt_conf_color_magenta_title'));
+ sendToKodi('playP', "magenta");
}
else
- h += ' '+$.i18n('wiz_cc_lettvshow',$.i18n('edt_conf_color_magenta_title'));
+ h += ' ' + $.i18n('wiz_cc_lettvshow', $.i18n('edt_conf_color_magenta_title'));
$('#wiz_cc_desc').html(h);
}
- if(step == 9)
- {
+ if (step == 9) {
updateWEditor(["yellow"]);
- h = $.i18n('wiz_cc_adjustit',$.i18n('edt_conf_color_yellow_title'));
- if(withKodi)
- {
- h += ' '+$.i18n('wiz_cc_kodishould',$.i18n('edt_conf_color_yellow_title'));
- sendToKodi('playP',"yellow");
+ h = $.i18n('wiz_cc_adjustit', $.i18n('edt_conf_color_yellow_title'));
+ if (withKodi) {
+ h += ' ' + $.i18n('wiz_cc_kodishould', $.i18n('edt_conf_color_yellow_title'));
+ sendToKodi('playP', "yellow");
}
else
- h += ' '+$.i18n('wiz_cc_lettvshow',$.i18n('edt_conf_color_yellow_title'));
+ h += ' ' + $.i18n('wiz_cc_lettvshow', $.i18n('edt_conf_color_yellow_title'));
$('#wiz_cc_desc').html(h);
}
- if(step == 10)
- {
- updateWEditor(["backlightThreshold","backlightColored"]);
+ if (step == 10) {
+ updateWEditor(["backlightThreshold", "backlightColored"]);
h = $.i18n('wiz_cc_backlight');
- if(withKodi)
- {
- h += ' '+$.i18n('wiz_cc_kodishould',$.i18n('edt_conf_color_black_title'));
- sendToKodi('playP',"black");
+ if (withKodi) {
+ h += ' ' + $.i18n('wiz_cc_kodishould', $.i18n('edt_conf_color_black_title'));
+ sendToKodi('playP', "black");
}
else
- h += ' '+$.i18n('wiz_cc_lettvshow',$.i18n('edt_conf_color_black_title'));
+ h += ' ' + $.i18n('wiz_cc_lettvshow', $.i18n('edt_conf_color_black_title'));
$('#wiz_cc_desc').html(h);
}
- if(step == 11)
- {
+ if (step == 11) {
updateWEditor([""], true);
- h = ''+$.i18n('wiz_cc_testintro')+'
';
- if(withKodi)
- {
- h += ''+$.i18n('wiz_cc_testintrok')+'
';
+ h = '' + $.i18n('wiz_cc_testintro') + '
';
+ if (withKodi) {
+ h += '' + $.i18n('wiz_cc_testintrok') + '
';
sendToKodi('stop');
- for(var i = 0; i '+txt+' ';
+ for (var i = 0; i < availVideos.length; i++) {
+ var txt = availVideos[i].replace(/_/g, " ");
+ h += ' ' + txt + '
';
}
- h +=' '+$.i18n('wiz_cc_btn_stop')+'
';
+ h += ' ' + $.i18n('wiz_cc_btn_stop') + '
';
}
else
- h += ''+$.i18n('wiz_cc_testintrowok')+' '+$.i18n('wiz_cc_link')+'
';
- h += ''+$.i18n('wiz_cc_summary')+'
';
+ h += '' + $.i18n('wiz_cc_testintrowok') + ' ' + $.i18n('wiz_cc_link') + '
';
+ h += '' + $.i18n('wiz_cc_summary') + '
';
$('#wiz_cc_desc').html(h);
- $('.videobtn').off().on('click', function(e){
- if(e.target.id == "stop")
+ $('.videobtn').off().on('click', function (e) {
+ if (e.target.id == "stop")
sendToKodi("stop");
else
- sendToKodi("playV",e.target.id+'.mp4');
+ sendToKodi("playV", e.target.id + '.mp4');
$(this).attr("disabled", true);
- setTimeout(function(){$('.videobtn').attr("disabled", false)},10000);
+ setTimeout(function () { $('.videobtn').attr("disabled", false) }, 10000);
});
$('#btn_wiz_next').attr("disabled", true);
$('#btn_wiz_save').toggle(true);
}
- else
- {
+ else {
$('#btn_wiz_next').attr("disabled", false);
$('#btn_wiz_save').toggle(false);
}
}
-function updateWEditor(el, all)
-{
- for (var key in cobj)
- {
- if(all === true || el[0] == key || el[1] == key || el[2] == key)
- $('#editor_container_wiz [data-schemapath*=".'+profile+'.'+key+'"]').toggle(true);
+function updateWEditor(el, all) {
+ for (var key in cobj) {
+ if (all === true || el[0] == key || el[1] == key || el[2] == key)
+ $('#editor_container_wiz [data-schemapath*=".' + profile + '.' + key + '"]').toggle(true);
else
- $('#editor_container_wiz [data-schemapath*=".'+profile+'.'+key+'"]').toggle(false);
+ $('#editor_container_wiz [data-schemapath*=".' + profile + '.' + key + '"]').toggle(false);
}
}
-function startWizardCC()
-{
+function startWizardCC() {
+ // Ensure that Kodi's default REST-API port is not used, as now the Web-Socket port is used
+ [kodiHost, kodiPort] = kodiAddress.split(":", 2);
+ if (kodiPort === "8080") {
+ kodiAddress = kodiHost;
+ kodiPort = undefined;
+ }
+
//create html
- $('#wiz_header').html(' '+$.i18n('wiz_cc_title'));
- $('#wizp1_body').html(''+$.i18n('wiz_cc_title')+' '+$.i18n('wiz_cc_intro1')+'
'+$.i18n('wiz_cc_kwebs')+' ');
- $('#wizp1_footer').html(' '+$.i18n('general_btn_continue')+' '+$.i18n('general_btn_cancel')+' ');
+ $('#wiz_header').html(' ' + $.i18n('wiz_cc_title'));
+ $('#wizp1_body').html('' + $.i18n('wiz_cc_title') + ' ' + $.i18n('wiz_cc_intro1') + '
' + $.i18n('wiz_cc_kwebs') + ' ');
+ $('#wizp1_footer').html(' ' + $.i18n('general_btn_continue') + ' ' + $.i18n('general_btn_cancel') + ' ');
$('#wizp2_body').html('
');
- $('#wizp2_footer').html(' '+$.i18n('general_btn_back')+''+$.i18n('general_btn_next')+' '+$.i18n('general_btn_save')+' '+$.i18n('general_btn_cancel')+' ');
+ $('#wizp2_footer').html(' ' + $.i18n('general_btn_back') + '' + $.i18n('general_btn_next') + ' ' + $.i18n('general_btn_save') + ' ' + $.i18n('general_btn_cancel') + ' ');
//open modal
$("#wizard_modal").modal({
- backdrop : "static",
+ backdrop: "static",
keyboard: false,
show: true
});
- $('#wiz_cc_kodiip').off().on('change',function() {
- kodiAddress = $(this).val();
- setStorage("kodiAddress", kodiAddress);
- sendToKodi("msg", $.i18n('wiz_cc_kodimsg_start'), function(cb){
- if(cb == "error")
- {
- $('#kodi_status').html(''+$.i18n('wiz_cc_kodidiscon')+'
'+$.i18n('wiz_cc_kodidisconlink')+' '+$.i18n('wiz_cc_link')+'
');
- withKodi = false;
- }
- else
- {
- $('#kodi_status').html(''+$.i18n('wiz_cc_kodicon')+'
');
- withKodi = true;
- }
+ $('#wiz_cc_kodiip').off().on('change', function () {
+ kodiAddress = $(this).val().trim();
+ $('#kodi_status').html('');
- $('#btn_wiz_cont').attr('disabled', false);
- });
+ // Remove Kodi's default Web-Socket port (9090) from display and ensure Kodi's default REST-API port (8080) is mapped to web-socket port to ease migration
+ if (kodiAddress !== "") {
+ [kodiHost, kodiPort] = kodiAddress.split(":", 2);
+ if (kodiPort === "9090" || kodiPort === "8080") {
+ kodiAddress = kodiHost;
+ kodiPort = undefined;
+ }
+ sendToKodi("msg", $.i18n('wiz_cc_kodimsg_start'), function (cb) {
+ if (cb == "error") {
+ $('#kodi_status').html('' + $.i18n('wiz_cc_kodidiscon') + '
' + $.i18n('wiz_cc_kodidisconlink') + ' ' + $.i18n('wiz_cc_link') + '
');
+ withKodi = false;
+ }
+ else {
+ setStorage("kodiAddress", kodiAddress);
+
+ $('#kodi_status').html('' + $.i18n('wiz_cc_kodicon') + '
');
+ withKodi = true;
+ }
+
+ $('#btn_wiz_cont').attr('disabled', false);
+ });
+ }
});
//listen for continue
- $('#btn_wiz_cont').off().on('click',function() {
+ $('#btn_wiz_cont').off().on('click', function () {
beginWizardCC();
$('#wizp1').toggle(false);
$('#wizp2').toggle(true);
@@ -453,59 +466,56 @@ function startWizardCC()
$('#wiz_cc_kodiip').trigger("change");
colorLength = window.serverConfig.color.channelAdjustment;
cobj = window.schema.color.properties.channelAdjustment.items.properties;
- websAddress = document.location.hostname+':'+window.serverConfig.webConfig.port;
- imgAddress = 'http://'+websAddress+'/img/cc/';
+ websAddress = document.location.hostname + ':' + window.serverConfig.webConfig.port;
+ imgAddress = 'http://' + websAddress + '/img/cc/';
setStorage("wizardactive", true);
//check profile count
- if(colorLength.length > 1)
- {
- $('#multi_cali').html(''+$.i18n('wiz_cc_morethanone')+'
');
- for(var i = 0; i 1) {
+ $('#multi_cali').html('' + $.i18n('wiz_cc_morethanone') + '
');
+ for (var i = 0; i < colorLength.length; i++)
+ $('#wiz_select').append(createSelOpt(i, i + 1 + ' (' + colorLength[i].id + ')'));
- $('#wiz_select').off().on('change', function(){
+ $('#wiz_select').off().on('change', function () {
profile = $(this).val();
});
}
//prepare editor
wiz_editor = createJsonEditor('editor_container_wiz', {
- color : window.schema.color
+ color: window.schema.color
}, true, true);
$('#editor_container_wiz h4').toggle(false);
$('#editor_container_wiz .btn-group').toggle(false);
$('#editor_container_wiz [data-schemapath="root.color.imageToLedMappingType"]').toggle(false);
- for(var i = 0; i'+$.i18n(hue_title));
- $('#wizp1_body').html(''+$.i18n(hue_title)+' '+$.i18n(hue_intro1)+'
');
- $('#wizp1_footer').html(' '+$.i18n('general_btn_continue')+' '+$.i18n('general_btn_cancel')+' ');
+ $('#wiz_header').html(' ' + $.i18n(hue_title));
+ $('#wizp1_body').html('' + $.i18n(hue_title) + ' ' + $.i18n(hue_intro1) + '
');
+ $('#wizp1_footer').html(' ' + $.i18n('general_btn_continue') + ' ' + $.i18n('general_btn_cancel') + ' ');
$('#wizp2_body').html('
');
- $('#wh_topcontainer').append(''+$.i18n(hue_desc1)+'
');
+ $('#wh_topcontainer').append('' + $.i18n(hue_desc1) + '
');
$('#wh_topcontainer').append();
$('#wh_topcontainer').append('
');
- if(hueType == 'philipshue')
- {
- $('#usrcont').append(''+$.i18n('wiz_hue_username')+'
');
+ if (hueType == 'philipshue') {
+ $('#usrcont').append('' + $.i18n('wiz_hue_username') + '
');
}
- if(hueType == 'philipshueentertainment')
- {
- $('#usrcont').append(''+$.i18n('wiz_hue_username')+'
'+$.i18n('wiz_hue_clientkey')+'
');
+ if (hueType == 'philipshueentertainment') {
+ $('#usrcont').append('' + $.i18n('wiz_hue_username') + '
' + $.i18n('wiz_hue_clientkey') + '
');
}
- $('#usrcont').append(' '+$.i18n(hue_create_user)+' ');
- if(hueType == 'philipshueentertainment')
- {
- $('#wizp2_body').append(''+$.i18n('wiz_hue_e_desc2')+'
');
+ $('#usrcont').append(' ' + $.i18n(hue_create_user) + ' ');
+ if (hueType == 'philipshueentertainment') {
+ $('#wizp2_body').append('' + $.i18n('wiz_hue_e_desc2') + '
');
createTable("gidsh", "gidsb", "hue_grp_ids_t");
- $('.gidsh').append(createTableRow([$.i18n('edt_dev_spec_groupId_title'),$.i18n('wiz_hue_e_use_group')], true));
- $('#wizp2_body').append(''+$.i18n('wiz_hue_e_desc3')+'
');
+ $('.gidsh').append(createTableRow([$.i18n('edt_dev_spec_groupId_title'), $.i18n('wiz_hue_e_use_group')], true));
+ $('#wizp2_body').append('' + $.i18n('wiz_hue_e_desc3') + '
');
}
- else
- {
- $('#wizp2_body').append(''+$.i18n('wiz_hue_desc2')+'
');
+ else {
+ $('#wizp2_body').append('' + $.i18n('wiz_hue_desc2') + '
');
}
createTable("lidsh", "lidsb", "hue_ids_t");
- $('.lidsh').append(createTableRow([$.i18n('edt_dev_spec_lightid_title'),$.i18n('wiz_pos'),$.i18n('wiz_identify')], true));
- $('#wizp2_footer').html(' '+$.i18n('general_btn_save')+' '+$.i18n('general_btn_cancel')+' ');
- $('#wizp3_body').html(''+$.i18n('wiz_hue_press_link')+' ');
+ $('.lidsh').append(createTableRow([$.i18n('edt_dev_spec_lightid_title'), $.i18n('wiz_pos'), $.i18n('wiz_identify')], true));
+ $('#wizp2_footer').html(' ' + $.i18n('general_btn_save') + ' ' + $.i18n('general_btn_cancel') + ' ');
+ $('#wizp3_body').html('' + $.i18n('wiz_hue_press_link') + ' ');
//open modal
$("#wizard_modal").modal({
- backdrop : "static",
+ backdrop: "static",
keyboard: false,
show: true
});
//listen for continue
- $('#btn_wiz_cont').off().on('click',function() {
+ $('#btn_wiz_cont').off().on('click', function () {
beginWizardHue();
$('#wizp1').toggle(false);
$('#wizp2').toggle(true);
});
}
-function checkHueBridge(cb,hueUser) {
+function checkHueBridge(cb, hueUser) {
var usr = (typeof hueUser != "undefined") ? hueUser : 'config';
- if(usr == 'config') $('#wiz_hue_discovered').html("");
+ if (usr == 'config') $('#wiz_hue_discovered').html("");
$.ajax({
- url: 'http://'+hueIPs[hueIPsinc].internalipaddress+'/api/'+usr,
+ url: 'http://' + hueIPs[hueIPsinc].internalipaddress + '/api/' + usr,
type: "GET",
dataType: "json",
- success: function( json ) {
+ success: function (json) {
if (json.config) {
cb(true, usr);
- } else if( json.name && json.bridgeid && json.modelid) {
+ } else if (json.name && json.bridgeid && json.modelid) {
$('#wiz_hue_discovered').html("Bridge: " + json.name + ", Modelid: " + json.modelid + ", API-Version: " + json.apiversion);
cb(true);
} else {
cb(false);
}
-
- },
+ },
timeout: 2500
- }).fail(function() {
+ }).fail(function () {
cb(false);
});
}
-function checkBridgeResult(reply, usr){
- if(reply)
- {
+function checkBridgeResult(reply, usr) {
+ if (reply) {
//abort checking, first reachable result is used
$('#wiz_hue_ipstate').html("");
$('#ip').val(hueIPs[hueIPsinc].internalipaddress)
//now check hue user on this bridge
$('#usrcont').toggle(true);
- checkHueBridge(checkUserResult,$('#user').val() ? $('#user').val() : "newdeveloper");
+ checkHueBridge(checkUserResult, $('#user').val() ? $('#user').val() : "newdeveloper");
}
- else
- {
+ else {
//increment and check again
- if(hueIPs.length-1 > hueIPsinc)
- {
+ if (hueIPs.length - 1 > hueIPsinc) {
hueIPsinc++;
checkHueBridge(checkBridgeResult);
}
- else
- {
+ else {
$('#usrcont').toggle(false);
$('#wiz_hue_ipstate').html($.i18n('wiz_hue_failure_ip'));
}
@@ -699,129 +697,115 @@ function checkBridgeResult(reply, usr){
};
function checkUserResult(reply, usr) {
-
- if(reply)
- {
+ if (reply) {
$('#user').val(usr);
- if(hueType == 'philipshueentertainment' && $('#clientkey').val() == "") {
+ if (hueType == 'philipshueentertainment' && $('#clientkey').val() == "") {
$('#usrcont').toggle(true);
$('#wiz_hue_usrstate').html($.i18n('wiz_hue_e_clientkey_needed'));
$('#wiz_hue_create_user').toggle(true);
} else {
$('#wiz_hue_usrstate').html("");
$('#wiz_hue_create_user').toggle(false);
- if(hueType == 'philipshue')
- {
+ if (hueType == 'philipshue') {
get_hue_lights();
}
- if(hueType == 'philipshueentertainment')
- {
+ if (hueType == 'philipshueentertainment') {
get_hue_groups();
}
}
}
- else
- {
+ else {
$('#wiz_hue_usrstate').html($.i18n('wiz_hue_failure_user'));
$('#wiz_hue_create_user').toggle(true);
}
};
-function identHueId(id, off, oState)
-{
- if(off !== true)
- {
- setTimeout(identHueId,1500,id,true,oState);
+function identHueId(id, off, oState) {
+ if (off !== true) {
+ setTimeout(identHueId, 1500, id, true, oState);
var put_data = '{"on":true,"bri":254,"hue":47000,"sat":254}';
}
- else
- {
- var put_data = '{"on":'+oState.on+',"bri":' + oState.bri +',"hue":' + oState.hue +',"sat":' + oState.sat +'}';
+ else {
+ var put_data = '{"on":' + oState.on + ',"bri":' + oState.bri + ',"hue":' + oState.hue + ',"sat":' + oState.sat + '}';
}
$.ajax({
- url: 'http://'+$('#ip').val()+'/api/'+$('#user').val()+'/lights/'+id+'/state',
+ url: 'http://' + $('#ip').val() + '/api/' + $('#user').val() + '/lights/' + id + '/state',
type: 'PUT',
timeout: 2000,
data: put_data
})
}
-function useGroupId(id)
-{
+function useGroupId(id) {
$('#groupId').val(id);
groupLights = groupIDs[id].lights;
groupLightsLocations = groupIDs[id].locations;
get_hue_lights();
}
-async function discover_hue_bridges(){
+async function discover_hue_bridges() {
+ const res = await requestLedDeviceDiscovery('philipshue');
- const res = await requestLedDeviceDiscovery ('philipshue');
-
- // TODO: error case unhandled
- // res can be: false (timeout) or res.error (not found)
- if(res && !res.error){
- const r = res.info;
+ // TODO: error case unhandled
+ // res can be: false (timeout) or res.error (not found)
+ if (res && !res.error) {
+ const r = res.info;
- // Process devices returned by discovery
- console.log(r);
-
- if(r.devices.length == 0)
- $('#wiz_hue_ipstate').html($.i18n('wiz_hue_failure_ip'));
- else
- {
- for(const device of r.devices)
- {
- console.log("Device:", device);
+ // Process devices returned by discovery
+ console.log(r);
- var ip = device.hostname + ":" + device.port;
- console.log("Host:", ip);
+ if (r.devices.length == 0)
+ $('#wiz_hue_ipstate').html($.i18n('wiz_hue_failure_ip'));
+ else {
+ for (const device of r.devices) {
+ console.log("Device:", device);
- hueIPs.push({internalipaddress : ip});
- }
- var usr = $('#user').val();
- if(usr != "") {
- checkHueBridge(checkUserResult, usr);
- } else {
- checkHueBridge(checkBridgeResult);
- }
- }
- }
+ var ip = device.hostname + ":" + device.port;
+ console.log("Host:", ip);
+
+ hueIPs.push({ internalipaddress: ip });
+ }
+ var usr = $('#user').val();
+ if (usr != "") {
+ checkHueBridge(checkUserResult, usr);
+ } else {
+ checkHueBridge(checkBridgeResult);
+ }
+ }
+ }
}
-async function getProperties_hue_bridge(hostAddress, username, resourceFilter){
+async function getProperties_hue_bridge(hostAddress, username, resourceFilter) {
+ let params = { host: hostAddress, user: username, filter: resourceFilter };
- let params = { host: hostAddress, user: username, filter: resourceFilter};
-
- const res = await requestLedDeviceProperties ('philipshue', params);
-
- // TODO: error case unhandled
- // res can be: false (timeout) or res.error (not found)
- if(res && !res.error){
- const r = res.info
+ const res = await requestLedDeviceProperties('philipshue', params);
- // Process properties returned
- console.log(r);
- }
+ // TODO: error case unhandled
+ // res can be: false (timeout) or res.error (not found)
+ if (res && !res.error) {
+ const r = res.info
+
+ // Process properties returned
+ console.log(r);
+ }
}
-function identify_hue_device(hostAddress, username, id){
+function identify_hue_device(hostAddress, username, id) {
+ console.log("identify_hue_device");
- console.log("identify_hue_device");
+ let params = { host: hostAddress, user: username, lightId: id };
- let params = { host: hostAddress, user: username, lightId: id };
-
- const res = requestLedDeviceIdentification ("philipshue", params);
- // TODO: error case unhandled
- // res can be: false (timeout) or res.error (not found)
- if(res && !res.error){
- const r = res.info
- console.log(r);
- }
+ const res = requestLedDeviceIdentification("philipshue", params);
+ // TODO: error case unhandled
+ // res can be: false (timeout) or res.error (not found)
+ if (res && !res.error) {
+ const r = res.info
+ console.log(r);
+ }
}
-function getHueIPs(){
+function getHueIPs() {
$('#wiz_hue_ipstate').html($.i18n('wiz_hue_searchb'));
$.ajax({
url: 'https://discovery.meethue.com',
@@ -829,97 +813,88 @@ function getHueIPs(){
type: 'GET',
timeout: 3000
})
- .done( function( data, textStatus, jqXHR ) {
- if(data.length == 0) {
+ .done(function (data, textStatus, jqXHR) {
+ if (data.length == 0) {
+ $('#wiz_hue_ipstate').html($.i18n('wiz_hue_failure_ip'));
+ } else {
+ hueIPs = data;
+ checkHueBridge(checkBridgeResult);
+ }
+ })
+ .fail(function (jqXHR, textStatus) {
$('#wiz_hue_ipstate').html($.i18n('wiz_hue_failure_ip'));
- } else {
- hueIPs = data;
- checkHueBridge(checkBridgeResult);
- }
- })
- .fail( function( jqXHR, textStatus ) {
- $('#wiz_hue_ipstate').html($.i18n('wiz_hue_failure_ip'));
- });
+ });
};
//return editor Value
-function eV(vn)
-{
+function eV(vn) {
return (vn) ? conf_editor.getEditor("root.specificOptions." + vn).getValue() : "";
}
-function beginWizardHue()
-{
+function beginWizardHue() {
var usr = eV("username");
- if(usr != "") {
+ if (usr != "") {
$('#user').val(usr);
}
- if(hueType == 'philipshueentertainment') {
+ if (hueType == 'philipshueentertainment') {
var clkey = eV("clientkey");
- if(clkey != "")
- {
+ if (clkey != "") {
$('#clientkey').val(clkey);
}
}
//check if ip is empty/reachable/search for bridge
- if(eV("output") == "")
- {
+ if (eV("output") == "") {
//getHueIPs();
discover_hue_bridges();
}
- else
- {
+ else {
var ip = eV("output");
$('#ip').val(ip);
- hueIPs.unshift({internalipaddress : ip});
- if(usr != "") {
+ hueIPs.unshift({ internalipaddress: ip });
+ if (usr != "") {
checkHueBridge(checkUserResult, usr);
- }else{
+ } else {
checkHueBridge(checkBridgeResult);
}
}
- $('#retry_bridge').off().on('click', function(){
- if($('#ip').val()!="")
- {
- hueIPs.unshift({internalipaddress : $('#ip').val()})
- hueIPsinc = 0;
+ $('#retry_bridge').off().on('click', function () {
+ if ($('#ip').val() != "") {
+ hueIPs.unshift({ internalipaddress: $('#ip').val() })
+ hueIPsinc = 0;
}
- else discover_hue_bridges();
+ else discover_hue_bridges();
var usr = $('#user').val();
- if(usr != "") {
+ if (usr != "") {
checkHueBridge(checkUserResult, usr);
- }else{
+ } else {
checkHueBridge(checkBridgeResult);
}
});
- $('#retry_usr').off().on('click', function(){
- checkHueBridge(checkUserResult,$('#user').val() ? $('#user').val() : "newdeveloper");
+ $('#retry_usr').off().on('click', function () {
+ checkHueBridge(checkUserResult, $('#user').val() ? $('#user').val() : "newdeveloper");
});
- $('#wiz_hue_create_user').off().on('click',function() {
- if($('#ip').val()!="") hueIPs.unshift({internalipaddress : $('#ip').val()});
+ $('#wiz_hue_create_user').off().on('click', function () {
+ if ($('#ip').val() != "") hueIPs.unshift({ internalipaddress: $('#ip').val() });
createHueUser();
});
- $('#btn_wiz_save').off().on("click", function(){
+ $('#btn_wiz_save').off().on("click", function () {
var hueLedConfig = [];
var finalLightIds = [];
//create hue led config
- for(var key in lightIDs)
- {
- if(hueType == 'philipshueentertainment')
- {
- if(groupLights.indexOf(key) == -1) continue;
+ for (var key in lightIDs) {
+ if (hueType == 'philipshueentertainment') {
+ if (groupLights.indexOf(key) == -1) continue;
}
- if($('#hue_'+key).val() != "disabled")
- {
+ if ($('#hue_' + key).val() != "disabled") {
finalLightIds.push(key);
- var idx_content = assignLightPos(key, $('#hue_'+key).val(), lightIDs[key].name);
+ var idx_content = assignLightPos(key, $('#hue_' + key).val(), lightIDs[key].name);
hueLedConfig.push(JSON.parse(JSON.stringify(idx_content)));
}
}
@@ -937,47 +912,45 @@ function beginWizardHue()
//device config
- //Start with a clean configuration
- var d = {};
- d.output = $('#ip').val();
- d.username = $('#user').val();
- d.type = 'philipshue';
- d.colorOrder = 'rgb';
- d.lightIds = finalLightIds;
- d.latchTime = 0;
- d.transitiontime = parseInt(eV("transitiontime") );
- d.restoreOriginalState = (eV("restoreOriginalState") == true);
- d.switchOffOnBlack = (eV("switchOffOnBlack") == true);
- d.brightnessFactor = parseFloat(eV("brightnessFactor"));
+ //Start with a clean configuration
+ var d = {};
+ d.output = $('#ip').val();
+ d.username = $('#user').val();
+ d.type = 'philipshue';
+ d.colorOrder = 'rgb';
+ d.lightIds = finalLightIds;
+ d.latchTime = 0;
+ d.transitiontime = parseInt(eV("transitiontime"));
+ d.restoreOriginalState = (eV("restoreOriginalState") == true);
+ d.switchOffOnBlack = (eV("switchOffOnBlack") == true);
+ d.brightnessFactor = parseFloat(eV("brightnessFactor"));
- d.clientkey = $('#clientkey').val();
- d.groupId = parseInt($('#groupId').val());
- d.blackLightsTimeout = parseInt(eV("blackLightsTimeout"));
- d.brightnessMin = parseFloat(eV("brightnessMin"));
- d.brightnessMax = parseFloat(eV("brightnessMax"));
- d.brightnessThreshold = parseFloat(eV("brightnessThreshold"));
- d.sslReadTimeout = parseInt(eV("sslReadTimeout"));
- d.sslHSTimeoutMin = parseInt(eV("sslHSTimeoutMin"));
- d.sslHSTimeoutMax = parseInt(eV("sslHSTimeoutMax"));
- d.verbose = (eV("verbose") == true);
- d.debugStreamer = (eV("debugStreamer") == true);
- d.debugLevel = (eV("debugLevel"));
+ d.clientkey = $('#clientkey').val();
+ d.groupId = parseInt($('#groupId').val());
+ d.blackLightsTimeout = parseInt(eV("blackLightsTimeout"));
+ d.brightnessMin = parseFloat(eV("brightnessMin"));
+ d.brightnessMax = parseFloat(eV("brightnessMax"));
+ d.brightnessThreshold = parseFloat(eV("brightnessThreshold"));
+ d.sslReadTimeout = parseInt(eV("sslReadTimeout"));
+ d.sslHSTimeoutMin = parseInt(eV("sslHSTimeoutMin"));
+ d.sslHSTimeoutMax = parseInt(eV("sslHSTimeoutMax"));
+ d.verbose = (eV("verbose") == true);
+ d.debugStreamer = (eV("debugStreamer") == true);
+ d.debugLevel = (eV("debugLevel"));
- if(hueType == 'philipshue')
- {
+ if (hueType == 'philipshue') {
d.useEntertainmentAPI = false;
- d.hardwareLedCount = finalLightIds.length;
- d.rewriteTime = 0;
- d.verbose = false;
+ d.hardwareLedCount = finalLightIds.length;
+ d.rewriteTime = 0;
+ d.verbose = false;
//smoothing off
sc.smoothing.enable = false;
}
- if(hueType == 'philipshueentertainment')
- {
+ if (hueType == 'philipshueentertainment') {
d.useEntertainmentAPI = true;
- d.hardwareLedCount = groupLights.length;
- d.rewriteTime = 20;
+ d.hardwareLedCount = groupLights.length;
+ d.rewriteTime = 20;
//smoothing on
sc.smoothing.enable = true;
}
@@ -991,178 +964,160 @@ function beginWizardHue()
$('#btn_wiz_abort').off().on('click', resetWizard);
}
-function createHueUser()
-{
+function createHueUser() {
var connectionRetries = 30;
- var data = {"devicetype":"hyperion#"+Date.now()}
- if(hueType == 'philipshueentertainment')
- {
- data = {"devicetype":"hyperion#"+Date.now(), "generateclientkey":true}
+ var data = { "devicetype": "hyperion#" + Date.now() }
+ if (hueType == 'philipshueentertainment') {
+ data = { "devicetype": "hyperion#" + Date.now(), "generateclientkey": true }
}
- var UserInterval = setInterval(function(){
- $.ajax({
- type: "POST",
- url: 'http://'+$("#ip").val()+'/api',
- processData: false,
- timeout: 1000,
- contentType: 'application/json',
- data: JSON.stringify(data),
- success: function(r) {
- $('#wizp1').toggle(false);
- $('#wizp2').toggle(false);
- $('#wizp3').toggle(true);
+ var UserInterval = setInterval(function () {
+ $.ajax({
+ type: "POST",
+ url: 'http://' + $("#ip").val() + '/api',
+ processData: false,
+ timeout: 1000,
+ contentType: 'application/json',
+ data: JSON.stringify(data),
+ success: function (r) {
+ $('#wizp1').toggle(false);
+ $('#wizp2').toggle(false);
+ $('#wizp3').toggle(true);
- connectionRetries--;
- $("#connectionTime").html(connectionRetries);
- if(connectionRetries == 0) {
- abortConnection(UserInterval);
- }
- else
- {
- if (typeof r[0].error != 'undefined') {
- console.log(connectionRetries+": link not pressed");
+ connectionRetries--;
+ $("#connectionTime").html(connectionRetries);
+ if (connectionRetries == 0) {
+ abortConnection(UserInterval);
}
- if (typeof r[0].success != 'undefined') {
- $('#wizp1').toggle(false);
- $('#wizp2').toggle(true);
- $('#wizp3').toggle(false);
- if(r[0].success.username != 'undefined') {
- $('#user').val(r[0].success.username);
- conf_editor.getEditor("root.specificOptions.username").setValue( r[0].success.username );
+ else {
+ if (typeof r[0].error != 'undefined') {
+ console.log(connectionRetries + ": link not pressed");
}
- if(hueType == 'philipshueentertainment')
- {
- if(r[0].success.clientkey != 'undefined') {
- $('#clientkey').val(r[0].success.clientkey);
- conf_editor.getEditor("root.specificOptions.clientkey").setValue( r[0].success.clientkey );
+ if (typeof r[0].success != 'undefined') {
+ $('#wizp1').toggle(false);
+ $('#wizp2').toggle(true);
+ $('#wizp3').toggle(false);
+ if (r[0].success.username != 'undefined') {
+ $('#user').val(r[0].success.username);
+ conf_editor.getEditor("root.specificOptions.username").setValue(r[0].success.username);
}
+ if (hueType == 'philipshueentertainment') {
+ if (r[0].success.clientkey != 'undefined') {
+ $('#clientkey').val(r[0].success.clientkey);
+ conf_editor.getEditor("root.specificOptions.clientkey").setValue(r[0].success.clientkey);
+ }
+ }
+ checkHueBridge(checkUserResult, r[0].success.username);
+ clearInterval(UserInterval);
}
- checkHueBridge(checkUserResult,r[0].success.username);
- clearInterval(UserInterval);
}
+ },
+ error: function (XMLHttpRequest, textStatus, errorThrown) {
+ $('#wizp1').toggle(false);
+ $('#wizp2').toggle(true);
+ $('#wizp3').toggle(false);
+ clearInterval(UserInterval);
}
- },
- error: function(XMLHttpRequest, textStatus, errorThrown) {
- $('#wizp1').toggle(false);
- $('#wizp2').toggle(true);
- $('#wizp3').toggle(false);
- clearInterval(UserInterval);
- }
- });
- },1000);
+ });
+ }, 1000);
}
-function get_hue_groups(){
+function get_hue_groups() {
$.ajax({
type: "GET",
- url: 'http://'+$("#ip").val()+'/api/'+$("#user").val()+'/groups',
+ url: 'http://' + $("#ip").val() + '/api/' + $("#user").val() + '/groups',
processData: false,
contentType: 'application/json',
- success: function(r) {
- if(Object.keys(r).length > 0)
- {
+ success: function (r) {
+ if (Object.keys(r).length > 0) {
$('#wh_topcontainer').toggle(false);
$('#hue_grp_ids_t').toggle(true);
groupIDs = r;
var gC = 0;
- for(var groupid in r)
- {
- if(r[groupid].type=='Entertainment')
- {
- $('.gidsb').append(createTableRow([groupid+' ('+r[groupid].name+')', ''+$.i18n('wiz_hue_e_use_groupid',groupid)+' ']));
+ for (var groupid in r) {
+ if (r[groupid].type == 'Entertainment') {
+ $('.gidsb').append(createTableRow([groupid + ' (' + r[groupid].name + ')', '' + $.i18n('wiz_hue_e_use_groupid', groupid) + ' ']));
gC++;
}
}
- if(gC == 0)
- {
+ if (gC == 0) {
noAPISupport('wiz_hue_e_noegrpids');
}
}
- else
- {
+ else {
noAPISupport('wiz_hue_e_nogrpids');
}
}
});
}
-function noAPISupport(txt)
-{
+function noAPISupport(txt) {
showNotification('danger', $.i18n('wiz_hue_e_title'), $.i18n('wiz_hue_e_noapisupport_hint'));
- conf_editor.getEditor("root.specificOptions.useEntertainmentAPI").setValue( false );
+ conf_editor.getEditor("root.specificOptions.useEntertainmentAPI").setValue(false);
$("#root_specificOptions_useEntertainmentAPI").trigger("change");
- $('#btn_wiz_holder').append(''+$.i18n('wiz_hue_e_noapisupport_hint')+'
');
+ $('#btn_wiz_holder').append('' + $.i18n('wiz_hue_e_noapisupport_hint') + '
');
$('#hue_grp_ids_t').toggle(false);
var txt = (txt) ? $.i18n(txt) : $.i18n('wiz_hue_e_nogrpids');
- $(''+txt+' '+$.i18n('wiz_hue_e_noapisupport')+'
').insertBefore('#wizp2_body #hue_ids_t');
+ $('' + txt + ' ' + $.i18n('wiz_hue_e_noapisupport') + '
').insertBefore('#wizp2_body #hue_ids_t');
$('#hue_id_headline').html($.i18n('wiz_hue_desc2'));
hueType = 'philipshue';
get_hue_lights();
}
-function get_light_state(id){
+function get_light_state(id) {
$.ajax({
type: "GET",
- url: 'http://'+$("#ip").val()+'/api/'+$("#user").val()+'/lights/'+id,
+ url: 'http://' + $("#ip").val() + '/api/' + $("#user").val() + '/lights/' + id,
processData: false,
contentType: 'application/json',
- success: function(r) {
- if(Object.keys(r).length > 0)
- {
+ success: function (r) {
+ if (Object.keys(r).length > 0) {
identHueId(id, false, r['state']);
}
}
});
}
-function get_hue_lights(){
+function get_hue_lights() {
$.ajax({
type: "GET",
- url: 'http://'+$("#ip").val()+'/api/'+$("#user").val()+'/lights',
+ url: 'http://' + $("#ip").val() + '/api/' + $("#user").val() + '/lights',
processData: false,
contentType: 'application/json',
- success: function(r) {
- if(Object.keys(r).length > 0)
- {
- if(hueType == 'philipshue')
- {
+ success: function (r) {
+ if (Object.keys(r).length > 0) {
+ if (hueType == 'philipshue') {
$('#wh_topcontainer').toggle(false);
}
$('#hue_ids_t, #btn_wiz_save').toggle(true);
lightIDs = r;
var lightOptions = [
- "top", "topleft", "topright",
- "bottom", "bottomleft", "bottomright",
- "left", "lefttop", "leftmiddle", "leftbottom",
- "right", "righttop", "rightmiddle", "rightbottom",
- "entire"
- ];
+ "top", "topleft", "topright",
+ "bottom", "bottomleft", "bottomright",
+ "left", "lefttop", "leftmiddle", "leftbottom",
+ "right", "righttop", "rightmiddle", "rightbottom",
+ "entire"
+ ];
- if(hueType == 'philipshue')
- {
+ if (hueType == 'philipshue') {
lightOptions.unshift("disabled");
}
$('.lidsb').html("");
var pos = "";
- for(var lightid in r)
- {
- if(hueType == 'philipshueentertainment')
- {
- if(groupLights.indexOf(lightid) == -1) continue;
+ for (var lightid in r) {
+ if (hueType == 'philipshueentertainment') {
+ if (groupLights.indexOf(lightid) == -1) continue;
- if(groupLightsLocations.hasOwnProperty(lightid))
- {
+ if (groupLightsLocations.hasOwnProperty(lightid)) {
lightLocation = groupLightsLocations[lightid];
var x = lightLocation[0];
var y = lightLocation[1];
var z = lightLocation[2];
var xval = (x < 0) ? "left" : "right";
- if(z != 1 && x >= -0.25 && x <= 0.25 ) xval = "";
- switch (z)
- {
+ if (z != 1 && x >= -0.25 && x <= 0.25) xval = "";
+ switch (z) {
case 1: // top / Ceiling height
pos = "top" + xval;
break;
@@ -1176,45 +1131,40 @@ function get_hue_lights(){
}
}
var options = "";
- for(var opt in lightOptions)
- {
+ for (var opt in lightOptions) {
var val = lightOptions[opt];
var txt = (val != 'entire' && val != 'disabled') ? 'conf_leds_layout_cl_' : 'wiz_ids_';
- options+= ''+$.i18n(txt+val)+' ';
+ options += '' + $.i18n(txt + val) + ' ';
}
- $('.lidsb').append(createTableRow([lightid+' ('+r[lightid].name+')', ''
- + options
- + ' ',''+$.i18n('wiz_hue_blinkblue',lightid)+' ']));
+ $('.lidsb').append(createTableRow([lightid + ' (' + r[lightid].name + ')', ''
+ + options
+ + ' ', '' + $.i18n('wiz_hue_blinkblue', lightid) + ' ']));
}
- if(hueType != 'philipshueentertainment')
- {
- $('.hue_sel_watch').bind("change", function(){
+ if (hueType != 'philipshueentertainment') {
+ $('.hue_sel_watch').bind("change", function () {
var cC = 0;
- for(var key in lightIDs)
- {
- if($('#hue_'+key).val() != "disabled")
- {
+ for (var key in lightIDs) {
+ if ($('#hue_' + key).val() != "disabled") {
cC++;
}
}
- cC == 0 ? $('#btn_wiz_save').attr("disabled",true) : $('#btn_wiz_save').attr("disabled",false);
+ (cC == 0) ? $('#btn_wiz_save').attr("disabled", true) : $('#btn_wiz_save').attr("disabled", false);
});
}
$('.hue_sel_watch').trigger('change');
}
- else
- {
- var txt = ''+$.i18n('wiz_hue_noids')+'
';
+ else {
+ var txt = '' + $.i18n('wiz_hue_noids') + '
';
$('#wizp2_body').append(txt);
}
}
});
}
-function abortConnection(UserInterval){
+function abortConnection(UserInterval) {
clearInterval(UserInterval);
$('#wizp1').toggle(false);
$('#wizp2').toggle(true);
@@ -1226,16 +1176,15 @@ function abortConnection(UserInterval){
// Wizard WLED
//****************************
var lights = null;
-function startWizardWLED(e)
-{
+function startWizardWLED(e) {
//create html
var wled_title = 'wiz_wled_title';
var wled_intro1 = 'wiz_wled_intro1';
- $('#wiz_header').html(' '+$.i18n(wled_title));
- $('#wizp1_body').html(''+$.i18n(wled_title)+' '+$.i18n(wled_intro1)+'
');
- $('#wizp1_footer').html(' '+$.i18n('general_btn_continue')+' '+$.i18n('general_btn_cancel')+' ');
+ $('#wiz_header').html(' ' + $.i18n(wled_title));
+ $('#wizp1_body').html('' + $.i18n(wled_title) + ' ' + $.i18n(wled_intro1) + '
');
+ $('#wizp1_footer').html(' ' + $.i18n('general_btn_continue') + ' ' + $.i18n('general_btn_cancel') + ' ');
/*$('#wizp2_body').html('
');
@@ -1249,254 +1198,235 @@ function startWizardWLED(e)
*/
//open modal
$("#wizard_modal").modal({
- backdrop : "static",
+ backdrop: "static",
keyboard: false,
show: true
});
//listen for continue
- $('#btn_wiz_cont').off().on('click',function() {
+ $('#btn_wiz_cont').off().on('click', function () {
+ /* For testing only
-// For testing only
- discover_wled();
+ discover_wled();
- var hostAddress = conf_editor.getEditor("root.specificOptions.host").getValue();
- if(hostAddress != "")
- {
- getProperties_wled(hostAddress,"info");
- identify_wled(hostAddress)
- }
-
-// For testing only
+ var hostAddress = conf_editor.getEditor("root.specificOptions.host").getValue();
+ if(hostAddress != "")
+ {
+ getProperties_wled(hostAddress,"info");
+ identify_wled(hostAddress)
+ }
+ For testing only */
});
}
-async function discover_wled(){
+async function discover_wled() {
+ const res = await requestLedDeviceDiscovery('wled');
- const res = await requestLedDeviceDiscovery ('wled');
+ // TODO: error case unhandled
+ // res can be: false (timeout) or res.error (not found)
+ if (res && !res.error) {
+ const r = res.info
- // TODO: error case unhandled
- // res can be: false (timeout) or res.error (not found)
- if(res && !res.error){
- const r = res.info
+ // Process devices returned by discovery
+ console.log(r);
- // Process devices returned by discovery
- console.log(r);
+ if (r.devices.length == 0)
+ $('#wiz_hue_ipstate').html($.i18n('wiz_hue_failure_ip'));
+ else {
+ for (const device of r.devices) {
+ console.log("Device:", device);
- if(r.devices.length == 0)
- $('#wiz_hue_ipstate').html($.i18n('wiz_hue_failure_ip'));
- else
- {
- for(const device of r.devices)
- {
- console.log("Device:", device);
+ var ip = device.hostname + ":" + device.port;
+ console.log("Host:", ip);
- var ip = device.hostname + ":" + device.port;
- console.log("Host:", ip);
-
- //wledIPs.push({internalipaddress : ip});
- }
- }
- }
+ //wledIPs.push({internalipaddress : ip});
+ }
+ }
+ }
}
-async function getProperties_wled(hostAddress, resourceFilter){
+async function getProperties_wled(hostAddress, resourceFilter) {
+ let params = { host: hostAddress, filter: resourceFilter };
- let params = { host: hostAddress, filter: resourceFilter};
+ const res = await requestLedDeviceProperties('wled', params);
- const res = await requestLedDeviceProperties ('wled', params);
+ // TODO: error case unhandled
+ // res can be: false (timeout) or res.error (not found)
+ if (res && !res.error) {
+ const r = res.info
- // TODO: error case unhandled
- // res can be: false (timeout) or res.error (not found)
- if(res && !res.error){
- const r = res.info
-
- // Process properties returned
- console.log(r);
- }
+ // Process properties returned
+ console.log(r);
+ }
}
-function identify_wled(hostAddress){
+function identify_wled(hostAddress) {
+ let params = { host: hostAddress };
- let params = { host: hostAddress };
-
- const res = requestLedDeviceIdentification ("wled", params);
- // TODO: error case unhandled
- // res can be: false (timeout) or res.error (not found)
- if(res && !res.error){
-
- const r = res.info
- console.log(r);
- }
+ const res = requestLedDeviceIdentification("wled", params);
+ // TODO: error case unhandled
+ // res can be: false (timeout) or res.error (not found)
+ if (res && !res.error) {
+ const r = res.info
+ console.log(r);
+ }
}
//****************************
// Wizard Yeelight
//****************************
var lights = null;
-function startWizardYeelight(e)
-{
- //create html
+function startWizardYeelight(e) {
+ //create html
- var yeelight_title = 'wiz_yeelight_title';
- var yeelight_intro1 = 'wiz_yeelight_intro1';
+ var yeelight_title = 'wiz_yeelight_title';
+ var yeelight_intro1 = 'wiz_yeelight_intro1';
- $('#wiz_header').html(' '+$.i18n(yeelight_title));
- $('#wizp1_body').html(''+$.i18n(yeelight_title)+' '+$.i18n(yeelight_intro1)+'
');
+ $('#wiz_header').html(' ' + $.i18n(yeelight_title));
+ $('#wizp1_body').html('' + $.i18n(yeelight_title) + ' ' + $.i18n(yeelight_intro1) + '
');
- $('#wizp1_footer').html(' '
- +$.i18n('general_btn_continue')+' '
- +$.i18n('general_btn_cancel')+' ');
+ $('#wizp1_footer').html(' '
+ + $.i18n('general_btn_continue') + ' '
+ + $.i18n('general_btn_cancel') + ' ');
- $('#wizp2_body').html('
');
+ $('#wizp2_body').html('
');
- $('#wh_topcontainer').append('
');
+ $('#wh_topcontainer').append('
');
- $('#wizp2_body').append(''+$.i18n('wiz_yeelight_desc2')+'
');
+ $('#wizp2_body').append('' + $.i18n('wiz_yeelight_desc2') + '
');
- createTable("lidsh", "lidsb", "yee_ids_t");
- $('.lidsh').append(createTableRow([$.i18n('edt_dev_spec_lights_title'),$.i18n('wiz_pos'),$.i18n('wiz_identify')], true));
- $('#wizp2_footer').html(' '
- +$.i18n('general_btn_save')+' '
- +$.i18n('general_btn_cancel')+'');
+ createTable("lidsh", "lidsb", "yee_ids_t");
+ $('.lidsh').append(createTableRow([$.i18n('edt_dev_spec_lights_title'), $.i18n('wiz_pos'), $.i18n('wiz_identify')], true));
+ $('#wizp2_footer').html(' '
+ + $.i18n('general_btn_save') + ' '
+ + $.i18n('general_btn_cancel') + '');
- //open modal
- $("#wizard_modal").modal({backdrop : "static", keyboard: false, show: true });
+ //open modal
+ $("#wizard_modal").modal({ backdrop: "static", keyboard: false, show: true });
- //listen for continue
- $('#btn_wiz_cont').off().on('click',function() {
- beginWizardYeelight();
- $('#wizp1').toggle(false);
- $('#wizp2').toggle(true);
- });
+ //listen for continue
+ $('#btn_wiz_cont').off().on('click', function () {
+ beginWizardYeelight();
+ $('#wizp1').toggle(false);
+ $('#wizp2').toggle(true);
+ });
}
-function beginWizardYeelight()
-{
- lights = [];
- configuredLights = conf_editor.getEditor("root.specificOptions.lights").getValue();
+function beginWizardYeelight() {
+ lights = [];
+ configuredLights = conf_editor.getEditor("root.specificOptions.lights").getValue();
- discover_yeelight_lights();
+ discover_yeelight_lights();
- $('#btn_wiz_save').off().on("click", function(){
- var yeelightLedConfig = [];
- var finalLights = [];
+ $('#btn_wiz_save').off().on("click", function () {
+ var yeelightLedConfig = [];
+ var finalLights = [];
- //create yeelight led config
- for(var key in lights)
- {
- if($('#yee_'+key).val() !== "disabled")
- {
- //delete lights[key].model;
+ //create yeelight led config
+ for (var key in lights) {
+ if ($('#yee_' + key).val() !== "disabled") {
+ //delete lights[key].model;
- // Set Name to layout-position, if empty
- if ( lights[key].name === "" )
- {
- lights[key].name = $.i18n( 'conf_leds_layout_cl_'+$('#yee_'+key).val() );
- }
+ // Set Name to layout-position, if empty
+ if (lights[key].name === "") {
+ lights[key].name = $.i18n('conf_leds_layout_cl_' + $('#yee_' + key).val());
+ }
- finalLights.push( lights[key]);
+ finalLights.push(lights[key]);
- var name = lights[key].host;
- if ( lights[key].name !== "")
- name += '_'+lights[key].name;
+ var name = lights[key].host;
+ if (lights[key].name !== "")
+ name += '_' + lights[key].name;
- var idx_content = assignLightPos(key, $('#yee_'+key).val(), name);
- yeelightLedConfig.push(JSON.parse(JSON.stringify(idx_content)));
- }
- }
+ var idx_content = assignLightPos(key, $('#yee_' + key).val(), name);
+ yeelightLedConfig.push(JSON.parse(JSON.stringify(idx_content)));
+ }
+ }
- //LED layout
- window.serverConfig.leds = yeelightLedConfig;
+ //LED layout
+ window.serverConfig.leds = yeelightLedConfig;
- //LED device config
- //Start with a clean configuration
- var d = {};
+ //LED device config
+ //Start with a clean configuration
+ var d = {};
- d.type = 'yeelight';
- d.hardwareLedCount = finalLights.length;
- d.colorOrder = conf_editor.getEditor("root.generalOptions.colorOrder").getValue();
- d.colorModel = parseInt(conf_editor.getEditor("root.specificOptions.colorModel").getValue());
+ d.type = 'yeelight';
+ d.hardwareLedCount = finalLights.length;
+ d.colorOrder = conf_editor.getEditor("root.generalOptions.colorOrder").getValue();
+ d.colorModel = parseInt(conf_editor.getEditor("root.specificOptions.colorModel").getValue());
- d.transEffect = parseInt(conf_editor.getEditor("root.specificOptions.transEffect").getValue());
- d.transTime = parseInt(conf_editor.getEditor("root.specificOptions.transTime").getValue());
- d.extraTimeDarkness = parseInt(conf_editor.getEditor("root.specificOptions.extraTimeDarkness").getValue());
+ d.transEffect = parseInt(conf_editor.getEditor("root.specificOptions.transEffect").getValue());
+ d.transTime = parseInt(conf_editor.getEditor("root.specificOptions.transTime").getValue());
+ d.extraTimeDarkness = parseInt(conf_editor.getEditor("root.specificOptions.extraTimeDarkness").getValue());
- d.brightnessMin = parseInt(conf_editor.getEditor("root.specificOptions.brightnessMin").getValue());
- d.brightnessSwitchOffOnMinimum = JSON.parse(conf_editor.getEditor("root.specificOptions.brightnessSwitchOffOnMinimum").getValue());
- d.brightnessMax = parseInt(conf_editor.getEditor("root.specificOptions.brightnessMax").getValue());
- d.brightnessFactor = parseFloat(conf_editor.getEditor("root.specificOptions.brightnessFactor").getValue());
+ d.brightnessMin = parseInt(conf_editor.getEditor("root.specificOptions.brightnessMin").getValue());
+ d.brightnessSwitchOffOnMinimum = JSON.parse(conf_editor.getEditor("root.specificOptions.brightnessSwitchOffOnMinimum").getValue());
+ d.brightnessMax = parseInt(conf_editor.getEditor("root.specificOptions.brightnessMax").getValue());
+ d.brightnessFactor = parseFloat(conf_editor.getEditor("root.specificOptions.brightnessFactor").getValue());
- d.latchTime = parseInt(conf_editor.getEditor("root.specificOptions.latchTime").getValue());;
- d.debugLevel = parseInt(conf_editor.getEditor("root.specificOptions.debugLevel").getValue());
+ d.latchTime = parseInt(conf_editor.getEditor("root.specificOptions.latchTime").getValue());;
+ d.debugLevel = parseInt(conf_editor.getEditor("root.specificOptions.debugLevel").getValue());
- d.lights = finalLights;
+ d.lights = finalLights;
- window.serverConfig.device = d;
+ window.serverConfig.device = d;
- //smoothing off
- window.serverConfig.smoothing.enable = false;
+ //smoothing off
+ window.serverConfig.smoothing.enable = false;
- requestWriteConfig(window.serverConfig, true);
- resetWizard();
- });
+ requestWriteConfig(window.serverConfig, true);
+ resetWizard();
+ });
- $('#btn_wiz_abort').off().on('click', resetWizard);
+ $('#btn_wiz_abort').off().on('click', resetWizard);
}
function getHostInLights(hostname) {
- return lights.filter(
- function(lights) {
- return lights.host === hostname
- }
- );
+ return lights.filter(
+ function (lights) {
+ return lights.host === hostname
+ }
+ );
}
-async function discover_yeelight_lights(){
-
+async function discover_yeelight_lights() {
var light = {};
// Get discovered lights
- const res = await requestLedDeviceDiscovery ('yeelight');
+ const res = await requestLedDeviceDiscovery('yeelight');
// TODO: error case unhandled
// res can be: false (timeout) or res.error (not found)
- if(res && !res.error){
+ if (res && !res.error) {
const r = res.info;
- // Process devices returned by discovery
- for(const device of r.devices)
- {
- //console.log("Device:", device);
+ // Process devices returned by discovery
+ for (const device of r.devices) {
+ //console.log("Device:", device);
- if( device.hostname !== "")
- {
- if ( getHostInLights ( device.hostname ).length === 0 )
- {
- light = {};
- light.host = device.hostname;
- light.port = device.port;
+ if (device.hostname !== "") {
+ if (getHostInLights(device.hostname).length === 0) {
+ light = {};
+ light.host = device.hostname;
+ light.port = device.port;
- light.name = device.other.name;
- light.model = device.other.model;
- lights.push(light);
- }
- }
- }
+ light.name = device.other.name;
+ light.model = device.other.model;
+ lights.push(light);
+ }
+ }
+ }
// Add additional items from configuration
- for(var keyConfig in configuredLights)
- {
-
- var [host, port]= configuredLights[keyConfig].host.split(":", 2);
+ for (var keyConfig in configuredLights) {
+ var [host, port] = configuredLights[keyConfig].host.split(":", 2);
//In case port has been explicitly provided, overwrite port given as part of hostname
- if ( configuredLights[keyConfig].port !== 0 )
+ if (configuredLights[keyConfig].port !== 0)
port = configuredLights[keyConfig].port;
- if ( host !== "" )
- if ( getHostInLights ( host ).length === 0 )
- {
+ if (host !== "")
+ if (getHostInLights(host).length === 0) {
light = {};
light.host = host;
light.port = port;
@@ -1510,476 +1440,434 @@ async function discover_yeelight_lights(){
}
}
-function assign_yeelight_lights(){
+function assign_yeelight_lights() {
+ var models = ['color', 'color1', 'color2', 'color4', 'stripe', 'strip1'];
- var models = ['color', 'color1', 'color2', 'color4', 'stripe', 'strip1'];
+ // If records are left for configuration
+ if (Object.keys(lights).length > 0) {
+ $('#wh_topcontainer').toggle(false);
+ $('#yee_ids_t,#btn_wiz_save').toggle(true);
- // If records are left for configuration
- if(Object.keys(lights).length > 0)
- {
- $('#wh_topcontainer').toggle(false);
- $('#yee_ids_t, #btn_wiz_save').toggle(true);
+ var lightOptions = [
+ "top", "topleft", "topright",
+ "bottom", "bottomleft", "bottomright",
+ "left", "lefttop", "leftmiddle", "leftbottom",
+ "right", "righttop", "rightmiddle", "rightbottom",
+ "entire"
+ ];
- var lightOptions = [
- "top", "topleft", "topright",
- "bottom", "bottomleft", "bottomright",
- "left", "lefttop", "leftmiddle", "leftbottom",
- "right", "righttop", "rightmiddle", "rightbottom",
- "entire"
- ];
+ lightOptions.unshift("disabled");
- lightOptions.unshift("disabled");
+ $('.lidsb').html("");
+ var pos = "";
- $('.lidsb').html("");
- var pos = "";
+ for (var lightid in lights) {
+ var lightHostname = lights[lightid].host;
+ var lightPort = lights[lightid].port;
+ var lightName = lights[lightid].name;
- for(var lightid in lights)
- {
- var lightHostname = lights[lightid].host;
- var lightPort = lights[lightid].port;
- var lightName = lights[lightid].name;
+ if (lightName === "")
+ lightName = $.i18n('edt_dev_spec_lights_itemtitle');
- if ( lightName === "" )
- lightName = $.i18n('edt_dev_spec_lights_itemtitle');
+ var options = "";
+ for (var opt in lightOptions) {
+ var val = lightOptions[opt];
+ var txt = (val !== 'entire' && val !== 'disabled') ? 'conf_leds_layout_cl_' : 'wiz_ids_';
+ options += '' + $.i18n(txt + val) + ' ';
+ }
- var options = "";
- for(var opt in lightOptions)
- {
- var val = lightOptions[opt];
- var txt = (val !== 'entire' && val !== 'disabled') ? 'conf_leds_layout_cl_' : 'wiz_ids_';
- options+= ''+$.i18n(txt+val)+' ';
- }
+ var enabled = 'enabled'
+ if (!models.includes(lights[lightid].model)) {
+ var enabled = 'disabled';
+ options = '' + $.i18n('wiz_yeelight_unsupported') + ' ';
+ }
- var enabled = 'enabled';
- if (! models.includes (lights[lightid].model) )
- {
- var enabled = 'disabled';
- options = ''+$.i18n('wiz_yeelight_unsupported')+' ';
- }
+ $('.lidsb').append(createTableRow([(parseInt(lightid, 10) + 1) + '. ' + lightName + ' (' + lightHostname + ')', ''
+ + options
+ + ' ', ''
+ + $.i18n('wiz_identify_light', lightName) + ' ']));
+ }
- $('.lidsb').append(createTableRow([(parseInt(lightid, 10) + 1)+'. '+lightName+' ('+lightHostname+')', ''
- + options
- + ' ',''
- + $.i18n('wiz_identify_light',lightName)+' ']));
- }
-
- $('.yee_sel_watch').bind("change", function(){
- var cC = 0;
- for(var key in lights)
- {
- if($('#yee_'+key).val() !== "disabled")
- {
- cC++;
- }
- }
- if ( cC === 0)
- $('#btn_wiz_save').attr("disabled",true);
- else
- $('#btn_wiz_save').attr("disabled",false);
- });
- $('.yee_sel_watch').trigger('change');
- }
- else
- {
- var noLightsTxt = ''+$.i18n('wiz_yeelight_noLights')+'
';
- $('#wizp2_body').append(noLightsTxt);
- }
+ $('.yee_sel_watch').bind("change", function () {
+ var cC = 0;
+ for (var key in lights) {
+ if ($('#yee_' + key).val() !== "disabled") {
+ cC++;
+ }
+ }
+ if (cC === 0)
+ $('#btn_wiz_save').attr("disabled", true);
+ else
+ $('#btn_wiz_save').attr("disabled", false);
+ });
+ $('.yee_sel_watch').trigger('change');
+ }
+ else {
+ var noLightsTxt = '' + $.i18n('wiz_yeelight_noLights') + '
';
+ $('#wizp2_body').append(noLightsTxt);
+ }
}
-async function getProperties_yeelight(hostname, port){
+async function getProperties_yeelight(hostname, port) {
+ let params = { hostname: hostname, port: port };
- let params = { hostname: hostname, port: port};
+ const res = await requestLedDeviceProperties('yeelight', params);
- const res = await requestLedDeviceProperties ('yeelight', params);
+ // TODO: error case unhandled
+ // res can be: false (timeout) or res.error (not found)
+ if (res && !res.error) {
+ const r = res.info
- // TODO: error case unhandled
- // res can be: false (timeout) or res.error (not found)
- if(res && !res.error){
- const r = res.info
-
- // Process properties returned
- console.log(r);
- }
+ // Process properties returned
+ console.log(r);
+ }
}
-function identify_yeelight_device(hostname, port){
+function identify_yeelight_device(hostname, port) {
+ let params = { hostname: hostname, port: port };
- let params = { hostname: hostname, port: port };
-
- const res = requestLedDeviceIdentification ("yeelight", params);
- // TODO: error case unhandled
- // res can be: false (timeout) or res.error (not found)
- if(res && !res.error){
- //const r = res.info;
- }
+ const res = requestLedDeviceIdentification("yeelight", params);
+ // TODO: error case unhandled
+ // res can be: false (timeout) or res.error (not found)
+ if (res && !res.error) {
+ //const r = res.info;
+ }
}
//****************************
// Wizard AtmoOrb
//****************************
var lights = null;
-function startWizardAtmoOrb(e)
-{
- //create html
+function startWizardAtmoOrb(e) {
+ //create html
- var atmoorb_title = 'wiz_atmoorb_title';
- var atmoorb_intro1 = 'wiz_atmoorb_intro1';
+ var atmoorb_title = 'wiz_atmoorb_title';
+ var atmoorb_intro1 = 'wiz_atmoorb_intro1';
- $('#wiz_header').html(' '+$.i18n(atmoorb_title));
- $('#wizp1_body').html(''+$.i18n(atmoorb_title)+' '+$.i18n(atmoorb_intro1)+'
');
+ $('#wiz_header').html(' ' + $.i18n(atmoorb_title));
+ $('#wizp1_body').html('' + $.i18n(atmoorb_title) + ' ' + $.i18n(atmoorb_intro1) + '
');
- $('#wizp1_footer').html(' '
- +$.i18n('general_btn_continue')+' '
- +$.i18n('general_btn_cancel')+' ');
+ $('#wizp1_footer').html(' '
+ + $.i18n('general_btn_continue') + ' '
+ + $.i18n('general_btn_cancel') + ' ');
- $('#wizp2_body').html('
');
+ $('#wizp2_body').html('
');
- $('#wh_topcontainer').append('
');
+ $('#wh_topcontainer').append('
');
- $('#wizp2_body').append(''+$.i18n('wiz_atmoorb_desc2')+'
');
+ $('#wizp2_body').append('' + $.i18n('wiz_atmoorb_desc2') + '
');
- createTable("lidsh", "lidsb", "orb_ids_t");
- $('.lidsh').append(createTableRow([$.i18n('edt_dev_spec_lights_title'),$.i18n('wiz_pos'),$.i18n('wiz_identify')], true));
- $('#wizp2_footer').html(' '
- +$.i18n('general_btn_save')+' '
- +$.i18n('general_btn_cancel')+'');
+ createTable("lidsh", "lidsb", "orb_ids_t");
+ $('.lidsh').append(createTableRow([$.i18n('edt_dev_spec_lights_title'), $.i18n('wiz_pos'), $.i18n('wiz_identify')], true));
+ $('#wizp2_footer').html(' '
+ + $.i18n('general_btn_save') + ' '
+ + $.i18n('general_btn_cancel') + '');
- //open modal
- $("#wizard_modal").modal({backdrop : "static", keyboard: false, show: true });
+ //open modal
+ $("#wizard_modal").modal({ backdrop: "static", keyboard: false, show: true });
- //listen for continue
- $('#btn_wiz_cont').off().on('click',function() {
- beginWizardAtmoOrb();
- $('#wizp1').toggle(false);
- $('#wizp2').toggle(true);
- });
+ //listen for continue
+ $('#btn_wiz_cont').off().on('click', function () {
+ beginWizardAtmoOrb();
+ $('#wizp1').toggle(false);
+ $('#wizp2').toggle(true);
+ });
}
-function beginWizardAtmoOrb()
-{
- lights = [];
- configuredLights = [];
+function beginWizardAtmoOrb() {
+ lights = [];
+ configuredLights = [];
- configruedOrbIds = conf_editor.getEditor("root.specificOptions.orbIds").getValue().trim();
- if ( configruedOrbIds.length !== 0 )
- {
- configuredLights = configruedOrbIds.split(",").map( Number );
- }
+ configruedOrbIds = conf_editor.getEditor("root.specificOptions.orbIds").getValue().trim();
+ if (configruedOrbIds.length !== 0) {
+ configuredLights = configruedOrbIds.split(",").map(Number);
+ }
- var multiCastGroup = conf_editor.getEditor("root.specificOptions.output").getValue();
- var multiCastPort = parseInt(conf_editor.getEditor("root.specificOptions.port").getValue());
+ var multiCastGroup = conf_editor.getEditor("root.specificOptions.output").getValue();
+ var multiCastPort = parseInt(conf_editor.getEditor("root.specificOptions.port").getValue());
- discover_atmoorb_lights(multiCastGroup, multiCastPort);
+ discover_atmoorb_lights(multiCastGroup, multiCastPort);
- $('#btn_wiz_save').off().on("click", function(){
- var atmoorbLedConfig = [];
- var finalLights = [];
+ $('#btn_wiz_save').off().on("click", function () {
+ var atmoorbLedConfig = [];
+ var finalLights = [];
- //create atmoorb led config
- for(var key in lights)
- {
- if($('#orb_'+key).val() !== "disabled")
- {
- // Set Name to layout-position, if empty
- if ( lights[key].name === "" )
- {
- lights[key].name = $.i18n( 'conf_leds_layout_cl_'+$('#orb_'+key).val() );
- }
+ //create atmoorb led config
+ for (var key in lights) {
+ if ($('#orb_' + key).val() !== "disabled") {
+ // Set Name to layout-position, if empty
+ if (lights[key].name === "") {
+ lights[key].name = $.i18n('conf_leds_layout_cl_' + $('#orb_' + key).val());
+ }
- finalLights.push( lights[key].id);
+ finalLights.push(lights[key].id);
- var name = lights[key].id;
- if ( lights[key].host !== "")
- name += ':' + lights[key].host;
+ var name = lights[key].id;
+ if (lights[key].host !== "")
+ name += ':' + lights[key].host;
- var idx_content = assignLightPos(key, $('#orb_'+key).val(), name);
- atmoorbLedConfig.push(JSON.parse(JSON.stringify(idx_content)));
- }
- }
+ var idx_content = assignLightPos(key, $('#orb_' + key).val(), name);
+ atmoorbLedConfig.push(JSON.parse(JSON.stringify(idx_content)));
+ }
+ }
- //LED layout
- window.serverConfig.leds = atmoorbLedConfig;
+ //LED layout
+ window.serverConfig.leds = atmoorbLedConfig;
- //LED device config
- //Start with a clean configuration
- var d = {};
+ //LED device config
+ //Start with a clean configuration
+ var d = {};
- d.type = 'atmoorb';
- d.hardwareLedCount = finalLights.length;
- d.colorOrder = conf_editor.getEditor("root.generalOptions.colorOrder").getValue();
+ d.type = 'atmoorb';
+ d.hardwareLedCount = finalLights.length;
+ d.colorOrder = conf_editor.getEditor("root.generalOptions.colorOrder").getValue();
- d.orbIds = finalLights.toString();
- d.useOrbSmoothing = (eV("useOrbSmoothing") == true);
+ d.orbIds = finalLights.toString();
+ d.useOrbSmoothing = (eV("useOrbSmoothing") == true);
- d.output = conf_editor.getEditor("root.specificOptions.output").getValue();
- d.port = parseInt(conf_editor.getEditor("root.specificOptions.port").getValue());
- d.latchTime = parseInt(conf_editor.getEditor("root.specificOptions.latchTime").getValue());;
+ d.output = conf_editor.getEditor("root.specificOptions.output").getValue();
+ d.port = parseInt(conf_editor.getEditor("root.specificOptions.port").getValue());
+ d.latchTime = parseInt(conf_editor.getEditor("root.specificOptions.latchTime").getValue());;
- window.serverConfig.device = d;
+ window.serverConfig.device = d;
- requestWriteConfig(window.serverConfig, true);
- resetWizard();
- });
+ requestWriteConfig(window.serverConfig, true);
+ resetWizard();
+ });
- $('#btn_wiz_abort').off().on('click', resetWizard);
+ $('#btn_wiz_abort').off().on('click', resetWizard);
}
function getIdInLights(id) {
- return lights.filter(
- function(lights) {
- return lights.id === id
- }
- );
+ return lights.filter(
+ function (lights) {
+ return lights.id === id
+ }
+ );
}
-async function discover_atmoorb_lights(multiCastGroup, multiCastPort){
-
+async function discover_atmoorb_lights(multiCastGroup, multiCastPort) {
var light = {};
- if ( multiCastGroup === "" )
- multiCastGroup = "239.255.255.250";
+ if (multiCastGroup === "")
+ multiCastGroup = "239.255.255.250";
- if ( multiCastPort === "")
+ if (multiCastPort === "")
multiCastPort = 49692;
- let params = { multiCastGroup : multiCastGroup, multiCastPort : multiCastPort};
+ let params = { multiCastGroup: multiCastGroup, multiCastPort: multiCastPort };
// Get discovered lights
- const res = await requestLedDeviceDiscovery ('atmoorb', params);
+ const res = await requestLedDeviceDiscovery('atmoorb', params);
// TODO: error case unhandled
// res can be: false (timeout) or res.error (not found)
- if(res && !res.error){
- const r = res.info;
+ if (res && !res.error) {
+ const r = res.info
- // Process devices returned by discovery
- for(const device of r.devices)
- {
- if( device.id !== "")
- {
- if ( getIdInLights ( device.id ).length === 0 )
- {
- light = {};
- light.id = device.id;
- light.ip = device.ip;
- light.host = device.hostname;
- lights.push(light);
- }
- }
- }
-
- // Add additional items from configuration
- for(const keyConfig in configuredLights)
- {
- if ( configuredLights[keyConfig] !== "" && !isNaN(configuredLights[keyConfig]) )
- {
- if ( getIdInLights ( configuredLights[keyConfig] ).length === 0 )
- {
- light = {};
- light.id = configuredLights[keyConfig];
- light.ip = "";
- light.host = "";
- lights.push(light);
- }
- }
+ // Process devices returned by discovery
+ for (const device of r.devices) {
+ if (device.id !== "") {
+ if (getIdInLights(device.id).length === 0) {
+ light = {};
+ light.id = device.id;
+ light.ip = device.ip;
+ light.host = device.hostname;
+ lights.push(light);
+ }
+ }
}
- lights.sort((a, b) => (a.id > b.id) ? 1 : -1);
+ // Add additional items from configuration
+ for (const keyConfig in configuredLights) {
+ if (configuredLights[keyConfig] !== "" && !isNaN(configuredLights[keyConfig])) {
+ if (getIdInLights(configuredLights[keyConfig]).length === 0) {
+ light = {};
+ light.id = configuredLights[keyConfig];
+ light.ip = "";
+ light.host = "";
+ lights.push(light);
+ }
+ }
+ }
+
+ lights.sort((a, b) => (a.id > b.id) ? 1 : -1);
assign_atmoorb_lights();
}
}
-function assign_atmoorb_lights(){
+function assign_atmoorb_lights() {
+ // If records are left for configuration
+ if (Object.keys(lights).length > 0) {
+ $('#wh_topcontainer').toggle(false);
+ $('#orb_ids_t, #btn_wiz_save').toggle(true);
- // If records are left for configuration
- if(Object.keys(lights).length > 0)
- {
- $('#wh_topcontainer').toggle(false);
- $('#orb_ids_t, #btn_wiz_save').toggle(true);
+ var lightOptions = [
+ "top", "topleft", "topright",
+ "bottom", "bottomleft", "bottomright",
+ "left", "lefttop", "leftmiddle", "leftbottom",
+ "right", "righttop", "rightmiddle", "rightbottom",
+ "entire"
+ ];
- var lightOptions = [
- "top", "topleft", "topright",
- "bottom", "bottomleft", "bottomright",
- "left", "lefttop", "leftmiddle", "leftbottom",
- "right", "righttop", "rightmiddle", "rightbottom",
- "entire"
- ];
+ lightOptions.unshift("disabled");
- lightOptions.unshift("disabled");
+ $('.lidsb').html("");
+ var pos = "";
- $('.lidsb').html("");
- var pos = "";
+ for (var lightid in lights) {
+ var orbId = lights[lightid].id;
+ var orbIp = lights[lightid].ip;
+ var orbHostname = lights[lightid].host;
- for(var lightid in lights)
- {
- var orbId = lights[lightid].id;
- var orbIp = lights[lightid].ip;
- var orbHostname = lights[lightid].host;
+ if (orbHostname === "")
+ orbHostname = $.i18n('edt_dev_spec_lights_itemtitle');
- if ( orbHostname === "" )
- orbHostname = $.i18n('edt_dev_spec_lights_itemtitle');
+ var options = "";
+ for (var opt in lightOptions) {
+ var val = lightOptions[opt];
+ var txt = (val !== 'entire' && val !== 'disabled') ? 'conf_leds_layout_cl_' : 'wiz_ids_';
+ options += '' + $.i18n(txt + val) + ' ';
+ }
- var options = "";
- for(var opt in lightOptions)
- {
- var val = lightOptions[opt];
- var txt = (val !== 'entire' && val !== 'disabled') ? 'conf_leds_layout_cl_' : 'wiz_ids_';
- options+= ''+$.i18n(txt+val)+' ';
- }
+ var enabled = 'enabled'
+ if (orbId < 1 || orbId > 255) {
+ enabled = 'disabled'
+ options = '' + $.i18n('wiz_atmoorb_unsupported') + ' ';
+ }
- var enabled = 'enabled';
- if ( orbId < 1 || orbId > 255 )
- {
- enabled = 'disabled';
- options = ''+$.i18n('wiz_atmoorb_unsupported')+' ';
- }
+ var lightAnnotation = "";
+ if (orbIp !== "") {
+ lightAnnotation = ': ' + orbIp + ' (' + orbHostname + ')';
+ }
- var lightAnnotation ="";
- if ( orbIp !== "" )
- {
- lightAnnotation = ': '+orbIp+' ('+orbHostname+')';
- }
+ $('.lidsb').append(createTableRow([orbId + lightAnnotation, ''
+ + options
+ + ' ', ''
+ + $.i18n('wiz_identify_light', orbId) + ' ']));
+ }
- $('.lidsb').append(createTableRow([orbId + lightAnnotation, ''
- + options
- + ' ',''
- + $.i18n('wiz_identify_light',orbId)+' ']));
- }
-
- $('.orb_sel_watch').bind("change", function(){
- var cC = 0;
- for(var key in lights)
- {
- if($('#orb_'+key).val() !== "disabled")
- {
- cC++;
- }
- }
- if ( cC === 0)
- $('#btn_wiz_save').attr("disabled",true);
- else
- $('#btn_wiz_save').attr("disabled",false);
- });
- $('.orb_sel_watch').trigger('change');
- }
- else
- {
- var noLightsTxt = ''+$.i18n('wiz_atmoorb_noLights')+'
';
- $('#wizp2_body').append(noLightsTxt);
- }
+ $('.orb_sel_watch').bind("change", function () {
+ var cC = 0;
+ for (var key in lights) {
+ if ($('#orb_' + key).val() !== "disabled") {
+ cC++;
+ }
+ }
+ if (cC === 0)
+ $('#btn_wiz_save').attr("disabled", true);
+ else
+ $('#btn_wiz_save').attr("disabled", false);
+ });
+ $('.orb_sel_watch').trigger('change');
+ }
+ else {
+ var noLightsTxt = '' + $.i18n('wiz_atmoorb_noLights') + '
';
+ $('#wizp2_body').append(noLightsTxt);
+ }
}
-function identify_atmoorb_device(orbId){
+function identify_atmoorb_device(orbId) {
+ let params = { id: orbId };
- let params = { id : orbId };
-
- const res = requestLedDeviceIdentification ("atmoorb", params);
- // TODO: error case unhandled
- // res can be: false (timeout) or res.error (not found)
- if(res && !res.error){
- const r = res.info
- }
+ const res = requestLedDeviceIdentification("atmoorb", params);
+ // TODO: error case unhandled
+ // res can be: false (timeout) or res.error (not found)
+ if (res && !res.error) {
+ const r = res.info
+ }
}
//****************************
// Wizard/Routines Nanoleaf
//****************************
-async function discover_nanoleaf(){
+async function discover_nanoleaf() {
+ const res = await requestLedDeviceDiscovery('nanoleaf');
- const res = await requestLedDeviceDiscovery ('nanoleaf');
+ // TODO: error case unhandled
+ // res can be: false (timeout) or res.error (not found)
+ if (res && !res.error) {
+ const r = res.info
- // TODO: error case unhandled
- // res can be: false (timeout) or res.error (not found)
- if(res && !res.error){
- const r = res.info
+ // Process devices returned by discovery
+ console.log(r);
- // Process devices returned by discovery
- console.log(r);
+ if (r.devices.length == 0)
+ $('#wiz_hue_ipstate').html($.i18n('wiz_hue_failure_ip'));
+ else {
+ for (const device of r.devices) {
+ console.log("Device:", device);
- if(r.devices.length == 0)
- $('#wiz_hue_ipstate').html($.i18n('wiz_hue_failure_ip'));
- else
- {
- for(const device of r.devices)
- {
- console.log("Device:", device);
+ var ip = device.hostname + ":" + device.port;
+ console.log("Host:", ip);
- var ip = device.hostname + ":" + device.port;
- console.log("Host:", ip);
-
- //nanoleafIPs.push({internalipaddress : ip});
- }
- }
- }
+ //nanoleafIPs.push({internalipaddress : ip});
+ }
+ }
+ }
}
-async function getProperties_nanoleaf(hostAddress, authToken, resourceFilter){
+async function getProperties_nanoleaf(hostAddress, authToken, resourceFilter) {
+ let params = { host: hostAddress, token: authToken, filter: resourceFilter };
- let params = { host: hostAddress, token: authToken, filter: resourceFilter};
+ const res = await requestLedDeviceProperties('nanoleaf', params);
- const res = await requestLedDeviceProperties ('nanoleaf', params);
+ // TODO: error case unhandled
+ // res can be: false (timeout) or res.error (not found)
+ if (res && !res.error) {
+ const r = res.info
- // TODO: error case unhandled
- // res can be: false (timeout) or res.error (not found)
- if(res && !res.error){
- const r = res.info
-
- // Process properties returned
- console.log(r);
- }
+ // Process properties returned
+ console.log(r);
+ }
}
-function identify_nanoleaf(hostAddress, authToken){
+function identify_nanoleaf(hostAddress, authToken) {
+ let params = { host: hostAddress, token: authToken };
- let params = { host: hostAddress, token: authToken};
-
- const res = requestLedDeviceIdentification ("nanoleaf", params);
- // TODO: error case unhandled
- // res can be: false (timeout) or res.error (not found)
- if(res && !res.error){
-
- const r = res.info
- console.log(r);
- }
+ const res = requestLedDeviceIdentification("nanoleaf", params);
+ // TODO: error case unhandled
+ // res can be: false (timeout) or res.error (not found)
+ if (res && !res.error) {
+ const r = res.info
+ console.log(r);
+ }
}
//****************************
// Wizard/Routines RS232-Devices
//****************************
-async function discover_providerRs232(rs232Type){
+async function discover_providerRs232(rs232Type) {
+ const res = await requestLedDeviceDiscovery(rs232Type);
- const res = await requestLedDeviceDiscovery (rs232Type);
+ // TODO: error case unhandled
+ // res can be: false (timeout) or res.error (not found)
+ if (res && !res.error) {
+ const r = res.info
- // TODO: error case unhandled
- // res can be: false (timeout) or res.error (not found)
- if(res && !res.error){
- const r = res.info
-
- // Process serialPorts returned by discover
- console.log(r);
- }
+ // Process serialPorts returned by discover
+ console.log(r);
+ }
}
//****************************
// Wizard/Routines HID (USB)-Devices
//****************************
-async function discover_providerHid(hidType){
+async function discover_providerHid(hidType) {
+ const res = await requestLedDeviceDiscovery(hidType);
+ console.log("discover_providerHid", res);
- const res = await requestLedDeviceDiscovery (hidType);
- console.log("discover_providerHid" ,res);
+ // TODO: error case unhandled
+ // res can be: false (timeout) or res.error (not found)
+ if (res && !res.error) {
+ const r = res.info
- // TODO: error case unhandled
- // res can be: false (timeout) or res.error (not found)
- if(res && !res.error){
- const r = res.info
-
- // Process HID returned by discover
- console.log(r);
- }
+ // Process HID returned by discover
+ console.log(r);
+ }
}
-