Fix Philip Hue APIv2 support without Entertainment group defined (#1743)

This commit is contained in:
LordGrey
2024-05-21 19:37:43 +02:00
committed by GitHub
parent 4a5b0b6bf2
commit e6714b21f9
5 changed files with 40 additions and 21 deletions

View File

@@ -502,7 +502,9 @@ const philipshueWizard = (() => {
let serviceID;
if (isAPIv2Ready) {
serviceID = lightLocation.service.rid;
if (lightLocation) {
serviceID = lightLocation.service.rid;
}
}
if (position.startsWith("entertainment")) {
@@ -531,7 +533,7 @@ const philipshueWizard = (() => {
// Layout per manual settings
let maxSegments = 1;
if (isAPIv2Ready) {
if (isAPIv2Ready && serviceID) {
const service = hueEntertainmentServices.find(service => service.id === serviceID);
maxSegments = service.segments.max_segments;
}
@@ -593,10 +595,10 @@ const philipshueWizard = (() => {
d.enableAttempts = parseInt(conf_editor.getEditor("root.generalOptions.enableAttempts").getValue());
d.enableAttemptsInterval = parseInt(conf_editor.getEditor("root.generalOptions.enableAttemptsInterval").getValue());
d.useEntertainmentAPI = isEntertainmentReady;
d.useEntertainmentAPI = isEntertainmentReady && (d.groupId !== "");
d.useAPIv2 = isAPIv2Ready;
if (isEntertainmentReady) {
if (d.useEntertainmentAPI) {
d.hardwareLedCount = channelNumber;
if (window.serverConfig.device.type !== d.type) {
//smoothing on, if new device
@@ -803,12 +805,18 @@ const philipshueWizard = (() => {
"lightPosBottomLeft112", "lightPosBottomLeftNewMid", "lightPosBottomLeft121"
];
if (isEntertainmentReady) {
if (isEntertainmentReady && hueEntertainmentConfigs.length > 0) {
lightOptions.unshift("entertainment_center");
lightOptions.unshift("entertainment");
} else {
lightOptions.unshift("disabled");
groupLights = Object.keys(hueLights);
if (isAPIv2Ready) {
for (const light in hueLights) {
groupLights.push(hueLights[light].id);
}
} else {
groupLights = Object.keys(hueLights);
}
}
$('.lidsb').html("");