Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle supported 'state' changes via FC03 for supported Philips Hue lights #7950

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion de_web_plugin_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -808,9 +808,26 @@ enum TaskType
TaskTuyaRequest = 41,
TaskXmasLightStrip = 42,
TaskSimpleMetering = 43,
TaskHueEffect = 44
TaskHueEffect = 44,
TaskHueManufacturerSpecific = 45
};

// Option set to represent the payload items in a '0xfc03' cluster's '0x00' command.
enum HueManufacturerSpecificPayload : quint16
{
None = 0x0, // 0x0000
On = 1 << 0, // 0x0001
Brightness = 1 << 1, // 0x0002
ColorTemperature = 1 << 2, // 0x0004
Color = 1 << 3, // 0x0008
TransitionTime = 1 << 4, // 0x0010
Effect = 1 << 5, // 0x0020
UNKNOWN = 1 << 6, // 0x0040
EffectDuration = 1 << 7 // 0x0080
};
Q_DECLARE_FLAGS(HueManufacturerSpecificPayloads, HueManufacturerSpecificPayload)
Q_DECLARE_OPERATORS_FOR_FLAGS(HueManufacturerSpecificPayloads)

enum XmasLightStripMode
{
ModeWhite = 0,
Expand Down Expand Up @@ -1432,9 +1449,13 @@ public Q_SLOTS:
// Advanced features of Hue lights.
QStringList getHueEffectNames(quint64 effectBitmap, bool colorloop);
QStringList getHueGradientStyleNames(quint16 styleBitmap);
bool isHueEffectLight(const LightNode *lightNode);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's probably some more places in rest_light.cpp where this could be leveraged.

bool isMappableToManufacturerSpecific(const QVariantMap &map);
bool addTaskHueEffect(TaskItem &task, QString &effect);
bool validateHueGradient(const ApiRequest &req, ApiResponse &rsp, QVariantMap &gradient, quint16 styleBitmap);
bool addTaskHueGradient(TaskItem &task, QVariantMap &gradient);
bool addTaskHueManufacturerSpecific(TaskItem &task, HueManufacturerSpecificPayloads &payloadItems, QVariantMap &items);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this routine going to be invoked outside hue.cpp? If not, better define it locally in hue.cpp rather than including it in DeRestPluginPrivate. In that case, also define HueManufacturerSpecificPayload locally.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I decided on having it here cause I noticed a couple of places in rest_lights.cpp that call out to addTaskHueEffect() and figured addTaskHueManufacturerSpecific() would eventually succeed them.

int setHueLightState(const ApiRequest &req, ApiResponse &rsp, TaskItem &taskRef, QVariantMap &map);

// Merry Christmas!
bool isXmasLightStrip(const LightNode *lightNode);
Expand Down
Loading