mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
Fixed QString string formatting, added safety check in case the connection to the bridge might be lost.
Former-commit-id: fb1f5fd21cd3873fc1b92d763c682e75f345ab42
This commit is contained in:
parent
f76b5ffbd8
commit
f0d2c15aeb
@ -32,6 +32,11 @@ int LedDevicePhilipsHue::write(const std::vector<ColorRgb> & ledValues) {
|
||||
saveStates((unsigned int) ledValues.size());
|
||||
switchOn((unsigned int) ledValues.size());
|
||||
}
|
||||
// If there are less states saved than colors given, then maybe something went wrong before.
|
||||
if (lamps.size() != ledValues.size()) {
|
||||
restoreStates();
|
||||
return 0;
|
||||
}
|
||||
// Iterate through colors and set light states.
|
||||
unsigned int idx = 0;
|
||||
for (const ColorRgb& color : ledValues) {
|
||||
@ -51,7 +56,7 @@ int LedDevicePhilipsHue::write(const std::vector<ColorRgb> & ledValues) {
|
||||
}
|
||||
// Send adjust color and brightness command in JSON format.
|
||||
put(getStateRoute(lamp.id),
|
||||
QString("{\"xy\": [%1, %2], \"bri\": %1}").arg(xy.x).arg(xy.y).arg(qRound(xy.bri * 255.0f)));
|
||||
QString("{\"xy\": [%1, %2], \"bri\": %3}").arg(xy.x).arg(xy.y).arg(qRound(xy.bri * 255.0f)));
|
||||
// Remember written color.
|
||||
lamp.color = xy;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user