mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Add Home Assistant Lights support (#1763)
* New HomeAssistant LEDDevice * Fix typos * Ping Qt for Windows to 6.7 until aqtinstaller is fixed * Fix HA default port handling * HA - Update default latchtime and range * Add HA Wizard and light selection * Naming consistency * Fix "Selected Hyperion instance is not running" * CodeQL findings * HA - allow to overwrite brightness by HA yes or no * HA - Support switch off on black * HA - Add transition time
This commit is contained in:
@@ -151,17 +151,7 @@ const atmoorbWizard = (() => {
|
||||
$('#wh_topcontainer').toggle(false);
|
||||
$('#orb_ids_t, #btn_wiz_save').toggle(true);
|
||||
|
||||
const lightOptions = [
|
||||
"top", "topleft", "topright",
|
||||
"bottom", "bottomleft", "bottomright",
|
||||
"left", "lefttop", "leftmiddle", "leftbottom",
|
||||
"right", "righttop", "rightmiddle", "rightbottom",
|
||||
"entire",
|
||||
"lightPosTopLeft112", "lightPosTopLeftNewMid", "lightPosTopLeft121",
|
||||
"lightPosBottomLeft14", "lightPosBottomLeft12", "lightPosBottomLeft34", "lightPosBottomLeft11",
|
||||
"lightPosBottomLeft112", "lightPosBottomLeftNewMid", "lightPosBottomLeft121"
|
||||
];
|
||||
|
||||
const lightOptions = utils.getLayoutPositions();
|
||||
lightOptions.unshift("disabled");
|
||||
|
||||
$('.lidsb').html("");
|
||||
@@ -178,10 +168,9 @@ const atmoorbWizard = (() => {
|
||||
let options = "";
|
||||
for (const opt in lightOptions) {
|
||||
const val = lightOptions[opt];
|
||||
const txt = (val !== 'entire' && val !== 'disabled') ? 'conf_leds_layout_cl_' : 'wiz_ids_';
|
||||
options += '<option value="' + val + '"';
|
||||
if (pos === val) options += ' selected="selected"';
|
||||
options += '>' + $.i18n(txt + val) + '</option>';
|
||||
options += '>' + $.i18n('conf_leds_layout_cl_' + val) + '</option>';
|
||||
}
|
||||
|
||||
let enabled = 'enabled';
|
||||
|
74
assets/webconfig/js/wizards/LedDevice_layoutLedPositions.js
Normal file
74
assets/webconfig/js/wizards/LedDevice_layoutLedPositions.js
Normal file
@@ -0,0 +1,74 @@
|
||||
//****************************
|
||||
// Wizard LED Layout
|
||||
//****************************
|
||||
|
||||
import { ledDeviceWizardUtils as utils } from './LedDevice_utils.js';
|
||||
|
||||
const layoutLedPositionsWizard = (() => {
|
||||
|
||||
let wiz_editor;
|
||||
|
||||
function createEditor() {
|
||||
wiz_editor = createJsonEditor('editor_container_wiz', {
|
||||
layoutPosition: {
|
||||
"type": "string",
|
||||
"title": "wiz_layout_led_position_title",
|
||||
"enum": utils.getLayoutPositions(),
|
||||
"options": {
|
||||
"enum_titles": utils.getLayoutPositionsTitles()
|
||||
}
|
||||
}
|
||||
}, true, true);
|
||||
}
|
||||
|
||||
function stopWizardLedLayout(reload) {
|
||||
resetWizard(reload);
|
||||
}
|
||||
|
||||
function beginWizardLayoutLedPositions() {
|
||||
createEditor();
|
||||
setStorage("wizardactive", true);
|
||||
|
||||
$('#btn_wiz_abort').off().on('click', function () {
|
||||
stopWizardLedLayout(true);
|
||||
});
|
||||
|
||||
$('#btn_wiz_ok').off().on('click', function () {
|
||||
const layoutPosition = wiz_editor.getEditor("root.layoutPosition").getValue();
|
||||
const layoutObject = utils.assignLightPos(layoutPosition);
|
||||
|
||||
var layoutObjects = [];
|
||||
layoutObjects.push(JSON.parse(JSON.stringify(layoutObject)));
|
||||
aceEdt.set(layoutObjects);
|
||||
|
||||
stopWizardLedLayout(true);
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
start: function (e, data) {
|
||||
$('#wiz_header').html('<i class="fa fa-magic fa-fw"></i>' + $.i18n('wiz_layout_led_positions_title'));
|
||||
$('#wizp1_body').html('<div <p style="font-weight:bold">' + $.i18n('wiz_layout_led_positions_expl', data.ledType) + '</p></div>' +
|
||||
'<div id="editor_container_wiz"></div>'
|
||||
);
|
||||
$('#wizp1_footer').html('<button type="button" class="btn btn-primary" id="btn_wiz_ok"><i class="fa fa-fw fa-check"></i>' + $.i18n('general_btn_ok') +
|
||||
'</button><button type="button" class="btn btn-danger" id="btn_wiz_abort"><i class="fa fa-fw fa-close"></i>' + $.i18n('general_btn_cancel') + '</button>'
|
||||
);
|
||||
|
||||
if (getStorage("darkMode") == "on")
|
||||
$('#wizard_logo').attr("src", 'img/hyperion/logo_negativ.png');
|
||||
|
||||
//open modal
|
||||
$("#wizard_modal").modal({
|
||||
backdrop: "static",
|
||||
keyboard: false,
|
||||
show: true
|
||||
});
|
||||
|
||||
beginWizardLayoutLedPositions();
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
export { layoutLedPositionsWizard };
|
||||
|
@@ -794,17 +794,7 @@ const philipshueWizard = (() => {
|
||||
}
|
||||
$('#hue_ids_t, #btn_wiz_save').toggle(true);
|
||||
|
||||
const lightOptions = [
|
||||
"top", "topleft", "topright",
|
||||
"bottom", "bottomleft", "bottomright",
|
||||
"left", "lefttop", "leftmiddle", "leftbottom",
|
||||
"right", "righttop", "rightmiddle", "rightbottom",
|
||||
"entire",
|
||||
"lightPosTopLeft112", "lightPosTopLeftNewMid", "lightPosTopLeft121",
|
||||
"lightPosBottomLeft14", "lightPosBottomLeft12", "lightPosBottomLeft34", "lightPosBottomLeft11",
|
||||
"lightPosBottomLeft112", "lightPosBottomLeftNewMid", "lightPosBottomLeft121"
|
||||
];
|
||||
|
||||
const lightOptions = utils.getLayoutPositions();
|
||||
if (isEntertainmentReady && hueEntertainmentConfigs.length > 0) {
|
||||
lightOptions.unshift("entertainment_center");
|
||||
lightOptions.unshift("entertainment");
|
||||
@@ -866,10 +856,9 @@ const philipshueWizard = (() => {
|
||||
let options = "";
|
||||
for (const opt in lightOptions) {
|
||||
const val = lightOptions[opt];
|
||||
const txt = (val != 'entire' && val != 'disabled') ? 'conf_leds_layout_cl_' : 'wiz_ids_';
|
||||
options += '<option value="' + val + '"';
|
||||
if (pos == val) options += ' selected="selected"';
|
||||
options += '>' + $.i18n(txt + val) + '</option>';
|
||||
options += '>' + $.i18n('conf_leds_layout_cl_' + val) + '</option>';
|
||||
}
|
||||
|
||||
$('.lidsb').append(createTableRow([id + ' (' + lightName + ')',
|
||||
|
@@ -52,6 +52,17 @@ const ledDeviceWizardUtils = (() => {
|
||||
const i = positionMap[pos] || positionMap["lightPosEntire"];
|
||||
i.name = name;
|
||||
return i;
|
||||
},
|
||||
getLayoutPositions: function () {
|
||||
return Object.keys(positionMap);
|
||||
},
|
||||
getLayoutPositionsTitles: function () {
|
||||
|
||||
let layoutPositionTitles = [];
|
||||
for (const layoutPosition of Object.keys(positionMap)) {
|
||||
layoutPositionTitles.push($.i18n('conf_leds_layout_cl_' + layoutPosition));
|
||||
}
|
||||
return layoutPositionTitles;
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -173,17 +173,7 @@ const yeelightWizard = (() => {
|
||||
$('#wh_topcontainer').toggle(false);
|
||||
$('#yee_ids_t, #btn_wiz_save').toggle(true);
|
||||
|
||||
const lightOptions = [
|
||||
"top", "topleft", "topright",
|
||||
"bottom", "bottomleft", "bottomright",
|
||||
"left", "lefttop", "leftmiddle", "leftbottom",
|
||||
"right", "righttop", "rightmiddle", "rightbottom",
|
||||
"entire",
|
||||
"lightPosTopLeft112", "lightPosTopLeftNewMid", "lightPosTopLeft121",
|
||||
"lightPosBottomLeft14", "lightPosBottomLeft12", "lightPosBottomLeft34", "lightPosBottomLeft11",
|
||||
"lightPosBottomLeft112", "lightPosBottomLeftNewMid", "lightPosBottomLeft121"
|
||||
];
|
||||
|
||||
const lightOptions = utils.getLayoutPositions();
|
||||
lightOptions.unshift("disabled");
|
||||
|
||||
$('.lidsb').html("");
|
||||
@@ -200,10 +190,9 @@ const yeelightWizard = (() => {
|
||||
let options = "";
|
||||
for (const opt in lightOptions) {
|
||||
const val = lightOptions[opt];
|
||||
const txt = (val !== 'entire' && val !== 'disabled') ? 'conf_leds_layout_cl_' : 'wiz_ids_';
|
||||
options += '<option value="' + val + '"';
|
||||
if (pos === val) options += ' selected="selected"';
|
||||
options += '>' + $.i18n(txt + val) + '</option>';
|
||||
options += '>' + $.i18n('conf_leds_layout_cl_' + val) + '</option>';
|
||||
}
|
||||
|
||||
let enabled = 'enabled';
|
||||
|
Reference in New Issue
Block a user