Merge remote-tracking branch 'origin/avea-light-interfaces'

This commit is contained in:
Jenkins 2018-04-19 12:04:46 +02:00
commit 43f44148fa
3 changed files with 36 additions and 3 deletions

View File

@ -205,7 +205,7 @@ bool AveaBulb::syncColor()
return false;
}
m_device->setStateValue(aveaBlueStateTypeId, m_white);
m_device->setStateValue(aveaWhiteStateTypeId, m_white);
m_device->setStateValue(aveaRedStateTypeId, m_red);
m_device->setStateValue(aveaGreenStateTypeId, m_green);
m_device->setStateValue(aveaBlueStateTypeId, m_blue);

View File

@ -498,12 +498,32 @@ DeviceManager::DeviceError DevicePluginElgato::executeAction(Device *device, con
device->setStateValue(aveaColorStateTypeId, color);
return DeviceManager::DeviceErrorNoError;
} else if (action.actionTypeId() == aveaColorTemperatureActionTypeId) {
int ctValue = action.param(aveaColorTemperatureActionParamTypeId).value().toInt();
// normalize from 0 to 347 instead of 153 to 500
int ct = ctValue - 153;
// for blue: lower half fades blue from 255 to 0
// ct : (255-blue) = (347 / 2) : 255
int blue = qMax(0, 255 - (ct * 255 / (347 / 2)));
// for red: upper half fades red from 0 255
// ct - (347/2) : red = (347 / 2) : 255
int red = qMax(0, (ct - (347/2)) * 255 / ((500-153)/2));
QColor color;
color.setRed(red);
color.setGreen(0);
color.setBlue(blue);
if (!bulb->setWhite(4095) || !bulb->setColor(color)) {
return DeviceManager::DeviceErrorHardwareNotAvailable;
}
device->setStateValue(aveaColorStateTypeId, color);
device->setStateValue(aveaColorTemperatureStateTypeId, ctValue);
return DeviceManager::DeviceErrorNoError;
} else if (action.actionTypeId() == aveaWhiteActionTypeId) {
int whiteValue = action.param(aveaWhiteActionParamTypeId).value().toInt();
if (!bulb->setWhite(whiteValue))
return DeviceManager::DeviceErrorHardwareNotAvailable;
device->setStateValue(aveaWhiteStateTypeId, whiteValue);
return DeviceManager::DeviceErrorNoError;
} else if (action.actionTypeId() == aveaGreenActionTypeId) {
int greenValue = action.param(aveaGreenActionParamTypeId).value().toInt();

View File

@ -14,7 +14,7 @@
"displayName": "Avea",
"deviceIcon": "LightBulb",
"basicTags": ["Device", "Actuator", "Lighting"],
"interfaces": ["connectable"],
"interfaces": ["connectable", "light", "colorlight"],
"createMethods": ["discovery"],
"paramTypes": [
{
@ -78,6 +78,19 @@
"defaultValue": "#000000",
"writable": true
},
{
"id": "8932ddac-d718-4345-94aa-f4c9611f132f",
"name": "colorTemperature",
"displayName": "color temperature",
"displayNameEvent": "color temperature changed",
"displayNameAction": "Set color temperature",
"type": "int",
"unit": "Mired",
"defaultValue": 170,
"minValue": 153,
"maxValue": 500,
"writable": true
},
{
"id": "50f6a224-fb8d-487d-8774-1a0536e5b1aa",
"name": "white",