mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
New LED Device - Cololight (#1070)
This commit is contained in:
@@ -59,40 +59,36 @@ function createLedPreview(leds, origin){
|
||||
|
||||
}
|
||||
|
||||
function createClassicLeds(){
|
||||
//get values
|
||||
var ledstop = parseInt($("#ip_cl_top").val());
|
||||
var ledsbottom = parseInt($("#ip_cl_bottom").val());
|
||||
var ledsleft = parseInt($("#ip_cl_left").val());
|
||||
var ledsright = parseInt($("#ip_cl_right").val());
|
||||
var ledsglength = parseInt($("#ip_cl_glength").val());
|
||||
var ledsgpos = parseInt($("#ip_cl_gpos").val());
|
||||
var position = parseInt($("#ip_cl_position").val());
|
||||
var reverse = $("#ip_cl_reverse").is(":checked");
|
||||
function createClassicLedLayoutSimple( ledstop,ledsleft,ledsright,ledsbottom,position,reverse ){
|
||||
|
||||
//advanced values
|
||||
var ledsVDepth = parseInt($("#ip_cl_vdepth").val())/100;
|
||||
var ledsHDepth = parseInt($("#ip_cl_hdepth").val())/100;
|
||||
var edgeVGap = parseInt($("#ip_cl_edgegap").val())/100/2;
|
||||
//var cornerVGap = parseInt($("#ip_cl_cornergap").val())/100/2;
|
||||
var overlap = $("#ip_cl_overlap").val()/100;
|
||||
let params = {
|
||||
ledstop: 0, ledsleft: 0, ledsright: 0, ledsbottom: 0,
|
||||
ledsglength: 0, ledsgpos: 0, position: 0,
|
||||
ledsHDepth: 0.08, ledsVDepth: 0.05, overlap: 0,
|
||||
edgeVGap: 0,
|
||||
ptblh: 0, ptblv: 1, ptbrh: 1, ptbrv: 1,
|
||||
pttlh: 0, pttlv: 0, pttrh: 1, pttrv: 0,
|
||||
reverse:false
|
||||
};
|
||||
|
||||
params.ledstop = ledstop;
|
||||
params.ledsleft = ledsleft;
|
||||
params.ledsright = ledsright;
|
||||
params.ledsbottom = ledsbottom;
|
||||
params.position = position;
|
||||
params.reverse = reverse;
|
||||
|
||||
//trapezoid values % -> float
|
||||
var ptblh = parseInt($("#ip_cl_pblh").val())/100;
|
||||
var ptblv = parseInt($("#ip_cl_pblv").val())/100;
|
||||
var ptbrh = parseInt($("#ip_cl_pbrh").val())/100;
|
||||
var ptbrv = parseInt($("#ip_cl_pbrv").val())/100;
|
||||
var pttlh = parseInt($("#ip_cl_ptlh").val())/100;
|
||||
var pttlv = parseInt($("#ip_cl_ptlv").val())/100;
|
||||
var pttrh = parseInt($("#ip_cl_ptrh").val())/100;
|
||||
var pttrv = parseInt($("#ip_cl_ptrv").val())/100;
|
||||
return createClassicLedLayout( params );
|
||||
}
|
||||
|
||||
function createClassicLedLayout( params ){
|
||||
|
||||
//helper
|
||||
var edgeHGap = edgeVGap/(16/9);
|
||||
var edgeHGap = params.edgeVGap/(16/9);
|
||||
var ledArray = [];
|
||||
|
||||
function createFinalArray(array){
|
||||
finalLedArray = [];
|
||||
var finalLedArray = [];
|
||||
for(var i = 0; i<array.length; i++){
|
||||
var hmin = array[i].hmin;
|
||||
var hmax = array[i].hmax;
|
||||
@@ -100,7 +96,7 @@ function createClassicLeds(){
|
||||
var vmax = array[i].vmax;
|
||||
finalLedArray[i] = { "hmax": hmax, "hmin": hmin, "vmax": vmax, "vmin": vmin }
|
||||
}
|
||||
createLedPreview(finalLedArray, 'classic');
|
||||
return finalLedArray;
|
||||
}
|
||||
|
||||
function rotateArray(array, times){
|
||||
@@ -131,9 +127,9 @@ function createClassicLeds(){
|
||||
function ovl(scan,val)
|
||||
{
|
||||
if(scan == "+")
|
||||
return valScan(val += overlap);
|
||||
return valScan(val += params.overlap);
|
||||
else
|
||||
return valScan(val -= overlap);
|
||||
return valScan(val -= params.overlap);
|
||||
}
|
||||
|
||||
function createLedArray(hmin, hmax, vmin, vmax){
|
||||
@@ -145,53 +141,53 @@ function createClassicLeds(){
|
||||
}
|
||||
|
||||
function createTopLeds(){
|
||||
var steph = (pttrh - pttlh - (2*edgeHGap))/ledstop;
|
||||
var stepv = (pttrv - pttlv)/ledstop;
|
||||
var steph = (params.pttrh - params.pttlh - (2*edgeHGap))/params.ledstop;
|
||||
var stepv = (params.pttrv - params.pttlv)/params.ledstop;
|
||||
|
||||
for (var i = 0; i<ledstop; i++){
|
||||
var hmin = ovl("-",pttlh+(steph*Number([i]))+edgeHGap);
|
||||
var hmax = ovl("+",pttlh+(steph*Number([i+1]))+edgeHGap);
|
||||
var vmin = pttlv+(stepv*Number([i]));
|
||||
var vmax = vmin + ledsHDepth;
|
||||
for (var i = 0; i<params.ledstop; i++){
|
||||
var hmin = ovl("-",params.pttlh+(steph*Number([i]))+edgeHGap);
|
||||
var hmax = ovl("+",params.pttlh+(steph*Number([i+1]))+edgeHGap);
|
||||
var vmin = params.pttlv+(stepv*Number([i]));
|
||||
var vmax = vmin + params.ledsHDepth;
|
||||
createLedArray(hmin, hmax, vmin, vmax);
|
||||
}
|
||||
}
|
||||
|
||||
function createRightLeds(){
|
||||
var steph = (ptbrh - pttrh)/ledsright;
|
||||
var stepv = (ptbrv - pttrv - (2*edgeVGap))/ledsright;
|
||||
var steph = (params.ptbrh - params.pttrh)/params.ledsright;
|
||||
var stepv = (params.ptbrv - params.pttrv - (2*params.edgeVGap))/params.ledsright;
|
||||
|
||||
for (var i = 0; i<ledsright; i++){
|
||||
var hmax = pttrh+(steph*Number([i+1]));
|
||||
var hmin = hmax-ledsVDepth;
|
||||
var vmin = ovl("-",pttrv+(stepv*Number([i]))+edgeVGap);
|
||||
var vmax = ovl("+",pttrv+(stepv*Number([i+1]))+edgeVGap);
|
||||
for (var i = 0; i<params.ledsright; i++){
|
||||
var hmax = params.pttrh+(steph*Number([i+1]));
|
||||
var hmin = hmax-params.ledsVDepth;
|
||||
var vmin = ovl("-",params.pttrv+(stepv*Number([i]))+params.edgeVGap);
|
||||
var vmax = ovl("+",params.pttrv+(stepv*Number([i+1]))+params.edgeVGap);
|
||||
createLedArray(hmin, hmax, vmin, vmax);
|
||||
}
|
||||
}
|
||||
|
||||
function createBottomLeds(){
|
||||
var steph = (ptbrh - ptblh - (2*edgeHGap))/ledsbottom;
|
||||
var stepv = (ptbrv - ptblv)/ledsbottom;
|
||||
var steph = (params.ptbrh - params.ptblh - (2*edgeHGap))/params.ledsbottom;
|
||||
var stepv = (params.ptbrv - params.ptblv)/params.ledsbottom;
|
||||
|
||||
for (var i = ledsbottom-1; i>-1; i--){
|
||||
var hmin = ovl("-",ptblh+(steph*Number([i]))+edgeHGap);
|
||||
var hmax = ovl("+",ptblh+(steph*Number([i+1]))+edgeHGap);
|
||||
var vmax= ptblv+(stepv*Number([i]));
|
||||
var vmin = vmax-ledsHDepth;
|
||||
for (var i = params.ledsbottom-1; i>-1; i--){
|
||||
var hmin = ovl("-",params.ptblh+(steph*Number([i]))+edgeHGap);
|
||||
var hmax = ovl("+",params.ptblh+(steph*Number([i+1]))+edgeHGap);
|
||||
var vmax= params.ptblv+(stepv*Number([i]));
|
||||
var vmin = vmax-params.ledsHDepth;
|
||||
createLedArray(hmin, hmax, vmin, vmax);
|
||||
}
|
||||
}
|
||||
|
||||
function createLeftLeds(){
|
||||
var steph = (ptblh - pttlh)/ledsleft;
|
||||
var stepv = (ptblv - pttlv - (2*edgeVGap))/ledsleft;
|
||||
var steph = (params.ptblh - params.pttlh)/params.ledsleft;
|
||||
var stepv = (params.ptblv - params.pttlv - (2*params.edgeVGap))/params.ledsleft;
|
||||
|
||||
for (var i = ledsleft-1; i>-1; i--){
|
||||
var hmin = pttlh+(steph*Number([i]));
|
||||
var hmax = hmin+ledsVDepth;
|
||||
var vmin = ovl("-",pttlv+(stepv*Number([i]))+edgeVGap);
|
||||
var vmax = ovl("+",pttlv+(stepv*Number([i+1]))+edgeVGap);
|
||||
for (var i = params.ledsleft-1; i>-1; i--){
|
||||
var hmin = params.pttlh+(steph*Number([i]));
|
||||
var hmax = hmin+params.ledsVDepth;
|
||||
var vmin = ovl("-",params.pttlv+(stepv*Number([i]))+params.edgeVGap);
|
||||
var vmax = ovl("+",params.pttlv+(stepv*Number([i+1]))+params.edgeVGap);
|
||||
createLedArray(hmin, hmax, vmin, vmax);
|
||||
}
|
||||
|
||||
@@ -202,47 +198,87 @@ function createClassicLeds(){
|
||||
createRightLeds();
|
||||
createBottomLeds();
|
||||
createLeftLeds();
|
||||
|
||||
|
||||
//check led gap pos
|
||||
if (ledsgpos+ledsglength > ledArray.length)
|
||||
if (params.ledsgpos+params.ledsglength > ledArray.length)
|
||||
{
|
||||
var mpos = Math.max(0,ledArray.length-ledsglength);
|
||||
$('#ip_cl_ledsgpos').val(mpos);
|
||||
var mpos = Math.max(0,ledArray.length-params.ledsglength);
|
||||
//$('#ip_cl_ledsgpos').val(mpos);
|
||||
ledsgpos = mpos;
|
||||
}
|
||||
|
||||
//check led gap length
|
||||
if(ledsglength >= ledArray.length)
|
||||
if(params.ledsglength >= ledArray.length)
|
||||
{
|
||||
$('#ip_cl_ledsglength').val(ledArray.length-1);
|
||||
ledsglength = ledArray.length-ledsglength-1;
|
||||
//$('#ip_cl_ledsglength').val(ledArray.length-1);
|
||||
params.ledsglength = ledArray.length-params.ledsglength-1;
|
||||
}
|
||||
|
||||
if(ledsglength != 0){
|
||||
ledArray.splice(ledsgpos, ledsglength);
|
||||
if(params.ledsglength != 0){
|
||||
ledArray.splice(params.ledsgpos, params.ledsglength);
|
||||
}
|
||||
|
||||
if (position != 0){
|
||||
rotateArray(ledArray, position);
|
||||
if (params.position != 0){
|
||||
rotateArray(ledArray, params.position);
|
||||
}
|
||||
|
||||
if (reverse)
|
||||
if (params.reverse)
|
||||
ledArray.reverse();
|
||||
|
||||
createFinalArray(ledArray);
|
||||
return createFinalArray(ledArray);
|
||||
}
|
||||
|
||||
function createMatrixLeds(){
|
||||
function createClassicLeds(){
|
||||
|
||||
//get values
|
||||
let params = {
|
||||
ledstop : parseInt($("#ip_cl_top").val()),
|
||||
ledsbottom : parseInt($("#ip_cl_bottom").val()),
|
||||
ledsleft : parseInt($("#ip_cl_left").val()),
|
||||
ledsright : parseInt($("#ip_cl_right").val()),
|
||||
ledsglength : parseInt($("#ip_cl_glength").val()),
|
||||
ledsgpos : parseInt($("#ip_cl_gpos").val()),
|
||||
position : parseInt($("#ip_cl_position").val()),
|
||||
reverse : $("#ip_cl_reverse").is(":checked"),
|
||||
|
||||
//advanced values
|
||||
ledsVDepth : parseInt($("#ip_cl_vdepth").val())/100,
|
||||
ledsHDepth : parseInt($("#ip_cl_hdepth").val())/100,
|
||||
edgeVGap : parseInt($("#ip_cl_edgegap").val())/100/2,
|
||||
//cornerVGap : parseInt($("#ip_cl_cornergap").val())/100/2,
|
||||
overlap : $("#ip_cl_overlap").val()/100,
|
||||
|
||||
//trapezoid values % -> float
|
||||
ptblh : parseInt($("#ip_cl_pblh").val())/100,
|
||||
ptblv : parseInt($("#ip_cl_pblv").val())/100,
|
||||
ptbrh : parseInt($("#ip_cl_pbrh").val())/100,
|
||||
ptbrv : parseInt($("#ip_cl_pbrv").val())/100,
|
||||
pttlh : parseInt($("#ip_cl_ptlh").val())/100,
|
||||
pttlv : parseInt($("#ip_cl_ptlv").val())/100,
|
||||
pttrh : parseInt($("#ip_cl_ptrh").val())/100,
|
||||
pttrv : parseInt($("#ip_cl_ptrv").val())/100,
|
||||
}
|
||||
|
||||
finalLedArray = createClassicLedLayout( params );
|
||||
|
||||
//check led gap pos
|
||||
if (params.ledsgpos+params.ledsglength > finalLedArray.length) {
|
||||
var mpos = Math.max(0,finalLedArray.length-params.ledsglength);
|
||||
$('#ip_cl_ledsgpos').val(mpos);
|
||||
}
|
||||
//check led gap length
|
||||
if(params.ledsglength >= finalLedArray.length) {
|
||||
$('#ip_cl_ledsglength').val(finalLedArray.length-1);
|
||||
}
|
||||
|
||||
createLedPreview(finalLedArray, 'classic');
|
||||
}
|
||||
|
||||
|
||||
function createMatrixLayout( ledshoriz, ledsvert, cabling, start){
|
||||
// Big thank you to RanzQ (Juha Rantanen) from Github for this script
|
||||
// https://raw.githubusercontent.com/RanzQ/hyperion-audio-effects/master/matrix-config.js
|
||||
|
||||
//get values
|
||||
var ledshoriz = parseInt($("#ip_ma_ledshoriz").val());
|
||||
var ledsvert = parseInt($("#ip_ma_ledsvert").val());
|
||||
var cabling = $("#ip_ma_cabling").val();
|
||||
//var order = $("#ip_ma_order").val();
|
||||
var start = $("#ip_ma_start").val();
|
||||
|
||||
var parallel = false
|
||||
var leds = []
|
||||
var hblock = 1.0 / ledshoriz
|
||||
@@ -298,9 +334,23 @@ function createMatrixLeds(){
|
||||
endX = tmp
|
||||
}
|
||||
}
|
||||
finalLedArray =[];
|
||||
finalLedArray = leds
|
||||
createLedPreview(leds, 'matrix');
|
||||
|
||||
return leds;
|
||||
}
|
||||
|
||||
|
||||
function createMatrixLeds(){
|
||||
// Big thank you to RanzQ (Juha Rantanen) from Github for this script
|
||||
// https://raw.githubusercontent.com/RanzQ/hyperion-audio-effects/master/matrix-config.js
|
||||
|
||||
//get values
|
||||
var ledshoriz = parseInt($("#ip_ma_ledshoriz").val());
|
||||
var ledsvert = parseInt($("#ip_ma_ledsvert").val());
|
||||
var cabling = $("#ip_ma_cabling").val();
|
||||
var start = $("#ip_ma_start").val();
|
||||
|
||||
finalLedArray = createMatrixLayout(ledshoriz,ledsvert,cabling,start);
|
||||
createLedPreview(finalLedArray, 'matrix');
|
||||
}
|
||||
|
||||
function migrateLedConfig(slConfig){
|
||||
@@ -560,6 +610,12 @@ $(document).ready(function() {
|
||||
var atmoorb_title = 'wiz_atmoorb_title';
|
||||
changeWizard(data, atmoorb_title, startWizardAtmoOrb);
|
||||
}
|
||||
else if(ledType == "cololight") {
|
||||
var ledWizardType = (this.checked) ? "cololight" : ledType;
|
||||
var data = { type: ledWizardType };
|
||||
var cololight_title = 'wiz_cololight_title';
|
||||
changeWizard(data, cololight_title, startWizardCololight);
|
||||
}
|
||||
else if(ledType == "yeelight") {
|
||||
var ledWizardType = (this.checked) ? "yeelight" : ledType;
|
||||
var data = { type: ledWizardType };
|
||||
@@ -582,10 +638,11 @@ $(document).ready(function() {
|
||||
var devRPiSPI = ['apa102', 'apa104', 'ws2801', 'lpd6803', 'lpd8806', 'p9813', 'sk6812spi', 'sk6822spi', 'sk9822', 'ws2812spi'];
|
||||
var devRPiPWM = ['ws281x'];
|
||||
var devRPiGPIO = ['piblaster'];
|
||||
var devNET = ['atmoorb', 'fadecandy', 'philipshue', 'nanoleaf', 'tinkerforge', 'tpm2net', 'udpe131', 'udpartnet', 'udph801', 'udpraw', 'wled', 'yeelight'];
|
||||
|
||||
var devNET = ['atmoorb', 'cololight', 'fadecandy', 'philipshue', 'nanoleaf', 'tinkerforge', 'tpm2net', 'udpe131', 'udpartnet', 'udph801', 'udpraw', 'wled', 'yeelight'];
|
||||
var devUSB = ['adalight', 'dmx', 'atmo', 'hyperionusbasp', 'lightpack', 'paintpack', 'rawhid', 'sedu', 'tpm2', 'karate'];
|
||||
|
||||
var optArr = [[]];
|
||||
var optArr = [[]];
|
||||
optArr[1]=[];
|
||||
optArr[2]=[];
|
||||
optArr[3]=[];
|
||||
|
@@ -152,9 +152,11 @@ function beginWizardRGB() {
|
||||
$('#btn_wizard_byteorder').off().on('click', startWizardRGB);
|
||||
|
||||
//color calibration wizard
|
||||
|
||||
var kodiHost = document.location.hostname;
|
||||
var kodiPort = 9090;
|
||||
var kodiAddress = kodiHost;
|
||||
|
||||
var wiz_editor;
|
||||
var colorLength;
|
||||
var cobj;
|
||||
@@ -168,6 +170,7 @@ var picnr = 0;
|
||||
var availVideos = ["Sweet_Cocoon", "Caminandes_2_GranDillama", "Caminandes_3_Llamigos"];
|
||||
|
||||
if (getStorage("kodiAddress") != null) {
|
||||
|
||||
kodiAddress = getStorage("kodiAddress");
|
||||
[kodiHost, kodiPort] = kodiAddress.split(":", 2);
|
||||
|
||||
@@ -585,6 +588,30 @@ function assignLightPos(id, pos, name) {
|
||||
return i;
|
||||
}
|
||||
|
||||
function getHostInLights(hostname) {
|
||||
return lights.filter(
|
||||
function (lights) {
|
||||
return lights.host === hostname
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function getIpInLights(ip) {
|
||||
return lights.filter(
|
||||
function (lights) {
|
||||
return lights.ip === ip
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function getIdInLights(id) {
|
||||
return lights.filter(
|
||||
function (lights) {
|
||||
return lights.id === id
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
//****************************
|
||||
// Wizard Philips Hue
|
||||
//****************************
|
||||
@@ -798,17 +825,8 @@ async function getProperties_hue_bridge(hostAddress, username, resourceFilter) {
|
||||
}
|
||||
|
||||
function identify_hue_device(hostAddress, username, id) {
|
||||
console.log("identify_hue_device");
|
||||
|
||||
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);
|
||||
}
|
||||
requestLedDeviceIdentification("philipshue", params);
|
||||
}
|
||||
|
||||
function getHueIPs() {
|
||||
@@ -1271,14 +1289,7 @@ async function getProperties_wled(hostAddress, resourceFilter) {
|
||||
|
||||
function identify_wled(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);
|
||||
}
|
||||
requestLedDeviceIdentification("wled", params);
|
||||
}
|
||||
|
||||
//****************************
|
||||
@@ -1390,14 +1401,6 @@ function beginWizardYeelight() {
|
||||
$('#btn_wiz_abort').off().on('click', resetWizard);
|
||||
}
|
||||
|
||||
function getHostInLights(hostname) {
|
||||
return lights.filter(
|
||||
function (lights) {
|
||||
return lights.host === hostname
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
async function discover_yeelight_lights() {
|
||||
var light = {};
|
||||
// Get discovered lights
|
||||
@@ -1414,10 +1417,9 @@ async function discover_yeelight_lights() {
|
||||
|
||||
if (device.hostname !== "") {
|
||||
if (getHostInLights(device.hostname).length === 0) {
|
||||
light = {};
|
||||
var light = {};
|
||||
light.host = device.hostname;
|
||||
light.port = device.port;
|
||||
|
||||
light.name = device.other.name;
|
||||
light.model = device.other.model;
|
||||
lights.push(light);
|
||||
@@ -1435,7 +1437,7 @@ async function discover_yeelight_lights() {
|
||||
|
||||
if (host !== "")
|
||||
if (getHostInLights(host).length === 0) {
|
||||
light = {};
|
||||
var light = {};
|
||||
light.host = host;
|
||||
light.port = port;
|
||||
light.name = configuredLights[keyConfig].name;
|
||||
@@ -1454,7 +1456,7 @@ function assign_yeelight_lights() {
|
||||
// If records are left for configuration
|
||||
if (Object.keys(lights).length > 0) {
|
||||
$('#wh_topcontainer').toggle(false);
|
||||
$('#yee_ids_t,#btn_wiz_save').toggle(true);
|
||||
$('#yee_ids_t, #btn_wiz_save').toggle(true);
|
||||
|
||||
var lightOptions = [
|
||||
"top", "topleft", "topright",
|
||||
@@ -1486,7 +1488,7 @@ function assign_yeelight_lights() {
|
||||
options += '>' + $.i18n(txt + val) + '</option>';
|
||||
}
|
||||
|
||||
var enabled = 'enabled'
|
||||
var enabled = 'enabled';
|
||||
if (!models.includes(lights[lightid].model)) {
|
||||
var enabled = 'disabled';
|
||||
options = '<option value=disabled>' + $.i18n('wiz_yeelight_unsupported') + '</option>';
|
||||
@@ -1514,7 +1516,7 @@ function assign_yeelight_lights() {
|
||||
$('.yee_sel_watch').trigger('change');
|
||||
}
|
||||
else {
|
||||
var noLightsTxt = '<p style="font-weight:bold;color:red;">' + $.i18n('wiz_yeelight_noLights') + '</p>';
|
||||
var noLightsTxt = '<p style="font-weight:bold;color:red;">' + $.i18n('wiz_noLights','Yeelights') + '</p>';
|
||||
$('#wizp2_body').append(noLightsTxt);
|
||||
}
|
||||
}
|
||||
@@ -1535,13 +1537,8 @@ async function getProperties_yeelight(hostname, port) {
|
||||
}
|
||||
|
||||
function identify_yeelight_device(hostname, 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;
|
||||
}
|
||||
let params = { hostname: hostname, port: port
|
||||
requestLedDeviceIdentification("yeelight", params);
|
||||
}
|
||||
|
||||
//****************************
|
||||
@@ -1648,14 +1645,6 @@ function beginWizardAtmoOrb() {
|
||||
$('#btn_wiz_abort').off().on('click', resetWizard);
|
||||
}
|
||||
|
||||
function getIdInLights(id) {
|
||||
return lights.filter(
|
||||
function (lights) {
|
||||
return lights.id === id
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
async function discover_atmoorb_lights(multiCastGroup, multiCastPort) {
|
||||
var light = {};
|
||||
|
||||
@@ -1673,13 +1662,13 @@ async function discover_atmoorb_lights(multiCastGroup, multiCastPort) {
|
||||
// TODO: error case unhandled
|
||||
// res can be: false (timeout) or res.error (not found)
|
||||
if (res && !res.error) {
|
||||
const r = res.info
|
||||
|
||||
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 = {};
|
||||
var light = {};
|
||||
light.id = device.id;
|
||||
light.ip = device.ip;
|
||||
light.host = device.hostname;
|
||||
@@ -1692,7 +1681,7 @@ async function discover_atmoorb_lights(multiCastGroup, multiCastPort) {
|
||||
for (const keyConfig in configuredLights) {
|
||||
if (configuredLights[keyConfig] !== "" && !isNaN(configuredLights[keyConfig])) {
|
||||
if (getIdInLights(configuredLights[keyConfig]).length === 0) {
|
||||
light = {};
|
||||
var light = {};
|
||||
light.id = configuredLights[keyConfig];
|
||||
light.ip = "";
|
||||
light.host = "";
|
||||
@@ -1743,9 +1732,9 @@ function assign_atmoorb_lights() {
|
||||
options += '>' + $.i18n(txt + val) + '</option>';
|
||||
}
|
||||
|
||||
var enabled = 'enabled'
|
||||
var enabled = 'enabled';
|
||||
if (orbId < 1 || orbId > 255) {
|
||||
enabled = 'disabled'
|
||||
enabled = 'disabled';
|
||||
options = '<option value=disabled>' + $.i18n('wiz_atmoorb_unsupported') + '</option>';
|
||||
}
|
||||
|
||||
@@ -1775,20 +1764,14 @@ function assign_atmoorb_lights() {
|
||||
$('.orb_sel_watch').trigger('change');
|
||||
}
|
||||
else {
|
||||
var noLightsTxt = '<p style="font-weight:bold;color:red;">' + $.i18n('wiz_atmoorb_noLights') + '</p>';
|
||||
var noLightsTxt = '<p style="font-weight:bold;color:red;">' + $.i18n('wiz_noLights','AtmoOrbs') + '</p>';
|
||||
$('#wizp2_body').append(noLightsTxt);
|
||||
}
|
||||
}
|
||||
|
||||
function identify_atmoorb_device(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
|
||||
}
|
||||
requestLedDeviceIdentification("atmoorb", params);
|
||||
}
|
||||
|
||||
//****************************
|
||||
@@ -1837,16 +1820,197 @@ async function getProperties_nanoleaf(hostAddress, authToken, resourceFilter) {
|
||||
|
||||
function identify_nanoleaf(hostAddress, authToken) {
|
||||
let params = { host: hostAddress, token: authToken };
|
||||
requestLedDeviceIdentification("nanoleaf", params);
|
||||
}
|
||||
|
||||
//****************************
|
||||
// Wizard Cololight
|
||||
//****************************
|
||||
var lights = null;
|
||||
var selectedLightId = null;
|
||||
|
||||
function startWizardCololight(e) {
|
||||
//create html
|
||||
|
||||
var cololight_title = 'wiz_cololight_title';
|
||||
var cololight_intro1 = 'wiz_cololight_intro1';
|
||||
|
||||
$('#wiz_header').html('<i class="fa fa-magic fa-fw"></i>' + $.i18n(cololight_title));
|
||||
$('#wizp1_body').html('<h4 style="font-weight:bold;text-transform:uppercase;">' + $.i18n(cololight_title) + '</h4><p>' + $.i18n(cololight_intro1) + '</p>');
|
||||
$('#wizp1_footer').html('<button type="button" class="btn btn-primary" id="btn_wiz_cont"><i class="fa fa-fw fa-check"></i>' + $.i18n('general_btn_continue') + '</button><button type="button" class="btn btn-danger" data-dismiss="modal"><i class="fa fa-fw fa-close"></i>' + $.i18n('general_btn_cancel') + '</button>');
|
||||
|
||||
$('#wizp2_body').html('<div id="wh_topcontainer"></div>');
|
||||
|
||||
$('#wh_topcontainer').append('<div class="form-group" id="usrcont" style="display:none"></div>');
|
||||
|
||||
$('#wizp2_body').append('<div id="colo_ids_t" style="display:none"><p style="font-weight:bold" id="colo_id_headline">' + $.i18n('wiz_cololight_desc2') + '</p></div>');
|
||||
|
||||
createTable("lidsh", "lidsb", "colo_ids_t");
|
||||
$('.lidsh').append(createTableRow([$.i18n('edt_dev_spec_lights_title'), $.i18n('wiz_identify')], true));
|
||||
$('#wizp2_footer').html('<button type="button" class="btn btn-primary" id="btn_wiz_save" style="display:none"><i class="fa fa-fw fa-save"></i>'
|
||||
+ $.i18n('general_btn_save') + '</button><buttowindow.serverConfig.device = d;n type="button" class="btn btn-danger" id="btn_wiz_abort"><i class="fa fa-fw fa-close"></i>'
|
||||
+ $.i18n('general_btn_cancel') + '</button>');
|
||||
|
||||
//open modal
|
||||
$("#wizard_modal").modal({
|
||||
backdrop: "static",
|
||||
keyboard: false,
|
||||
show: true
|
||||
});
|
||||
|
||||
//listen for continue
|
||||
$('#btn_wiz_cont').off().on('click', function () {
|
||||
beginWizardCololight();
|
||||
$('#wizp1').toggle(false);
|
||||
$('#wizp2').toggle(true);
|
||||
});
|
||||
}
|
||||
|
||||
function beginWizardCololight() {
|
||||
lights = [];
|
||||
|
||||
discover_cololights();
|
||||
|
||||
$('#btn_wiz_save').off().on("click", function () {
|
||||
//LED device config
|
||||
//Start with a clean configuration
|
||||
var d = {};
|
||||
|
||||
d.type = 'cololight';
|
||||
|
||||
//Cololight does not resolve into stable hostnames (as devices named the same), therefore use IP
|
||||
if (!lights[selectedLightId].ip) {
|
||||
d.host = lights[selectedLightId].host;
|
||||
} else {
|
||||
d.host = lights[selectedLightId].ip;
|
||||
}
|
||||
|
||||
var coloLightProperties = lights[selectedLightId].props;
|
||||
if (Object.keys(coloLightProperties).length === 0) {
|
||||
alert($.i18n('wiz_cololight_noprops'));
|
||||
d.hardwareLedCount = 1;
|
||||
} else {
|
||||
if (coloLightProperties.ledCount > 0) {
|
||||
d.hardwareLedCount = coloLightProperties.ledCount;
|
||||
} else if (coloLightProperties.modelType === "Strip")
|
||||
d.hardwareLedCount = 120;
|
||||
}
|
||||
|
||||
d.colorOrder = conf_editor.getEditor("root.generalOptions.colorOrder").getValue();
|
||||
d.latchTime = parseInt(conf_editor.getEditor("root.specificOptions.latchTime").getValue());;
|
||||
|
||||
window.serverConfig.device = d;
|
||||
|
||||
//LED layout - have initial layout prepared matching the LED-count
|
||||
|
||||
var coloLightLedConfig = [];
|
||||
|
||||
if (coloLightProperties.modelType === "Strip") {
|
||||
coloLightLedConfig = createClassicLedLayoutSimple(d.hardwareLedCount / 2, d.hardwareLedCount / 4, d.hardwareLedCount / 4, 0, d.hardwareLedCount / 4 * 3, false);
|
||||
} else {
|
||||
coloLightLedConfig = createClassicLedLayoutSimple(0, 0, 0, d.hardwareLedCount, 0, true);
|
||||
}
|
||||
|
||||
window.serverConfig.leds = coloLightLedConfig;
|
||||
|
||||
//smoothing off
|
||||
window.serverConfig.smoothing.enable = false;
|
||||
|
||||
requestWriteConfig(window.serverConfig, true);
|
||||
|
||||
resetWizard();
|
||||
});
|
||||
|
||||
$('#btn_wiz_abort').off().on('click', resetWizard);
|
||||
}
|
||||
|
||||
async function discover_cololights() {
|
||||
const res = await requestLedDeviceDiscovery('cololight');
|
||||
|
||||
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 r = res.info;
|
||||
|
||||
// Process devices returned by discovery
|
||||
for (const device of r.devices) {
|
||||
if (device.ip !== "") {
|
||||
if (getIpInLights(device.ip).length === 0) {
|
||||
var light = {};
|
||||
light.ip = device.ip;
|
||||
light.host = device.hostname;
|
||||
light.name = device.name;
|
||||
light.type = device.type;
|
||||
lights.push(light);
|
||||
}
|
||||
}
|
||||
}
|
||||
assign_cololight_lights();
|
||||
}
|
||||
}
|
||||
|
||||
function assign_cololight_lights() {
|
||||
// If records are left for configuration
|
||||
if (Object.keys(lights).length > 0) {
|
||||
$('#wh_topcontainer').toggle(false);
|
||||
$('#colo_ids_t, #btn_wiz_save').toggle(true);
|
||||
|
||||
$('.lidsb').html("");
|
||||
|
||||
var options = "";
|
||||
|
||||
for (var lightid in lights) {
|
||||
lights[lightid].id = lightid;
|
||||
|
||||
var lightHostname = lights[lightid].host;
|
||||
var lightIP = lights[lightid].ip;
|
||||
|
||||
var val = lightHostname + " (" + lightIP + ")";
|
||||
options += '<option value="' + lightid + '">' + val + '</option>';
|
||||
}
|
||||
|
||||
var enabled = 'enabled';
|
||||
|
||||
$('.lidsb').append(createTableRow(['<select id="colo_select_id" ' + enabled + ' class="colo_sel_watch form-control">'
|
||||
+ options
|
||||
+ '</select>', '<button id="wiz_identify_btn" class="btn btn-sm btn-primary">'
|
||||
+ $.i18n('wiz_identify') + '</button>']));
|
||||
|
||||
$('.colo_sel_watch').bind("change", function () {
|
||||
selectedLightId = $('#colo_select_id').val();
|
||||
var lightIP = lights[selectedLightId].ip;
|
||||
|
||||
$('#wiz_identify_btn').unbind().bind('click', function (event) { identify_cololight_device(lightIP); });
|
||||
|
||||
if (!lights[selectedLightId].props) {
|
||||
getProperties_cololight(lightIP);
|
||||
}
|
||||
});
|
||||
$('.colo_sel_watch').trigger('change');
|
||||
}
|
||||
else {
|
||||
var noLightsTxt = '<p style="font-weight:bold;color:red;">' + $.i18n('wiz_noLights','Cololights') + '</p>';
|
||||
$('#wizp2_body').append(noLightsTxt);
|
||||
}
|
||||
}
|
||||
|
||||
async function getProperties_cololight(ip) {
|
||||
let params = { host: ip };
|
||||
|
||||
const res = await requestLedDeviceProperties('cololight', params);
|
||||
|
||||
if (res && !res.error) {
|
||||
var coloLightProperties = res.info;
|
||||
|
||||
//Store properties along light with given IP-address
|
||||
var id = getIpInLights(ip)[0].id;
|
||||
lights[id].props = coloLightProperties;
|
||||
}
|
||||
}
|
||||
|
||||
function identify_cololight_device(hostAddress) {
|
||||
let params = { host: hostAddress };
|
||||
requestLedDeviceIdentification("cololight", params);
|
||||
}
|
||||
|
||||
//****************************
|
||||
// Wizard/Routines RS232-Devices
|
||||
//****************************
|
||||
|
Reference in New Issue
Block a user