Skip to content

Commit

Permalink
Additional special effects for Hue lights (#7922)
Browse files Browse the repository at this point in the history
With the 1.116.3 / 67.116.3 firmware upgrade from May 2024, most Hue lights get additional special effects (see https://www.philips-hue.com/en-us/support/release-notes/lamps). There's also a new (undocumented) "sunset" effect, which basically is the reverse of the "sunrise" effect.

Most of these changes should be reflected by the API automatically when, the attributes from the Hue Effects cluster are re-read after the firmware update.

This PR adds support for the new "sunset" effect. It also brings the GUI up to date with the API ("opal" and "glisten" were missing and "prism" was still called "loop"). It enables the Hue-specific Startup Current X and Startup Current Y attributes, now that the GUI bug handling attributes with the same ID but different manufacturer codes has been fixed.
Finally, it removes the values for state/effect from the DDFs for the Hue lights, as these are exposed through capabilities/color/effects, and as they depend on the firmware revision.

While changing the C++ code, I also fixed the handling of special effects for (white and/or white ambiance) lights that don't support colorloop, see #7451.
  • Loading branch information
ebaauw authored Sep 24, 2024
1 parent d4eda44 commit f601a6c
Show file tree
Hide file tree
Showing 16 changed files with 166 additions and 222 deletions.
2 changes: 1 addition & 1 deletion de_web_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3253,7 +3253,7 @@ void DeRestPluginPrivate::setLightNodeStaticCapabilities(LightNode *lightNode)
lightNode->removeItem(RStateY);
lightNode->addItem(DataTypeUInt16, RStateHue);
lightNode->addItem(DataTypeUInt8, RStateSat);
lightNode->addItem(DataTypeString, RStateEffect)->setValue(RStateEffectValues[R_EFFECT_NONE]);
lightNode->addItem(DataTypeString, RStateEffect)->setValue(QVariant("none"));
}
}

Expand Down
2 changes: 1 addition & 1 deletion de_web_plugin_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -1430,7 +1430,7 @@ public Q_SLOTS:
bool addTaskSimpleMeteringReadWriteAttribute(TaskItem &task, uint8_t readOrWriteCmd, uint16_t attrId, uint8_t attrType, uint32_t attrValue, uint16_t mfrCode=0);

