fix mood enable
This commit is contained in:
parent
6baa7584ad
commit
e751bff279
@ -205,16 +205,17 @@ void DevicePluginTune::tuneAutodetected()
|
|||||||
|
|
||||||
void DevicePluginTune::activateMood(Device *device)
|
void DevicePluginTune::activateMood(Device *device)
|
||||||
{
|
{
|
||||||
|
// first deactivate every current active mood
|
||||||
foreach (Device* d, myDevices()) {
|
foreach (Device* d, myDevices()) {
|
||||||
if (d->deviceClassId() == moodDeviceClassId) {
|
if (d->deviceClassId() == moodDeviceClassId) {
|
||||||
if (d->id() == device->id()) {
|
if (d->stateValue(activeStateTypeId).toBool()) {
|
||||||
d->setStateValue(activeStateTypeId, true);
|
|
||||||
} else {
|
|
||||||
d->setStateValue(activeStateTypeId, false);
|
d->setStateValue(activeStateTypeId, false);
|
||||||
|
syncStates(d);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sync();
|
device->setStateValue(activeStateTypeId, true);
|
||||||
|
syncStates(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DevicePluginTune::tuneConnectionStatusChanged(const bool &connected)
|
void DevicePluginTune::tuneConnectionStatusChanged(const bool &connected)
|
||||||
@ -254,16 +255,15 @@ void DevicePluginTune::tuneDataAvailable(const QByteArray &data)
|
|||||||
QVariantMap states = mood.value("states").toMap();
|
QVariantMap states = mood.value("states").toMap();
|
||||||
bool activeValue = states.value("active").toBool();
|
bool activeValue = states.value("active").toBool();
|
||||||
int value = states.value("value").toInt();
|
int value = states.value("value").toInt();
|
||||||
|
|
||||||
if (activeValue) {
|
if (activeValue) {
|
||||||
// disable any active mood
|
|
||||||
activateMood(device);
|
activateMood(device);
|
||||||
} else {
|
} else {
|
||||||
device->setStateValue(activeStateTypeId, activeValue);
|
device->setStateValue(activeStateTypeId, activeValue);
|
||||||
}
|
}
|
||||||
device->setStateValue(valueStateTypeId, value);
|
device->setStateValue(valueStateTypeId, value);
|
||||||
}
|
}
|
||||||
} else if (message.contains("tune")) {
|
}
|
||||||
|
if (message.contains("tune")) {
|
||||||
QVariantMap tune = message.value("tune").toMap();
|
QVariantMap tune = message.value("tune").toMap();
|
||||||
Device *device = deviceManager()->findConfiguredDevice(DeviceId(tune.value("deviceId").toString()));
|
Device *device = deviceManager()->findConfiguredDevice(DeviceId(tune.value("deviceId").toString()));
|
||||||
if (device) {
|
if (device) {
|
||||||
|
|||||||
Reference in New Issue
Block a user