Closed
Description
I've finally found the time to refactor the setting of the state
of a /lights
resource, see #1111 (comment). Next to the functional changes, I'm also adding parameter checking.
The logic for handling on
and bri
is described in the issue mentioned above. The logic for handling the other attributes is less clear. I run into some design decisions for these, @manup, everybody, please provide your input.
- The Hue API clearly states:
xy
trumpsct
trumpshue
andsat
. It ignores the over-trumped attributes without issuing an error, but clients can tell because they aren't reported in the response. Not sure howeffect
is supposed to relate to these. I want to do the following: for"none"
, clear the colour loop before handling the colour attributes; for"colorloop"
, set the colour loop after handling the colour attributes. And return an error for the colour attributes while colour loop is active (just as forbri
and colour attributes when the light is off). - While not documented, I think the Hue API also acts like:
bri
trumpsbri_inc
andct
trumpsct_inc
. Note that the deCONZ API doesn't exposexy_inc
,hue_inc
, norsat_inc
. While they might be great for rule actions for the magic cube, I haven't seen any use for these; - There is no
ResourceItem
foreffect
. Looking at the code,effect
is exposed only whenxy
is. On the other hand, setting the colour loop changescolormode
tohs
? - I'm not sure I fully understand the code handling
hue
andsat
. It would seem the plugin tries to calculate and update thexy
values from thehue
andsat
values for the benefit oftaskToLocalData()
. Why isn't there similar logic for updatingct
. And for updatingxy
andhue
/sat
when settingct
? And for updatingct
andhue
/sat
when updatingxy
?
I think API clients should take notice ofcolormode
and only process the corresponding attributes (homebridge-hue does).
I would really like to defer this setting of other colour attributes to the light, although not all non-Hue lights updatexy
,ct
, orhue
/sat
from other colour modes; - I'm missing an
addTaskSetEnhancedHueAndSaturation()
inzcl_tasks.cpp
. Is that intentional or just for historic reasons? Preferably, I would have a singleaddTask...()
to set any combination of hue/enhanced hue and sat, depending on the light capabilities; - What's the policy for exposing attributes that aren't supported by the light? E.g. exposing
ct
for Color lights, orhue
andsat
for lights that don't support these for Alexa's benefit. And for using a different colour mode than specified in the API call to set the colour (e.g. settinghue
/sat
whenxy
was specified, or settingxy
whenct
was specified). How to handlecolormode
in these cases: I think it should report the actual light mode?
Personally I feel this is a poor decision, leading only to confusion. If a light doesn't supporthue
andsat
, it doesn't work with Alexa, sorry. If a light doesn't supportct
, do thect
toxy
conversion in your API client. - Currently a number of non-light devices are exposed as
/lights
resources: _Window covering device, Warning device, Fan, Range Extender, and Configuration Tool (did I miss any?). For Window covering device,on
,bri
, andsat
are abused for Open, Percentage Lift and Percentage Tilt from the Window covering cluster. For Warning device,alert
is abused for Warning from the IAS WD cluster. The only Fan currently (in progress of being) is the Hampton Bay fan module (Fan Module (Hampton Bay) #932), which exposes the Fan Control cluster on the same endpoint as the On/Off and Level Control clusters (to expose the light). The fan is exposed though an addedspeed
attribute. I'm still not sure whether the Fan Control cluster should better be exposed as a separate (for now)/lights
resource. The Trådfri repeater supports Identify, and correctly maps that toalert
.
Most of these devices support Groups and Scenes, but the API cannot handle these. In preparation of this, I'd like to change the attributes for Window covering device toopen
,lift
, andtilt
(and get rid of the 0..254 to 0..100 translations) and for Warning device towarning
. As this would be a breaking change, how do we want to handle that. Expose old and new next to each other for a while?
It might be prudent to add the cluster to theuniqueid
of these non-light/lights
resources, but that might also be a breaking change. It would be needed to expose the Hamption Bay as two resources.