// Advanced features of Hue lights.
QStringList getHueEffectNames(quint64 effectBitmap);
QStringList getHueEffectNames(quint64 effectBitmap, bool colorloop);
QStringList getHueGradientStyleNames(quint16 styleBitmap);
bool addTaskHueEffect(TaskItem &task, QString &effect);
bool validateHueGradient(const ApiRequest &req, ApiResponse &rsp, QVariantMap &gradient, quint16 styleBitmap);
Expand Down
3 changes: 3 additions & 0 deletions devices/philips/fc03_state.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ if (attrid === 0x0002) {
case 0x800C:
R.item('state/effect').val = 'glisten'
break
case 0x800D:
R.item('state/effect').val = 'sunset'
break
default:
R.item('state/effect').val = '0x' + effect.toString(16)
break
Expand Down
22 changes: 0 additions & 22 deletions devices/philips/light_zb3_C.json
Original file line number Diff line number Diff line change
Expand Up @@ -367,28 +367,6 @@
},
{
"name": "state/effect",
"values": [
[
"\"none\"",
"no effect is active"
],
[
"\"colorloop\"",
"colorloop through hue values"
],
[
"\"candle\"",
"candlelight dynamic effect"
],
[
"\"fireplace\"",
"fireplace dynamic effect"
],
[
"\"prism\"",
"prism dynamic effect"
]
],
"parse": {
"fn": "zcl:attr",
"ep": "0x0b",
Expand Down
38 changes: 0 additions & 38 deletions devices/philips/light_zb3_C_festavia.json
Original file line number Diff line number Diff line change
Expand Up @@ -289,44 +289,6 @@
},
{
"name": "state/effect",
"values": [
[
"\"none\"",
"no effect is active"
],
[
"\"colorloop\"",
"colorloop through hue values"
],
[
"\"candle\"",
"candlelight dynamic effect"
],
[
"\"fireplace\"",
"fireplace dynamic effect"
],
[
"\"prism\"",
"prism dynamic effect"
],
[
"\"sunrise\"",
"sunrise dynamic effect"
],
[
"\"sparkle\"",
"sparkle dynamic effect"
],
[
"\"opal\"",
"opal dynamic effect"
],
[
"\"glisten\"",
"glisten dynamic effect"
]
],
"parse": {
"fn": "zcl:attr",
"ep": "0x0b",
Expand Down
26 changes: 0 additions & 26 deletions devices/philips/light_zb3_C_gradient.json
Original file line number Diff line number Diff line change
Expand Up @@ -361,32 +361,6 @@
},
{
"name": "state/effect",
"values": [
[
"\"none\"",
"no effect is active"
],
[
"\"colorloop\"",
"colorloop through hue values"
],
[
"\"candle\"",
"candlelight dynamic effect"
],
[
"\"fireplace\"",
"fireplace dynamic effect"
],
[
"\"prism\"",
"prism dynamic effect"
],
[
"\"sunrise\"",
"sunrise dynamic effect"
]
],
"parse": {
"fn": "zcl:attr",
"ep": "0x0b",
Expand Down
13 changes: 3 additions & 10 deletions devices/philips/light_zb3_white.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@
{
"name": "cap/bri/move_with_onoff"
},
{
"name": "cap/color/effects"
},
{
"name": "cap/on/off_with_effect"
},
Expand Down Expand Up @@ -163,16 +166,6 @@
},
{
"name": "state/effect",
"values": [
[
"\"none\"",
"no effect is active"
],
[
"\"candle\"",
"candlelight dynamic effect"
]
],
"read": {
"fn": "none"
}
Expand Down
13 changes: 3 additions & 10 deletions devices/philips/light_zb3_white_ambiance.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@
{
"name": "cap/color/ct/min"
},
{
"name": "cap/color/effects"
},
{
"name": "cap/on/off_with_effect"
},
Expand Down Expand Up @@ -246,16 +249,6 @@
},
{
"name": "state/effect",
"values": [
[
"\"none\"",
"no effect is active"
],
[
"\"candle\"",
"candlelight dynamic effect"
]
],
"read": {
"fn": "none"
}
Expand Down
22 changes: 0 additions & 22 deletions devices/philips/light_zll_C.json
Original file line number Diff line number Diff line change
Expand Up @@ -245,28 +245,6 @@
},
{
"name": "state/effect",
"values": [
[
"\"none\"",
"no effect is active"
],
[
"\"colorloop\"",
"colorloop through hue values"
],
[
"\"candle\"",
"candlelight dynamic effect"
],
[
"\"fireplace\"",
"fireplace dynamic effect"
],
[
"\"prism\"",
"prism dynamic effect"
]
],
"parse": {
"fn": "zcl:attr",
"ep": "0x0b",
Expand Down
13 changes: 3 additions & 10 deletions devices/philips/light_zll_white_ambiance.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@
{
"name": "cap/color/ct/min"
},
{
"name": "cap/color/effects"
},
{
"name": "cap/on/off_with_effect"
},
Expand Down Expand Up @@ -180,16 +183,6 @@
},
{
"name": "state/effect",
"values": [
[
"\"none\"",
"no effect is active"
],
[
"\"candle\"",
"candlelight dynamic effect"
]
],
"parse": {
"fn": "zcl:attr",
"ep": "0x0b",
Expand Down
16 changes: 10 additions & 6 deletions general.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2995,10 +2995,6 @@ Note: It does not clear or delete previous weekly schedule programming configura
<attribute id="0x0002" name="Remaining Time" type="u16" access="r" range="0x0000,0xfffe" default="0x0000" required="o"></attribute>
<attribute id="0x0003" name="Current X" type="u16" access="r" range="0x0000,0xfeff" default="0x61eb" required="m"></attribute>
<attribute id="0x0004" name="Current Y" type="u16" access="r" range="0x0000,0xfeff" default="0x607b" required="m"></attribute>
<!--
<attribute id="0x0003" mfcode="0x100b" name="Hue StartUp Current X" type="u16" access="rw" range="0x0000,0xffff" default="0xffff" required="o"></attribute>
<attribute id="0x0004" mfcode="0x100b" name="Hue StartUp Current Y" type="u16" access="rw" range="0x0000,0xffff" default="0xffff" required="o"></attribute>
-->
<!-- Haven't yet seen any lights supporting these
<attribute id="0x0005" name="Drift Compensation" type="enum8" access="r" required="o">
<value name="None" value="0x00"></value>
Expand Down Expand Up @@ -3041,6 +3037,8 @@ Note: It does not clear or delete previous weekly schedule programming configura
<attribute id="0x400c" name="Color Temperature Max Mireds" type="u16" access="r" range="0x0000,0xfeff" default="0xfeff" required="m"></attribute>
<attribute id="0x400d" name="Couple Color Temp To Min Mireds" type="u16" access="r" range="0x0000,0xfeff" required="m"></attribute>
<attribute id="0x4010" name="StartUp Color Temperature Mireds" type="u16" access="rw" range="0x0000,0xffff" default="0xffff" required="o"></attribute>
<attribute id="0x0003" mfcode="0x100b" name="Hue StartUp Current X" type="u16" access="rw" range="0x0000,0xffff" default="0xffff" required="o"></attribute>
<attribute id="0x0004" mfcode="0x100b" name="Hue StartUp Current Y" type="u16" access="rw" range="0x0000,0xffff" default="0xffff" required="o"></attribute>
</attribute-set>
<attribute-set id="0x0010" description="Defined Primaries Information">
<attribute id="0x0010" name="Number of Primaries" type="u8" access="r" range="0x00,0x06" required="o"></attribute>
Expand Down Expand Up @@ -5168,9 +5166,12 @@ These devices can operate on either battery or mains power, and can have a wide
<value name="None" value="0x00"/>
<value name="Candle" value="0x01"/>
<value name="Fireplace" value="0x02"/>
<value name="Loop" value="0x03"/>
<value name="Prism" value="0x03"/>
<value name="Sunrise" value="0x09"/>
<value name="Sparkle" value="0x0a"/>
<value name="Opal" value="0x0b"/>
<value name="Glisten" value="0x0c"/>
<value name="Sunset" value="0x0d"/>
</attribute>
</payload>
</command>
Expand All @@ -5187,9 +5188,12 @@ These devices can operate on either battery or mains power, and can have a wide
<attribute id="0x0011" name="Effects" type="bmp64" mfcode="0x100b" access="r" required="o">
<value name="Candle" value="0x01"/>
<value name="Fireplace" value="0x02"/>
<value name="Loop" value="0x03"/>
<value name="Prism" value="0x03"/>
<value name="Sunrise" value="0x09"/>
<value name="Sparkle" value="0x0a"/>
<value name="Opal" value="0x0b"/>
<value name="Glisten" value="0x0c"/>
<value name="Sunset" value="0x0d"/>
</attribute>
<attribute id="0x0012" name="Gradient Unknown 12" type="bmp32" mfcode="0x100b" access="r" required="o">
<value name="Unknown 00" value="0x00"/>
Expand Down
27 changes: 16 additions & 11 deletions hue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ code effects[] = {
{ 0x09, QLatin1String("sunrise") },
{ 0x0a, QLatin1String("sparkle") },
{ 0x0b, QLatin1String("opal") },
{ 0x0c, QLatin1String("glisten") }
{ 0x0c, QLatin1String("glisten") },
{ 0x0d, QLatin1String("sunset") }
};

quint8 effectNameToValue(QString &effectName)
Expand All @@ -41,11 +42,13 @@ quint8 effectNameToValue(QString &effectName)
\param effectBitmap - the bitmap with supported effects (from 0x0011)
\return QStringList of effect names
*/
QStringList DeRestPluginPrivate::getHueEffectNames(quint64 effectBitmap)
QStringList DeRestPluginPrivate::getHueEffectNames(quint64 effectBitmap, bool colorloop)
{
QStringList names = {
"none", "colorloop"
};
QStringList names = { QLatin1String("none") };
if (colorloop)
{
names.append(QLatin1String("colorloop"));
}
for (auto &e: effects) {
if (effectBitmap & (0x01 << e.value))
{
Expand Down Expand Up @@ -119,12 +122,14 @@ bool DeRestPluginPrivate::addTaskHueEffect(TaskItem &task, QString &effectName)
QDataStream stream(&task.zclFrame.payload(), QIODevice::WriteOnly);
stream.setByteOrder(QDataStream::LittleEndian);

if (effectName == "none") {
stream << (quint16) 0x0020; // clear effect
stream << (quint8) 0; // off
} else {
stream << (quint16) 0x0021; // set effect (with on/off)
stream << (quint8) 1; // on
stream << (quint16) 0x0021; // set effect (with on/off)
stream << (quint8) 1; // on
if (effectName == "none")
{
stream << (quint8) 0; // none
}
else
{
stream << effectNameToValue(effectName);
}
}
Expand Down
2 changes: 1 addition & 1 deletion light_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ void LightNode::setHaEndpoint(const deCONZ::SimpleDescriptor &endpoint)
}
else
{
addItem(DataTypeString, RStateEffect)->setValue(RStateEffectValues[R_EFFECT_NONE]);
addItem(DataTypeString, RStateEffect)->setValue(QVariant("none"));
addItem(DataTypeUInt16, RStateHue);
addItem(DataTypeUInt8, RStateSat);
}
Expand Down
2 changes: 0 additions & 2 deletions resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,6 @@ extern const QStringList RStateAlertValues;
extern const QStringList RStateAlertValuesTriggerEffect;

extern const QStringList RStateEffectValues;
#define R_EFFECT_NONE 0
#define R_EFFECT_COLORLOOP 1
extern const QStringList RStateEffectValuesMueller;
extern const QStringList RStateEffectValuesXmasLightStrip;

Expand Down
Loading

0 comments on commit f601a6c

Please sign in to comment.