mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Philips Hue APIv2 support (#1637)
* Support Philips Hue APIv2 and refactoring * Fix MDNSBrower - if timeout during host resolvment occurs * Hue API v2 - Migrate database * Fix macOS build * Handle network timeout before any other error * Address CodeQL findings * Clean-up and Fixes * Only getProperties, if username is available * Option to layout by entertainment area center * Fix Wizard --------- Co-authored-by: Paulchen-Panther <16664240+Paulchen-Panther@users.noreply.github.com>
This commit is contained in:
@@ -723,6 +723,7 @@ bool SettingsManager::handleConfigUpgrade(QJsonObject& config)
|
||||
}
|
||||
|
||||
//Migration steps for versions <= 2.0.13
|
||||
_previousVersion = targetVersion;
|
||||
targetVersion.setVersion("2.0.13");
|
||||
if (_previousVersion <= targetVersion)
|
||||
{
|
||||
@@ -774,6 +775,60 @@ bool SettingsManager::handleConfigUpgrade(QJsonObject& config)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Migration steps for versions <= 2.0.16
|
||||
_previousVersion = targetVersion;
|
||||
targetVersion.setVersion("2.0.16");
|
||||
if (_previousVersion <= targetVersion)
|
||||
{
|
||||
Info(_log, "Instance [%u]: Migrate from version [%s] to version [%s] or later", _instance, _previousVersion.getVersion().c_str(), targetVersion.getVersion().c_str());
|
||||
|
||||
// Have Hostname/IP-address separate from port for LED-Devices
|
||||
if (config.contains("device"))
|
||||
{
|
||||
QJsonObject newDeviceConfig = config["device"].toObject();
|
||||
|
||||
if (newDeviceConfig.contains("type"))
|
||||
{
|
||||
QString type = newDeviceConfig["type"].toString();
|
||||
if ( type == "philipshue")
|
||||
{
|
||||
if (newDeviceConfig.contains("groupId"))
|
||||
{
|
||||
if (newDeviceConfig["groupId"].isDouble())
|
||||
{
|
||||
int groupID = newDeviceConfig["groupId"].toInt();
|
||||
newDeviceConfig["groupId"] = QString::number(groupID);
|
||||
migrated = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (newDeviceConfig.contains("lightIds"))
|
||||
{
|
||||
QJsonArray lightIds = newDeviceConfig.value( "lightIds").toArray();
|
||||
// Iterate through the JSON array and update integer values to strings
|
||||
for (int i = 0; i < lightIds.size(); ++i) {
|
||||
QJsonValue value = lightIds.at(i);
|
||||
if (value.isDouble())
|
||||
{
|
||||
int lightId = value.toInt();
|
||||
lightIds.replace(i, QString::number(lightId));
|
||||
migrated = true;
|
||||
}
|
||||
}
|
||||
newDeviceConfig["lightIds"] = lightIds;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (migrated)
|
||||
{
|
||||
config["device"] = newDeviceConfig;
|
||||
Debug(_log, "LED-Device records migrated");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return migrated;
|
||||
|
Reference in New Issue
Block a user