mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Fixed: Philip Hue APIv2 support without Entertainment group defined (#1742)
This commit is contained in:
parent
4a5b0b6bf2
commit
6371a7ac8c
@ -29,6 +29,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- Workaround to address Web UI keeps forcing browser to download the html instead (#1692)
|
||||
- Fixed: Kodi Color Calibration, Refactor Wizards (#1674)
|
||||
- Fixed: Token Dialog not closing
|
||||
- Fixed: Philip Hue APIv2 support without Entertainment group defined (#1742)
|
||||
|
||||
**JSON-API**
|
||||
- Refactored JSON-API to ensure consistent authorization behaviour across sessions and single requests with token authorization.
|
||||
|
@ -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("");
|
||||
|
@ -895,6 +895,7 @@ void LedDevicePhilipsHueBridge::setBridgeDetails(const QJsonDocument &doc, bool
|
||||
log( "API-Version", "%u.%u.%u", _api_major, _api_minor, _api_patch );
|
||||
log( "API v2 ready", "%s", _isAPIv2Ready ? "Yes" : "No" );
|
||||
log( "Entertainment ready", "%s", _isHueEntertainmentReady ? "Yes" : "No" );
|
||||
log( "Use Entertainment API", "%s", _useEntertainmentAPI ? "Yes" : "No" );
|
||||
log( "DIYHue", "%s", _isDiyHue ? "Yes" : "No" );
|
||||
}
|
||||
}
|
||||
@ -1799,11 +1800,11 @@ bool LedDevicePhilipsHue::init(const QJsonObject &deviceConfig)
|
||||
|
||||
if (LedDevicePhilipsHueBridge::init(_devConfig))
|
||||
{
|
||||
log( "Off on Black", "%s", _switchOffOnBlack ? "Yes" : "No" );
|
||||
log( "Brightness Factor", "%f", _brightnessFactor );
|
||||
log( "Transition Time", "%d", _transitionTime );
|
||||
log( "Restore Original State", "%s", _isRestoreOrigState ? "Yes" : "No" );
|
||||
log( "Use Hue Entertainment API", "%s", _useEntertainmentAPI ? "Yes" : "No" );
|
||||
log("Off on Black", "%s", _switchOffOnBlack ? "Yes" : "No" );
|
||||
log("Brightness Factor", "%f", _brightnessFactor );
|
||||
log("Transition Time", "%d", _transitionTime );
|
||||
log("Restore Original State", "%s", _isRestoreOrigState ? "Yes" : "No" );
|
||||
log("Use Hue Entertainment API", "%s", _useEntertainmentAPI ? "Yes" : "No" );
|
||||
log("Brightness Threshold", "%f", _blackLevel);
|
||||
log("CandyGamma", "%s", _candyGamma ? "Yes" : "No" );
|
||||
log("Time powering off when black", "%s", _onBlackTimeToPowerOff ? "Yes" : "No" );
|
||||
@ -1864,7 +1865,7 @@ bool LedDevicePhilipsHue::setLights()
|
||||
Debug(_log, "Lights configured: %d", configuredLightsCount );
|
||||
if (updateLights( getLightMap()))
|
||||
{
|
||||
if (_useApiV2)
|
||||
if (_useApiV2 && _useEntertainmentAPI)
|
||||
{
|
||||
_channelsCount = getGroupChannelsCount (_groupId);
|
||||
|
||||
@ -2208,15 +2209,14 @@ int LedDevicePhilipsHue::write(const std::vector<ColorRgb> & ledValues)
|
||||
int rc {0};
|
||||
if (_isOn)
|
||||
{
|
||||
if (!_useApiV2)
|
||||
{
|
||||
rc = writeSingleLights( ledValues );
|
||||
}
|
||||
|
||||
if (_useEntertainmentAPI && _isInitLeds)
|
||||
{
|
||||
rc= writeStreamData(ledValues);
|
||||
}
|
||||
else
|
||||
{
|
||||
rc = writeSingleLights( ledValues );
|
||||
}
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
@ -2482,7 +2482,7 @@ void LedDevicePhilipsHue::setColor(PhilipsHueLight& light, CiColor& color)
|
||||
QJsonObject colorXY;
|
||||
colorXY[API_X_COORDINATE] = color.x;
|
||||
colorXY[API_Y_COORDINATE] = color.y;
|
||||
cmd.insert(API_COLOR, QJsonObject {{API_DURATION, colorXY }});
|
||||
cmd.insert(API_COLOR, QJsonObject {{API_XY_COORDINATES, colorXY }});
|
||||
cmd.insert(API_DIMMING, QJsonObject {{API_BRIGHTNESS, bri }});
|
||||
}
|
||||
else
|
||||
@ -2556,7 +2556,7 @@ void LedDevicePhilipsHue::setState(PhilipsHueLight& light, bool on, const CiColo
|
||||
QJsonObject colorXY;
|
||||
colorXY[API_X_COORDINATE] = color.x;
|
||||
colorXY[API_Y_COORDINATE] = color.y;
|
||||
cmd.insert(API_COLOR, QJsonObject {{API_DURATION, colorXY }});
|
||||
cmd.insert(API_COLOR, QJsonObject {{API_XY_COORDINATES, colorXY }});
|
||||
cmd.insert(API_DIMMING, QJsonObject {{API_BRIGHTNESS, bri }});
|
||||
}
|
||||
else
|
||||
|
@ -30,7 +30,8 @@ enum HttpStatusCode {
|
||||
BadRequest = 400,
|
||||
UnAuthorized = 401,
|
||||
Forbidden = 403,
|
||||
NotFound = 404
|
||||
NotFound = 404,
|
||||
TooManyRequests = 429
|
||||
};
|
||||
|
||||
} //End of constants
|
||||
@ -336,6 +337,15 @@ httpResponse ProviderRestApi::getResponse(QNetworkReply* const& reply)
|
||||
case HttpStatusCode::NotFound:
|
||||
advise = "Check Resource given";
|
||||
break;
|
||||
case HttpStatusCode::TooManyRequests:
|
||||
{
|
||||
QString retryAfterTime = response.getHeader("Retry-After");
|
||||
if (!retryAfterTime.isEmpty())
|
||||
{
|
||||
advise = "Retry-After: " + response.getHeader("Retry-After");
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
advise = httpReason;
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user